chore: enable CPD detection (pmd.cpd.min → 100), de-dup and baseline#1397
Draft
joaodinissf wants to merge 2 commits into
Draft
chore: enable CPD detection (pmd.cpd.min → 100), de-dup and baseline#1397joaodinissf wants to merge 2 commits into
joaodinissf wants to merge 2 commits into
Conversation
Replace the pmd/checkstyle jobs with a parallel shape that gives early,
inline feedback and stops re-running analysis inside the build:
- lint: compile + pmd:pmd + checkstyle:checkstyle (SARIF) + pmd:cpd-check,
-T 2C, --fail-never; gates by counting the merged SARIF (+ cpd.xml grep).
Fails in ~3-5 min on its own check, independent of the build.
- spotbugs: compile + spotbugs:spotbugs (SARIF), -Xmx4g, own parallel lane
(the slow analysis).
- maven-verify: build + tests only; the redundant checkstyle/pmd/spotbugs
goals are dropped (now owned by lint/spotbugs).
- line-endings: unchanged.
All three emit SARIF 2.1.0, merged per tool and uploaded to Code Scanning
(security-events: write) for inline annotations on the PR diff + Security tab.
No custom Python annotator.
Count-gate rather than the *:check goals: the check goals @Execute-fork a
second analysis and cannot emit SARIF, and without the full compile classpath
they false-positive on type-resolving rules. Each report goal runs once
(full-reactor compile -> correct + SARIF) and the gate counts the result.
Rationale + tables in docs/ci-static-analysis-design.md; measurement protocol
in docs/ci-measurement-protocol.md.
CPD gating is wired but inert until dsldevkit#1339 lowers the token threshold.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5f1c381 to
d45faf3
Compare
…aseline pmd.cpd.min was 100000, which effectively disabled PMD's copy/paste detector (dsldevkit#1339). Lower it to PMD's default of 100 so CPD catches duplication going forward. At threshold 100 the reactor surfaces 9 pre-existing duplications (5 groups). Two are genuinely extractable logic and are refactored away; the other three are incidental or deliberately explicit and are baselined with // CPD-OFF markers that each carry a per-site reason. Refactored: - check.ui ExtensionHelper guard chain: the identical isExtensionUpdateRequired body in CheckValidatorExtensionHelper and CheckQuickfixExtensionHelper is extracted to a shared isTargetClassExtensionUpdateRequired method on AbstractCheckExtensionHelper (keyed on the existing getExtensionPointId() and a new protected getTargetClassName() hook); the two helpers now delegate to it. The base isExtensionUpdateRequired keeps its coarse extension-point check, which the documentation helpers rely on via super; that subtree has no target class, so it declares the getTargetClassName hook unsupported once in its shared parent (AbstractCheckDocumentationExtensionHelper). - xtext fingerprint featureIterable: the identical private helper in AbstractFingerprintComputer and AbstractStreamingFingerprintComputer is extracted to a shared package-private FingerprintFeatures utility. Baselined (CPD-OFF, with reason): - DispatchingCheckImpl: incidental token overlap (DI field + trace/try idiom), not an extractable unit. - ParameterListMatcherTest: explicit parameterized test cases, kept readable. - AbstractValidationTest: test scaffolding; per-test clarity beats extraction. Verified: check.ui and xtext compile; pmd:cpd-check is clean across the full reactor at threshold 100. Closes dsldevkit#1339 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
d45faf3 to
b4bfa9d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1339.
Note
Stacked on #1396. The first commit (
ci: fast static analysis…) belongs to #1396 and will drop out once that merges; review only the second commit here (chore: enable CPD…). I'll rebase to a clean single commit after #1396 lands.Problem
ddk-parent/pom.xmlsetpmd.cpd.min=100000, which effectively disables PMD's copy/paste detector —pmd:cpd-checkpasses on virtually any duplication (#1339).What this does
pmd.cpd.minto 100 (PMD's default), so CPD actually detects duplication going forward — and thelintjob's CPD gate (from ci: fast static analysis with early-fail lint + inline SARIF (PMD/Checkstyle/SpotBugs) #1396) becomes meaningful.// CPD-OFFmarkers carrying a per-site reason — incidental token overlap, or deliberately-explicit code where sharing would hurt readability.check.uiandxtextcompile, andpmd:cpd-checkis clean across the full reactor at threshold 100 (0 duplications).The 9 duplications — disposition
AbstractValidationTest(test core)ParameterListMatcherTest(typesystem test)testForceMatchByPosition*cases share an arrange-act-assert skeleton, kept explicit for readability.Check{Validator,Quickfix}ExtensionHelper(prod UI)isExtensionUpdateRequiredguard chain lifted toAbstractCheckExtensionHelper, keyed on the existinggetExtensionPointId()plus a newprotected getTargetClassName()hook. The documentation-helper subtree (no target class) declares that hook unsupported once in its shared parent.DispatchingCheckImpl(prod runtime)Abstract{,Streaming}FingerprintComputer(prod)featureIterablehelper extracted to a shared package-privateFingerprintFeaturesutility.Notes
cpd.xml→SARIF transform for inline CPD is a possible follow-up.lint/spotbugsrename is ci: fast static analysis with early-fail lint + inline SARIF (PMD/Checkstyle/SpotBugs) #1396's).🤖 Generated with Claude Code