Find similar code

Proprietary

Detect structurally similar (but not identical) methods with MinHash/LSH near-duplicate matching over their AST shingles (zero AI), reporting an approximate similarity percentage. Complements exact duplicate detection by surfacing restructured near-duplicates worth consolidating.

io.moderne.prethink.quality.FindSimilarCode

Optional

Minimum Jaccard similarity (as a percentage) for two methods to be considered similar. Defaults to 70.

Maximum similarity (percentage) to report. Pairs more similar than this are exact or near-exact duplicates that exact clone detection already covers, so they are excluded here. Defaults to 99; set to 100 to include perfect matches.

Minimum number of AST nodes a method must contain to be considered. Smaller methods have too few features for a meaningful similarity signal. Defaults to 40.

Minimum number of distinct AST shingles a method must have to be considered. Defaults to 8.

Minimum number of AST nodes a subtree must contain to be used as a shingle (feature). Defaults to 3.

includeTestSourcesBoolean

Whether to include test sources (paths under src/test). Defaults to false.

suppressBoilerplateBoolean

Whether to skip getters/setters, equals/hashCode/toString, and all-trivial methods. Defaults to true.

Maximum number of lines of the representative method to include in the snippet. Defaults to 40.

Cap on the number of member methods listed per group. Defaults to 200.

mod run . --recipe=io.moderne.prethink.quality.FindSimilarCode

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.