Back to News
Advertisement
991awebsi 2 days ago 2 commentsRead Article on github.com

ZH version is available. Content is displayed in original English for accuracy.

treepeat is a tool that finds similarities in your codebase.

Find duplicate code blocks meaningful to the language (classes/functions), not just lines.

Find near-duplicates: ignore whitespace, strings, high level AST nodes such as function and names.

Find structurally similar code: anonymize identifiers, constants, etc.

Pull requests welcome: This is very much an proof of concept - I'm happy with it, but I haven't supported very many languages at present.

Languages supported: astro, bash, css, go, html, javascript, lua, markdown (plus codeblocks), python, sql, typescript, java, kotlin, rust, yaml

Advertisement

⚡ Community Insights

Discussion Sentiment

33% Positive

Analyzed from 69 words in the discussion.

Trending Topics

#duplicate#code#codebases#wanted#help#detection#real#problem#agentic#programming

Discussion (2 Comments)Read Original on HackerNews

ryuuseijin•39 minutes ago
This is what I wanted to help with duplicate code detection, which is now a real problem with agentic programming since the agent tends to duplicate helper functions a lot in bigger codebases.

I ended up writing my own tool [1] that uses vector search, which works but can be unusably slow in large codebases.

I will give this a shot.

[1]: https://github.com/ninjaxtools/slopdex

bradleyy•about 2 hours ago
Thanks for posting this; I'm very interested in finding similar chunks of code in an AST-ish fashion, and using tree-sitter seems perfect.