Skip to main content
fallow dupes finds duplicated code blocks across your entire codebase. jscpd v5 is faster for raw duplication scanning on the current README benchmark fixtures; fallow’s advantage is running duplication inside the same audit flow as dead code, dependency, complexity, and architecture checks.

Why built-in duplication matters

Most dead-code analysis tools stop at finding unused exports and unreachable files. Fallow goes further: it includes duplication detection in the same binary, using the same module graph. This means you can cross-reference dead code with duplication in a single pass. When you run fallow dead-code --include-dupes, fallow identifies code blocks that are both duplicated and unused. These are the highest-value cleanup targets: removing them eliminates dead code and reduces duplication simultaneously. Running duplication analysis alongside dead-code detection also means:
  • One tool, one config, one CI step: No need to install and configure a separate duplication detector
  • Shared file discovery: The same ignore patterns, entry points, and workspace config apply to both analyses
  • Cross-analysis insights: Clone families that span unused files are flagged as combined findings
  • Consistent output formats: JSON, SARIF, markdown, compact, and CodeClimate output work the same way for duplication as for dead code

Detection modes

Exact token-for-token clones only. No normalization is applied; the code must be character-identical after tokenization.
Best for finding exact copy-paste where nothing was changed.
Start with mild mode (default). Upgrade to semantic when you want to catch clones with renamed variables.

Near-miss clones

Add --near to include function-scoped clones with small structural edits:
Near-miss detection uses semantic token normalization and requires at least 80% shingle similarity between every pair in a group. It runs alongside exact clone detection and remains opt-in because it does more work and can surface code that needs human review. Set duplicates.near to true to enable it by default, or use fallow.duplication.near in VS Code. Here’s what typical output looks like:
$ fallow dupes
In semantic mode, fallow also reports renamed identifiers:
$ fallow dupes --mode semantic

Thresholds and limits

Minimum occurrences

By default fallow reports every duplicated pair (minOccurrences: 2). If you follow the “rule of three” and only want to refactor logic once it appears in three or more places, raise the threshold:
Values below 2 are rejected, since a single occurrence is not a duplicate. Raising this skips context-sensitive pairs and focuses on widespread copy-paste worth abstracting. The VS Code extension exposes the same control as the fallow.duplication.minOccurrences setting.

Spread-aware ranking

Fallow multiplies duplicated token count by occurrence count, then applies a spread boost. Spread is the maximum directory-tree distance between copies. Copies in the same file use one spread step per 250 lines of separation. The boost is capped at 15%, so larger and more repeated clones remain the main priority. The default report and --top use this order. JSON output includes spread on every clone group, plus similarity for near-miss groups.

Reviewed clone groups

Use duplicates.ignoredClones when a specific clone group is intentional but you want other duplication findings to remain active:
Each entry combines the group’s fingerprint with its instance count. Copy the fingerprint from the human listing or clone_groups[].fingerprint in JSON, then append :<instance_count>. A token change or a new copy makes the group reportable again. Formatting-only edits keep the same fingerprint. JSON output sets stats.clone_groups_ignored when reviewed groups are hidden. Near-miss runs set stats.near_candidates_skipped if bounded-work limits skip candidate comparisons, which means the near-miss result may be incomplete.

Clone families

Clone groups sharing the same file set are grouped into clone families with refactoring suggestions:
  • Extract function: clones are in the same file
  • Extract module: clones span multiple files

Cross-language detection

Compare TypeScript and JavaScript files by stripping type annotations:
Fallow normalizes .ts files to their .js equivalent for comparison. This catches clones where one copy was converted from TypeScript to JavaScript or vice versa.

Ignoring imports

Files with the same module wiring are a structural property of well-formatted code, not copy-paste, so that wiring is stripped from the token stream by default. This covers ES imports, re-export declarations, and top-level static require() binding declarations. To count module wiring as clone candidates again, opt out on the command line:
Or set it permanently in config:
Runtime code, local exports, side-effect require() calls, nested require() calls, dynamic require arguments, and mixed declarations are still counted.

Incremental analysis

Only check duplication in files changed since a git ref:
Useful in CI to only report new duplication introduced in a pull request.

Baseline comparison

Adopt duplication limits incrementally:

Debugging

Trace all clones of a specific code location:

Benchmarks vs jscpd

Cold runs (no cache) so each tool works from scratch. Fastest tool per row in bold. jscpd’s Rust rewrite (v5) is faster than fallow for raw duplication scanning across these projects. Fallow’s advantage is running duplication inside the same single audit pass as dead code, dependency, complexity, CSS, framework, and security checks, not raw scan speed. Fallow uses a with for clone detection, avoiding quadratic pairwise comparison.

See also

CLI: dupes

Full reference for the fallow dupes command and its flags.

Configuration

Set default duplication thresholds and modes in your config file.

Migrating from jscpd

Replace jscpd with fallow in your project.