Skip to main content

Code Duplication

Tools and engines for detecting copy-pasted fragments and structural clones across Dart and Flutter codebases.

dedupe

pub package

High-performance code duplication and clone detection engine and CLI tool for Dart and Flutter.

It scans codebases to detect token-level, structural, and near-miss code clones across files and packages with fast incremental analysis.

Comparison: avoid_duplicate_code vs dedupe

avoid_duplicate_codededupe
Tool typeDart Analyzer / Linter plugin ruleStandalone CLI tool & Dart library/API
Primary workflowReal-time in-IDE feedback and dart analyzeRepository auditing, CI/CD checks, PR gating, batch analysis
Detection approachBlock-level (AST): Analyzes complete syntactic structures (functions, methods, closures, if/for bodies)Sequence-level (Tokens): Analyzes continuous sequences of code anywhere across files
Whole functions & blocks
(e.g., duplicated methods with renamed variables)
DetectedDetected
Sub-method fragments
(e.g., 5–10 copied lines inside a 50-line method)
Skipped (only evaluates complete blocks/methods)Detected (flags duplicate snippets regardless of block boundaries)
Near-miss / modified clones
(e.g., copy-paste with an extra line or minor edit)
Skipped (requires matching syntactic block structure)Detected (fuzzy matching detects clones with insertions/deletions)
Differing literals diffingDetailed in-IDE diff (pinpoints exact differing values, e.g. 'email' vs 'sms')No per-value diff (flags clone locations without a detailed literal breakdown)
Reporting & diagnosticsIDE Problems & Related LocationsMarkdown, JSON, GitHub Actions annotations, % duplication metrics
Disk cache usage

💡 Best Together: Use avoid_duplicate_code for instant IDE feedback, and dedupe for CI/CD quality gates and repository-wide code clone audits.