Skip to content

chore: enable CPD detection (pmd.cpd.min → 100), de-dup and baseline#1397

Merged
joaodinissf merged 1 commit into
dsldevkit:masterfrom
joaodinissf:ci/cpd-min-threshold
Jul 13, 2026
Merged

chore: enable CPD detection (pmd.cpd.min → 100), de-dup and baseline#1397
joaodinissf merged 1 commit into
dsldevkit:masterfrom
joaodinissf:ci/cpd-min-threshold

Conversation

@joaodinissf

@joaodinissf joaodinissf commented May 30, 2026

Copy link
Copy Markdown
Collaborator

Closes #1339.

Problem

ddk-parent/pom.xml set pmd.cpd.min=100000, which effectively disables PMD's copy/paste detector — pmd:cpd-check passes on virtually any duplication (#1339).

What this does

  • Lowers pmd.cpd.min to 100 (PMD's default), so CPD actually detects duplication going forward.
  • At 100 the reactor surfaces pre-existing duplications in 8 file-groups. Each was assessed for whether it is genuinely extractable logic or incidental/deliberate similarity:
    • 2 refactored (C, E) — genuine duplicated logic; behavior-neutral extraction.
    • 6 baselined (A, B, D, F, G, H) with // CPD-OFF markers carrying a per-site reason.
  • Verified: full local gate (clean verify checkstyle:check pmd:pmd pmd:cpd pmd:check pmd:cpd-check spotbugs:check) → BUILD SUCCESS, pmd:cpd-check clean across the full reactor at threshold 100.

Dispositions

Group File(s) Kind Disposition Rationale
A AbstractValidationTest (test core) test scaffolding baseline error-message assembly + assert helpers in a test base; per-test clarity beats a shared extraction that would obscure intent.
B ParameterListMatcherTest (typesystem test) test cases baseline sibling testForceMatchByPosition* cases share an arrange-act-assert skeleton, kept explicit for readability.
C Check{Validator,Quickfix}ExtensionHelper (prod UI) helper pair refactored identical isExtensionUpdateRequired guard chain lifted to AbstractCheckExtensionHelper, keyed on the existing getExtensionPointId() plus a new protected getTargetClassName() hook. The documentation-helper subtree (no target class) declares that hook unsupported once in its shared parent.
D DispatchingCheckImpl (prod runtime) incidental baseline the matched spans are incidental token overlap (DI field declarations + the trace/try/run/catch/finally idiom), not an extractable unit.
E Abstract{,Streaming}FingerprintComputer (prod) helper pair refactored the identical private featureIterable helper extracted to a shared package-private FingerprintFeatures utility.
F FormatJvmModelInferrer (prod, migrated) dispatch/emission baseline (file-scoped) 9 self-duplications across the per-locator emission blocks of freshly-migrated Xtend dispatch code, kept faithful to the migration; de-duplication belongs to the migration readability follow-ups, not this PR.
G FormatFragment2 (prod generator, migrated) stub emission baseline the parallel Xtend- and Java-formatter stub emission runs are deliberately explicit twins.
H CheckCfg{ContentAssist,ConfiguredParameterValidations}Test test scaffolding baseline sibling test classes share @Override setup scaffolding, kept explicit per class.

Notes

Merge chain: #1399 (merged) → #1396#1400#1456#1457#1397 (this PR)

🤖 Generated with Claude Code

@joaodinissf joaodinissf force-pushed the ci/cpd-min-threshold branch from 5f1c381 to d45faf3 Compare May 30, 2026 21:30
@joaodinissf joaodinissf changed the title chore: enable CPD detection (pmd.cpd.min → 100) and baseline existing duplications chore: enable CPD detection (pmd.cpd.min → 100), de-dup and baseline May 30, 2026
@joaodinissf joaodinissf force-pushed the ci/cpd-min-threshold branch from d45faf3 to b4bfa9d Compare May 30, 2026 21:44
@joaodinissf joaodinissf force-pushed the ci/cpd-min-threshold branch from b4bfa9d to 9e73c19 Compare July 7, 2026 15:53
@joaodinissf joaodinissf force-pushed the ci/cpd-min-threshold branch from 9e73c19 to 92e68f5 Compare July 11, 2026 09:16
builder.append("import com.avaloq.tools.ddk.xtext.formatting.ExtendedLineEntry");
builder.newLine();
// CPD-OFF — parallel Xtend/Java formatter-stub emission, kept explicit (#1339)
builder.append("import java.util.List");

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will coalesce these in a follow-up PR.

@joaodinissf joaodinissf marked this pull request as ready for review July 11, 2026 12:54
@joaodinissf joaodinissf requested a review from rubenporras July 11, 2026 12:54
…aseline

pmd.cpd.min=100000 effectively disabled PMD's copy/paste detector: cpd-check
passed on virtually any duplication. Lower the threshold to 100 (PMD's
default) so CPD detects duplication going forward.

At 100 the reactor surfaces pre-existing duplications; each was assessed
for whether it is genuinely extractable logic or incidental/deliberate
similarity:

- Refactored: the identical isExtensionUpdateRequired guard chain in the
  Check validator/quickfix extension helpers lifted to
  AbstractCheckExtensionHelper (keyed on getExtensionPointId() plus a new
  protected getTargetClassName() hook); the identical private
  featureIterable helper in Abstract{,Streaming}FingerprintComputer
  extracted to a shared package-private FingerprintFeatures utility.
- Baselined with per-site CPD-OFF markers and reasons: test scaffolding in
  AbstractValidationTest, sibling test cases in ParameterListMatcherTest,
  incidental token overlap in DispatchingCheckImpl, migrated Xtend
  dispatch/emission code in FormatJvmModelInferrer (file-scoped) and
  FormatFragment2, and sibling test-class scaffolding in the two CheckCfg
  test classes.

The lifted guard chain keeps the overrides' public visibility: the hook is
deliberately public so tests can exercise it directly on injected helpers.

Full-reactor pmd:cpd-check is clean at threshold 100.

Closes dsldevkit#1339.
@joaodinissf joaodinissf merged commit 7199dc5 into dsldevkit:master Jul 13, 2026
4 checks passed
@joaodinissf joaodinissf deleted the ci/cpd-min-threshold branch July 13, 2026 08:16
joaodinissf added a commit that referenced this pull request Jul 13, 2026
Enabling CPD (#1397, pmd.cpd.min 100000->100) and migrating the
AnnotationAware ANTLR generators to Java (#1429) each passed CI in
isolation, but their combination on master surfaced 4 intra-file
duplications in the migrated generators that neither PR's build saw:
CPD was still effectively disabled when #1429's checks ran, and #1397's
baseline predated #1429's Java. The snapshot full scan caught it,
leaving master red at cpd-check.

These are faithfully migrated Xtend generators with parallel
rule-emission structure, baselined with file-scoped CPD-OFF markers
consistent with #1397's treatment of the analogous FormatJvmModelInferrer.

Verified locally: pmd:cpd-check / checkstyle:check / pmd:check all green
on com.avaloq.tools.ddk.xtext.generator.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: pmd.cpd.min set to 100000 effectively disables CPD

2 participants