Contact Us

CLONE DETECTION AND REMOVAL Services

Large software systems typically contain an estimated 10–25% or more redundant code, according to Semantic Designs. This redundancy often results from a common programming practice: copying and pasting existing code fragments, or cloning, and then modifying them to meet new application requirements.

A bug in one code fragment may also exist in its hidden clones. Every copy creates another opportunity for a bug fix to be missed, increases modernization costs, and forces reviewers to examine the same logic repeatedly.

Modernize Software’s CloneDR, is an AST-based code clone detector built on Semantic Designs’ DMS compiler technology. CloneDR identifies exact and near-miss clones, including code fragments with renamed variables or other edits. It detects duplication in both executable code and data declarations.

With the DMS Reengineering Toolkit, Modernize Software can go further by automating clone remediation: consolidating duplicated code into shared routines or structures and updating the corresponding call sites. The result is less redundant code, easier maintenance, and a more efficient modernization process.

Book A Free Clone Assessment
30+ yrs
Compiler Engineering
40+
Source Languages
PhD
Average Team Seniority
TRUSTED BY
NASA
Boeing
RTX
Rockwell Automation
Global Shop Solutions
BlackRock
ANZ
Northrop Grumman
Emerson
Proof

We wrote the paper. Then we ran it on 10 million lines.

In 1998 our founder, Dr. Ira Baxter, co-authored "Clone Detection Using Abstract Syntax Trees" (ICSM 1998), one of the founding papers of AST-based clone detection. CloneDR is that idea turned into a production tool.

10M+
Lines of Java and C# scanned
2 weeks
Plagiarism scan, start to findings
27,000
Lines removed from one Java application

Large global bank

CloneDR analyzed 10M+ lines of Java and C# to identify software plagiarism. Findings in two weeks.

Salion

On a 250,000-line Java application, partial clone removal guided by CloneDR eliminated 27,000 lines. That is more than a tenth of the system, gone.

Tableau

DMS refactored 4M+ lines of C++, updating call sites across 5,000+ modules in under 3 months. The same rewrite machinery updates every call site when a clone set becomes one function.

Clone types

Four kinds of copies, and which ones we catch

Researchers sort clones into four types; Roy and Cordy's definitions are the standard reference. Here is what each looks like and what CloneDR does with it.

Clone type
What differs between the copies
What CloneDR does
Clone typeType 1, exact
What differs between the copiesWhitespace, layout, comments
What CloneDR doesFound. Parsing discards formatting, comments, line breaks and case before anything is compared.
Clone typeType 2, renamed or parameterized
What differs between the copiesIdentifiers, literals, types
What CloneDR doesFound. Each difference becomes a named parameter of the clone set.
Clone typeType 3, near-miss
What differs between the copiesStatements added, changed or removed
What CloneDR doesFound within a difference threshold you set. Neighboring matches merge into larger clones; the gaps become parameters.
Clone typeType 4, semantic
What differs between the copiesSame computation, different syntax
What CloneDR doesNot claimed. CloneDR is a syntactic detector by design, which keeps its reports precise.
Why line and token tools fall short

Copy-paste detectors find the cheap copies and miss the expensive ones

Line-hash and token-window tools, including the duplicate checks in most linters and quality dashboards, compare text. Developers don't copy text. They copy code, then edit it.

Hazard
How DMS handles it
HazardA copied block with renamed variables
How DMS handles itMatched on syntax-tree shape. The renames become parameters, not misses.
HazardOne line inserted in the middle of a copy
How DMS handles itLine windows split it into two short fragments or report nothing. CloneDR merges the matches across the gap and parameterizes it.
HazardReformatted or re-commented copies
How DMS handles itIrrelevant. Formatting and comments never reach the comparison.
HazardBoilerplate floods: imports, getters, table initializers
How DMS handles itSize thresholds and whole syntactic units keep trivial matches out of the report.
HazardMatches that start mid-statement
How DMS handles itEvery clone is a complete syntax unit or statement sequence, so every clone can actually be extracted.
HazardCopies spread across subsystems
How DMS handles itWhole-system comparison across thousands of files, not one file or one module at a time.
HazardDuplicated record layouts and structs
How DMS handles itData declarations are compared, not just procedural code.
How detection works

System-scale clone detection, built on a compiler

Parse with a real front end

DMS parses each file with a full grammar for its language and builds an abstract syntax tree. Text artifacts are gone before matching starts.

Hash every subtree

CloneDR hashes arbitrary substructures of the program, which turns an all-pairs comparison into roughly linear work. It spreads across every processor on your server.

Grow and parameterize

Small matches merge with their neighbors into larger clones. Points of variation become parameters, within the similarity threshold you choose.

Emit the covering abstraction

For each clone set, CloneDR produces a detected code skeleton: the shared code, with parameter slots marked. It is the blueprint for removal.

The report gives the percentage of cloned code and the clone sets themselves, each with its skeleton and every location. For a fuller picture of a system, pair it with our code analysis services.

Where it pays

Five reasons teams call us about clones

Use case
What clone data does for you
Use casePre-migration shrink
What clone data does for youFewer lines to translate, test and pay for. Run it before a COBOL modernization or C++ modernization, not after.
Use caseBug propagation
What clone data does for you"Fixed in five places, missed in the sixth." A clone set lists every sibling of the code you just patched.
Use caseIP and plagiarism audits
What clone data does for youCompare two codebases at a similarity level you control and get matching fragments side by side, even after renaming and reformatting.
Use caseM&A code due diligence
What clone data does for youDuplication rate per subsystem is a maintenance liability you can price before you sign. Cross-comparison flags code shared with codebases you supply.
Use caseProduct-line consolidation
What clone data does for youForked customer variants become one core plus parameters. Salion, whose product line the SEI documented in a published case study, used CloneDR to cut 27,000 lines.
Clone removal

Detection is half the job. We do the other half.

Most clone tools stop at a report and leave the refactoring to your backlog. Our clone removal service turns clone sets into shared code, to your specification, without changing what the system does.

Agree the spec

Together we choose which clone sets go, the minimum size worth removing, the target form (function, method, copybook or macro), naming, and where shared code lives.

Abstract

Each covering abstraction becomes one shared routine. Its parameter slots become arguments, named and typed to your standards.

Rewrite call sites

Each copy becomes a call that passes its own values. DMS resolves names and types before changing a line and regenerates source with comments and layout intact. Clone sets too irregular for a rule are refactored by our engineers, guided by the skeleton.

Verify

Every change compiles and passes your test suite. Our test coverage tools show the tests actually exercise the refactored code, and a structural diff keeps review fast.

Engagement shapes

Start with a number. Finish with less code.

  1. 1

    Clone audit report

    Cloned-code percentage by subsystem, the largest clone sets with their skeletons, and a removal estimate. A fast way to size a migration or a cleanup.

  2. 2

    Clone removal campaign

    We remove the agreed clone sets to your spec, verified by your tests. Fixed price after assessment. Often part of a wider code refactoring program.

  3. 3

    Plagiarism and provenance scan

    Two or more codebases, a similarity threshold, and an evidence report your counsel can read. Under NDA, on your premises if required.

  4. 4

    CloneDR for your team

    Licensed CloneDR on your own servers, run on a schedule or per release so the clone rate stops climbing. Configured for your languages and thresholds.

Related services

Fix it once. Have it fixed everywhere.

Get a clone report on your own code before you migrate, merge or maintain another line of it.

Book A Free Clone Assessment
FAQ

The questions our engineers get asked the most

General questions

Clone detection finds code that was copied and then kept, edited or renamed, anywhere in your system. Clone removal replaces each set of copies with one shared function, method, copybook or macro and updates every call site. We detect with CloneDR, Semantic Designs' AST-based detector, and remove with DMS rewrite rules plus engineer-led refactoring, all to your specification and verified by your tests.

Those tools compare lines or token sequences. They catch exact copies well, but an inserted statement or a renamed variable can break the match, and boilerplate inflates the count. CloneDR parses code with a compiler-grade front end, matches syntax trees and turns differences into parameters. Near-miss clones are found, each clone is a unit you can actually extract, and you get the covering abstraction needed for removal.

Type 1 exact clones, Type 2 renamed or parameterized clones, and Type 3 near-miss clones with statements added, changed or removed, within a difference threshold you set. It finds them in procedural code and in data declarations. It does not claim Type 4 semantic clones, where the same computation is written in different syntax. We would rather give you a precise report than a long one.

CloneDR handles thousands of files and millions of lines and uses every processor on your server. A large global bank had 10M+ lines of Java and C# analyzed for plagiarism in two weeks. Evaluation versions exist for Java, C#, C++, COBOL, JavaScript and PHP. Because CloneDR is built on DMS, which parses 40+ languages, we can build one for almost any language, legacy dialects included.

It supplies the technical evidence. CloneDR compares codebases and reports matching fragments side by side at a similarity level you control, even after renaming and reformatting. Whether a match is infringement is a legal question for your counsel. For due diligence, duplication rates show maintenance liability. We compare the code you supply; we don't maintain an open-source fingerprint database, so pair us with a software composition analysis scan for license compliance.

We agree the rules first: which clone sets, what form the shared code takes, and naming. DMS resolves names and types before it changes a line, rewrites each copy into a call and regenerates source with comments intact. Every change compiles and passes your tests, and our coverage tools confirm the tests exercise the refactored code. Irregular clone sets are refactored by our engineers, guided by the detected skeleton.

No. Detection runs on a snapshot and never touches your repository. Removal lands in batches, one subsystem or clone set at a time, so each change arrives as a normal reviewable merge. Because DMS transformations are deterministic, we rerun them on your latest code instead of freezing the codebase while we work.

A supporting one. Clone detection and call-site rewriting are deterministic symbolic AI: same input, same output, every time. Gen AI helps around that core, drafting documentation for new shared routines, summarizing clone sets for reviewers and generating test cases. It never decides what counts as a clone or what code changes. Here is why.

Yes. CloneDR and DMS run on your own servers, including air-gapped networks, and every engagement starts under NDA. Your source never has to leave your site. You own the refactored code, the reports and the clone data. If you license CloneDR for your team, there are no runtime royalties on anything it helps you produce.

Send us rough line counts, languages and what you want from the scan: a clone rate, a plagiarism answer, or less code. We start with a free codebase assessment under NDA and return complexity and duplication findings, an automation estimate and a rough timeline in about five business days. Fixed price follows the assessment. Contact us to begin.