What counts as a duplicate
Iris Code splits code into tokens, the smallest meaningful pieces such as a name, a bracket or a keyword. A match must be at leastduplicateBlockMinTokens of these tokens long, 40 by default. Matching stretches that run on from each other are joined into one block, so a long copy is reported once rather than as several overlapping pieces.
The other rules keep the results short enough to review:
- Import lines never match. Two files that load the same components are not a problem worth fixing, and reporting them would bury the real findings.
- Repetitive data never matches. Lists such as country names or lookup tables look alike by nature.
- Repeats are reported sparingly. A block that appears eight times is reported as the smallest set of pairs that covers every copy, not all 28 possible pairs. A match that sits entirely inside a bigger match is dropped.
- Markup needs a longer match. In
.jsxand.tsxfiles, or.jsfiles containing JSX, the token minimum doubles, because markup is repetitive by design. - Very large or minified-looking files are left out of the comparison. Iris Code tells you which files were left out rather than skipping them silently.
Where you’ll see it
File tab: duplicates within the file appear as a “Duplicate blocks” smell, with both locations. Each block takeshealthScoreWeights.duplicateCode points off the health score, 3 by default.
Workspace and Folder tabs: a Duplication section shows the number of blocks, the percentage of code lines that are duplicated and the largest blocks. Click either location to open it.
The Duplicates table, opened with “See all”, lists every block. You can filter by cross-file or within-file, search, and click either location. It follows your edits as you type: line ranges update, and a pair that is no longer duplicated drops out without a new scan.
The diff view (Pro)
A diff view shows two pieces of code side by side with their differences highlighted. Every row in the table has Open diff, titled with both locations the way GitHub would show them:scanner.ts:10-24 ↔ parser.ts:88-102.
Pairs in two different files open both real files side by side, scrolled to the matching blocks. You are editing the actual files with their full context, and they save normally. Iris Code shows a notification once the duplication is gone.
Pairs in the same file would show nothing useful compared with itself, so they open as two editable extracts instead. Saving a pane writes the change back into the real file, an Open link jumps to the full file, and the panes update as the file changes.
Gating on duplication (Pro)
A gate is the check that can fail a push or build when your code goes over a limit you have set.gateMaxDuplicateBlocks sets the most duplicate blocks allowed across the whole scan. It is applied by iris check, iris gate, the pre-push hook and the build hook. A block spanning two files counts once.
.irisconfig.json
iris gate shows a “Max duplicate blocks” rule row and, when the limit is exceeded, lists the files involved.
Configuration
See the .irisconfig.json reference for every setting.
Suppressing a finding
To accept one duplicate on purpose, add aniris-ignore comment above it. duplicate-code is the rule id, and a reason is required:
In the CLI
The CLI is the set of Iris Code commands you type in a terminal.iris check --format json adds a duplicateBlocks list to each file entry, and iris gate reports any files that were left out of the comparison.