Skip to content

Commit df381cb

Browse files
committed
feat(enrichment): add near-verbatim duplication scan analyzer for review briefs
1 parent 752381d commit df381cb

9 files changed

Lines changed: 974 additions & 3 deletions

File tree

.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ GITTENSORY_REVIEW_ENRICHMENT=false
6565
# Current analyzer names:
6666
# dependency,lockfileDrift,secret,license,installScript,heavyDependency,actionPin,eol,redos
6767
# provenance,codeowners,secretLog,assetWeight,typosquat,commitSignature,iacMisconfig,nativeBuild
68-
# history,docCommentDrift
68+
# history,docCommentDrift,duplication
6969
#
7070
# Profile defaults:
7171
# fast: dependency,lockfileDrift,secret,license,installScript,heavyDependency,actionPin,eol
7272
# redos,provenance,secretLog,typosquat,iacMisconfig,nativeBuild
7373
# balanced (default): dependency,lockfileDrift,secret,license,installScript,heavyDependency
7474
# actionPin,eol,redos,provenance,codeowners,secretLog,assetWeight,typosquat,commitSignature
75-
# iacMisconfig,nativeBuild,history,docCommentDrift
75+
# iacMisconfig,nativeBuild,history,docCommentDrift,duplication
7676
# deep: dependency,lockfileDrift,secret,license,installScript,heavyDependency,actionPin,eol
7777
# redos,provenance,codeowners,secretLog,assetWeight,typosquat,commitSignature,iacMisconfig
78-
# nativeBuild,history,docCommentDrift
78+
# nativeBuild,history,docCommentDrift,duplication
7979
# END GENERATED REES ANALYZERS
8080

8181
# Submitter-reputation spend control (internal-only): downgrades new/burst/low-rep

apps/gittensory-ui/src/lib/rees-analyzers.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,34 @@ export const REES_ANALYZERS = [
505505
"Conservative: only named function declarations with confidently-enumerable params; non-parameter signature edits are not reported.",
506506
},
507507
},
508+
{
509+
name: "duplication",
510+
title: "Near-verbatim duplicated code",
511+
category: "quality",
512+
cost: "github-light",
513+
defaultEnabled: true,
514+
profiles: ["balanced", "deep"],
515+
requires: ["files", "github-token", "head-sha"],
516+
limits: {
517+
minRun: 8,
518+
maxCandidates: 40,
519+
maxFetches: 30,
520+
maxFindings: 25,
521+
maxFileBytes: 500000,
522+
},
523+
docs: {
524+
summary:
525+
"Flags added code that is a near-verbatim duplicate of a block already present elsewhere in the repo.",
526+
looksAt:
527+
"Added diff hunks in changed source files compared against same-extension repo files fetched from the git tree at headSha.",
528+
reports:
529+
"The head file:line, the existing source file:line it duplicates, and the matched line count.",
530+
network:
531+
"Calls the GitHub API for the git tree and candidate blobs. Requires headSha and token forwarding for private repos.",
532+
notes:
533+
"Conservative: trivial/boilerplate lines are dropped and a long contiguous run is required, so incidental overlap is not flagged. Never returns code content.",
534+
},
535+
},
508536
] as const satisfies readonly ReesAnalyzerDoc[];
509537

510538
export const REES_ANALYZER_NAMES = REES_ANALYZERS.map((analyzer) => analyzer.name);

review-enrichment/analyzer-metadata.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,36 @@
579579
"network": "Calls the GitHub API for changed file contents. Requires headSha and token forwarding for private repos.",
580580
"notes": "Conservative: only named function declarations with confidently-enumerable params; non-parameter signature edits are not reported."
581581
}
582+
},
583+
{
584+
"name": "duplication",
585+
"title": "Near-verbatim duplicated code",
586+
"category": "quality",
587+
"cost": "github-light",
588+
"defaultEnabled": true,
589+
"profiles": [
590+
"balanced",
591+
"deep"
592+
],
593+
"requires": [
594+
"files",
595+
"github-token",
596+
"head-sha"
597+
],
598+
"limits": {
599+
"minRun": 8,
600+
"maxCandidates": 40,
601+
"maxFetches": 30,
602+
"maxFindings": 25,
603+
"maxFileBytes": 500000
604+
},
605+
"docs": {
606+
"summary": "Flags added code that is a near-verbatim duplicate of a block already present elsewhere in the repo.",
607+
"looksAt": "Added diff hunks in changed source files compared against same-extension repo files fetched from the git tree at headSha.",
608+
"reports": "The head file:line, the existing source file:line it duplicates, and the matched line count.",
609+
"network": "Calls the GitHub API for the git tree and candidate blobs. Requires headSha and token forwarding for private repos.",
610+
"notes": "Conservative: trivial/boilerplate lines are dropped and a long contiguous run is required, so incidental overlap is not flagged. Never returns code content."
611+
}
582612
}
583613
]
584614
}

0 commit comments

Comments
 (0)