Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Use a clone detector to find repeated code, then review each match in context. A report identifies fragments that meet a tool’s similarity rules; it cannot tell you whether they implement the same behavior or should become one abstraction. Prioritize duplicates that share a purpose, change for similar reasons, and carry meaningful maintenance risk—not simply the longest matches or the highest duplication percentage.

What counts as duplicated code?

Code-clone research commonly groups similarities into four types. These labels describe degrees of syntactic similarity, not a universal ranking of quality or risk:

  • Type 1: Identical code apart from formatting, whitespace, or comments.
  • Type 2: Similar code with changes such as renamed identifiers or different literals.
  • Type 3: Similar fragments with statements added, removed, or changed.
  • Type 4: Code that behaves similarly but may have little or no syntactic resemblance.

Clone detectors generally compare syntax, tokens, lines, or structures according to their own algorithms. A tool may find some Type 1–3 clones while missing behaviorally equivalent implementations that look different; tools do not all detect the same clone types. The distinctions and detection approaches are discussed in this comparison of clone-detection techniques.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A match is a candidate to inspect, not a refactoring instruction. Similar-looking code may implement different rules, while semantic duplication may escape a detector entirely. Fowler’s description of a code smell is a useful frame: duplication can signal a problem, but the signal needs judgment.

#1 Best Overall
GameStop Physical Gift Card
  • Redeemable at US GameStop, EB Games, Babbage's, Electronic Boutique, EBX, Planet X, and Software Etc. stores. Also redeemable online at and GameStop.com and EBGames.com.
  • Over 6,100 stores located throughout the United States.
  • GameStop. Power to the Players.
  • Redemption: Instore and Online
  • No returns and no refunds on gift cards.

Choose a detector that fits the repository

Start with the languages and file types actually maintained in the repository, including templates or embedded languages where relevant. Then check how each candidate tool handles matching and whether its reports are practical for your workflow.

  • Language and format support: Confirm support for the exact languages, file extensions, and syntax in your codebase. A broad format list does not guarantee every embedded-language construct is analyzed as you expect.
  • Matching behavior: Review token or line thresholds, comment handling, and whether identifiers or literals are normalized. Broader normalization can reveal renamed copies, but it can also increase noise.
  • Scope controls: Check how to select paths and exclude generated files, dependencies, or other noise. Keep exclusions narrow and documented.
  • Workflow fit: Check report formats, source locations, performance at repository scale, and how findings affect a CI process.

PMD’s Copy/Paste Detector (CPD) is one example for language-specific scans and multiple report formats. jscpd is another option, with support for many formats. Neither is a universal winner: choose based on your repository’s formats, matching needs, and reporting workflow.

Run a scoped first scan

Scan maintained source rather than every file in the checkout. Decide deliberately whether to include tests: duplicated test setup may be harmless, but duplicated assertions or test logic can create their own maintenance burden. Generated code, vendored dependencies, build output, snapshots, fixtures, and intentional templates may need exclusion if they overwhelm useful findings.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Xbox Physical Gift Card
  • XBOX GIFT CARD: Buy full digital game downloads, game add-ons, in-game currency, memberships, devices, apps, movies, TV shows, and more.
  • DIGITAL GAMES: Choose from hundreds of games, from AAA to indie options. Start playing the moment your most anticipated game is available when you pre-order and pre-download it.
  • GAME AD-ONS: Extend the experience of your favorite games with add-ons and in-game currency.
  • MOVIES & TV SHOWS: Rent or buy new and popular movies and TV shows from a massive library.
  • PERFECT GIFT: Great as a gift for a friend or yourself. Xbox Gift Cards are easy to use, never expire, and give the freedom to pick the gift they want. Enjoy more ways to play without a credit card attached to your Microsoft account.

For Java, this PMD CPD command scans two directories and prints a text report:

pmd cpd --minimum-tokens 100 --dir src/main/java --dir src/test/java --language java --format text
  • --minimum-tokens 100 sets an example minimum match size; 100 is not a universal recommended cutoff.
  • Each --dir adds a directory to the scan.
  • --language java selects Java handling, and --format text requests a text report.

PMD documents these options and other report formats, including XML, CSV, and Markdown, in its CPD usage guide. The CLI reference describes path selection and exclusions; option availability varies by command and version, and --exclude-file-list is documented for CPD starting with version 7.14.0. Check the reference for your installed version before relying on a particular option.

jscpd exposes line and token thresholds, exclusions, matching modes, reporters, and format selection. Its current configuration documentation lists defaults of five duplicated lines, 50 tokens, and mild mode, as well as .gitignore handling; defaults and options are release-sensitive. Check the configuration for the installed release instead of assuming those defaults apply to every version.

Rank #3
$100 XBOX Gift Card [Digital Code]
  • THE PERFECT GAMING GIFT — Buy an XBOX Gift Card for yourself or a friend and let them choose the games, add‑ons, subscriptions, and accessories they want most.
  • USE FOR GAMES & CONTENT — Redeem for thousands of digital XBOX games, from backward compatible classics to the latest new releases, plus DLC and in‑game currency.
  • GAME PASS READY — Apply your balance toward XBOX Game Pass Ultimate to play new titles on day one* and access a library of hundreds of high‑quality console games.
  • PRE‑ORDER & PRE‑INSTALL GAMES — Use your balance to pre‑order and pre‑download upcoming titles so you’re ready to play the moment they launch.
  • NO FEES OR EXPIRATION — XBOX Gift Cards never expire and have no service fees, so your balance is ready whenever you are.

Understand the CI exit status before adding a gate

For current PMD documentation, CPD returns status 4 when it detects duplicates, status 5 for recoverable errors, and status 0 when it finds neither duplicates nor recoverable errors. A recoverable error can mean some files were not fully analyzed, so a scan that returns status 5 is not equivalent to a clean, complete scan. PMD also documents statuses 1 for an exception and 2 for a usage error. Confirm the behavior in the CPD status documentation before wiring it into automation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Validate what the report found

For each promising match, inspect both fragments in full. A short excerpt can hide the callers, types, tests, comments, or domain boundary that explain why the code differs.

  1. Check behavior: Do the fragments enforce the same rule, or do they only look alike?
  2. Inspect meaningful differences: Determine whether permissions, error handling, lifecycle, platform, product boundary, or release cadence differ for a reason.
  3. Check the source of the match: Boilerplate, generated code, copied license headers, and framework conventions can produce matches without creating a useful refactoring target.
  4. Search beyond the reported pair: Look for other occurrences. Thresholds and report grouping can omit smaller or structurally different copies.
  5. Use history when it helps: Review repeated fixes, feature changes, or commits that touch fragments together. Co-change is evidence to investigate, not proof that the code belongs in one abstraction.

Matching rules affect what appears in the report. jscpd’s documentation describes mild matching as dropping whitespace, weak as also dropping comments, and strict as retaining all tokens; normalization of identifiers and literals also affects which clones are detected. Its guide to detection explains these choices. Before changing settings, inspect sample results so you understand how broader or narrower matching changes the review workload.

Rank #4
Fortnite Physical Gift Card
  • An Epic Games account is required to redeem an Epic Games Store Card code
  • If playing on a console platform (PlayStation Network, Xbox Live, Nintendo Switch or Mobile) you need to link your Epic Games account to that gaming platform (one time) to redeem your gift card code
  • The 16 digit code on the back of the card WILL NOT work if redeemed directly through your gaming platform (PlayStation Network, Xbox Live, Nintendo Switch, Mobile, etc.)
  • Note: Nintendo devices do not support Fortnite Shared Wallet, so V-Bucks purchased using your account balance will not show up on your Nintendo device. However, if you purchase items in the web Item Shop — or another platform where you play Fortnite — those items will be available in your Locker across all platforms.
  • Redemption: Online
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Prioritize by maintenance value, not match size alone

Use the detector to narrow the search, then weigh the candidate against the factors below. A long clone or a high duplication percentage is a screening signal—not a quality verdict. Percentages vary with the tool, version, configuration, language support, and paths scanned.

  • Impact: Is the logic security-sensitive, business-critical, error-prone, or costly to change?
  • Change likelihood: Does it change often? Have similar copies needed coordinated feature updates or bug fixes?
  • Evidence of maintenance burden: Do review or version-control histories show copies drifting, or fixes repeatedly applied to one copy but not another?
  • Semantic confidence: Do the fragments implement the same behavior, or is the match mostly syntactic?
  • Scope and cohesion: Are the copies close to one another and owned by the same abstraction? Would sharing them reduce cognitive load without creating awkward dependencies?
  • Refactor risk and reach: How many modules, teams, interfaces, or runtime constraints are involved, and are tests strong enough to support a safe change?

For example, repeated security checks in frequently changed production paths merit close review if they implement the same policy and have a history of coordinated fixes. Similar code in separate services or products may be better left separate when each side has distinct requirements or release ownership. A near-miss match can warrant careful inspection, but it is not automatically more important than an exact match.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Empirical findings do not provide a universal bug-risk score. A study of seven systems reported that 18.42% of clone fragments that experienced bug fixes were involved in the study’s defined bug-propagation patterns; that denominator is not all clones or all code. A separate study of nine systems found higher bug-proneness for Type 3 clones than for Type 1 or Type 2 in its sample, not as a rule for every repository. Findings vary with the systems, definitions, and methods used; they do not establish that a particular clone should be removed. See the studies on bug propagation through cloning and clone types and bug-proneness.

Best Value
$25 PlayStation Store Gift Card [Digital Code]
  • Redeem for anything on PlayStationStore: games, add-ons, PlayStationPlus and more.
  • Everything you want to play. Choose from the largest library of PlayStation content.
  • Use gift card funds to contribute towards PlayStationPlus memberships.

Know when to leave duplication in place

Eliminating every repeated line is not a sound mechanical goal. Two fragments may look alike but need to change for different reasons. Combining them can couple independent products, obscure intentional variation, or produce a shared helper full of options and conditionals.

  • Keep boundaries independent when ownership, release cadence, platform behavior, or domain rules differ.
  • Do not refactor generated or required code as ordinary source duplication. Address the generator or dependency policy if the generated output is causing an ongoing problem.
  • Treat test code on its own merits. A shared fixture can reduce repetitive setup, while an over-generalized test helper can make each test harder to understand.
  • Consider the likely lifespan. Temporary scaffolding may not justify introducing a lasting abstraction.

Research on clone changes likewise does not settle the decision: one study reported release-level defect rates from 1.02% to 4.00% for clone genealogies in three systems, using its own unit of analysis and method. Those figures illustrate variation in a specific study, not a general defect rate for duplicated code. See the study of inconsistent clone changes.

Refactor in small, verifiable steps

When the fragments have the same purpose and a shared change pattern, choose the smallest abstraction that fits their design. Local repetition may call for an extracted variable or method; a shared module or hierarchy-level abstraction needs a stronger case that ownership and reasons to change align. PMD’s documentation gives examples of local extraction and hierarchy-level options in its refactoring guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Establish tests for the observable behavior of the paths involved; add coverage for meaningful differences before changing structure.
  2. Make one small structural change at a time, preserving behavior as the goal.
  3. Run the relevant tests and static checks, then review the diff for accidental changes or lost variation.
  4. Re-run the detector if useful, but judge the outcome by maintainability and correctness—not merely by whether the reported count fell.

Fowler describes refactoring as a series of small transformations that preserve behavior; that is the aim, not a guarantee that an untested edit is safe. See his refactoring overview.

Keep the backlog manageable

For an existing codebase, establish a baseline so pre-existing findings do not have to block every change. If a gate is worthwhile, apply it to new duplication or changed code where practical, and choose a threshold only after reviewing representative matches. A gate that treats any finding as failure can disrupt builds, so account for the detector’s exit semantics and recoverable errors.

Quick Recap

Bestseller No. 1
GameStop Physical Gift Card
GameStop Physical Gift Card
Over 6,100 stores located throughout the United States.; GameStop. Power to the Players.; Redemption: Instore and Online
$25.00
Bestseller No. 2
Xbox Physical Gift Card
Xbox Physical Gift Card
MOVIES & TV SHOWS: Rent or buy new and popular movies and TV shows from a massive library.
$25.00
Bestseller No. 3
$100 XBOX Gift Card [Digital Code]
$100 XBOX Gift Card [Digital Code]
Gift cards are region‑specific (U.S. only) and cannot be transferred once redeemed.
$100.00
Bestseller No. 4
Fortnite Physical Gift Card
Fortnite Physical Gift Card
An Epic Games account is required to redeem an Epic Games Store Card code; Redemption: Online
$50.00
Bestseller No. 5
$25 PlayStation Store Gift Card [Digital Code]
$25 PlayStation Store Gift Card [Digital Code]
Redeem for anything on PlayStationStore: games, add-ons, PlayStationPlus and more.; Everything you want to play. Choose from the largest library of PlayStation content.
$25.00
  • Keep exclusions narrow, explain why they exist, and revisit them.
  • Use the same tool, version, configuration, branch assumptions, and source scope when tracking trends.
  • Do not compare percentages across different tools or configurations as if they measured the same thing.
  • Supplement automated scans with code review, targeted searches for repeated domain operations, IDE structural search, and version-history review; these can reveal semantic duplication a token-based scan misses.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.