Documentation
¶
Overview ¶
Package duplication is a deterministic, pure-Go copy-paste (clone) detector: it walks a source tree, tokenizes each file (comment- and whitespace-insensitive, language-aware comment stripping), and finds runs of duplicated tokens across and within files via a Rabin-Karp rolling hash, then reports the standard duplication metrics (blocks, duplicated lines, files, density). It NEVER executes the target and reads bounded (skips vendored/binary/oversized files, follows no symlinks). Pure Go with no CGO, so it is available in every build (unlike the tree-sitter metrics sidecar). Exact (Type-1) clones: identifiers and literals are matched by text, which is the copy-paste signal operators expect.
Index ¶
Constants ¶
const ( // DefaultMinTokens is the smallest duplicated token run reported by default. Tokens here are at // lexer granularity (an identifier/number, a whole string literal, or an operator run – see the // tokenizer), so 100 matches the long-standing PMD/CPD default and keeps trivial repetition out. DefaultMinTokens = 100 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector finds duplicated token runs of at least MinTokens tokens.
func (*Detector) Duplication ¶
Duplication walks root, tokenizes each supported source file, and returns the duplication report.