Skip to content

ci: consolidate pmd, checkstyle, spotbugs into one static-analysis job#1333

Draft
joaodinissf wants to merge 1 commit into
dsldevkit:masterfrom
joaodinissf:ci/consolidate-static-analysis
Draft

ci: consolidate pmd, checkstyle, spotbugs into one static-analysis job#1333
joaodinissf wants to merge 1 commit into
dsldevkit:masterfrom
joaodinissf:ci/consolidate-static-analysis

Conversation

@joaodinissf
Copy link
Copy Markdown
Collaborator

@joaodinissf joaodinissf commented May 6, 2026

Replaces the separate pmd and checkstyle jobs with a single static-analysis job:

  1. Compile + generate reports (mvn compile pmd:pmd pmd:cpd checkstyle:checkstyle) — no *:check goals, so no Maven cascade-skip; every module's XML is produced.
  2. Annotate + count (Python) — parses every report, emits one inline PR annotation per violation, exits 1 if any. Fail-fast trigger that bypasses SpotBugs (slow) when there are PMD/Checkstyle issues.
  3. Maven pmd:check pmd:cpd-check checkstyle:check safety-net — official-tool validation; redundant in the success case.
  4. Generate SpotBugs report — only runs if step 3 passed.
  5. Annotate + count SpotBugs (Python) — same pattern.
  6. Maven spotbugs:check safety-net.

Drops the now-redundant pmd/checkstyle/spotbugs goals from maven-verify (now just mvn clean verify). line-endings stays separate. Uses -T 2C (8 worker threads on a 4 vCPU runner; benchmark on this branch showed ~25% wall-clock saving over sequential).

Why every analysis step prepends compile

pmd:check, pmd:pmd, spotbugs:spotbugs, and spotbugs:check all need an aux-classpath populated by Tycho's compile phase. That state is in-process — even though target/classes/ exists from a previous step, a fresh mvn invocation doesn't pick it up. Running the analysis goal in the same invocation as compile makes type-resolving rules (like PMD's InvalidLogMessageFormat against the SLF4J trailing-Throwable idiom) work correctly. Tycho's incremental compile is near no-op on the second invocation since sources haven't changed between steps.

Cascade-skip when checks fail

With --fail-at-end, when pmd:check fails on a module, downstream modules are SKIPPED and their violations don't appear in the log either. The Python step (which parses the XML written in step 1's no-fail report run) covers everything; the Maven safety-net only sees modules that ran before any cascade-skip. In practice both layers together surface most violations on the first iteration; edge cases on cascade-skipped modules become visible after the first failing module is fixed.

@joaodinissf joaodinissf force-pushed the ci/consolidate-static-analysis branch 10 times, most recently from 2c90e30 to bf47363 Compare May 6, 2026 22:56
@joaodinissf joaodinissf marked this pull request as ready for review May 6, 2026 23:20
@joaodinissf joaodinissf force-pushed the ci/consolidate-static-analysis branch from bf47363 to 7e69ddb Compare May 6, 2026 23:20
Copy link
Copy Markdown
Member

@rubenporras rubenporras left a comment

Choose a reason for hiding this comment

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

is it possible to not repeat the python script?

…b with inline PR annotations

Replaces the separate pmd and checkstyle jobs with a single static-analysis job. Step 1 compiles and generates PMD/Checkstyle reports (no *:check goals → no Maven cascade-skip; every module's XML is produced). Step 2 is a Python pass that emits GitHub workflow-command annotations from each violation and exits 1 if any are found — fail-fast that bypasses SpotBugs (slow) when there are PMD/Checkstyle issues. Step 3 re-runs Maven `pmd:check pmd:cpd-check checkstyle:check` as a safety-net for official-tool validation. Steps 4-6 mirror the same pattern for SpotBugs (only run if PMD/Checkstyle are clean). Drops the now-redundant pmd/checkstyle/spotbugs goals from maven-verify (now just `mvn clean verify`). line-endings stays separate. Uses `-T 2C` (8 worker threads on a 4 vCPU runner; benchmark on this branch showed ~25% wall-clock saving over sequential).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joaodinissf
Copy link
Copy Markdown
Collaborator Author

is it possible to not repeat the python script?

I will refactor. Still want to try a few more variations before merging, I have a few ideas to optimize this further.

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.

2 participants