Skip to content

build(sonar): tune quality gate for false positives and fix genuine findings#55

Closed
wolpert wants to merge 1 commit into
mainfrom
fix/sonar-quality-gate-tuning
Closed

build(sonar): tune quality gate for false positives and fix genuine findings#55
wolpert wants to merge 1 commit into
mainfrom
fix/sonar-quality-gate-tuning

Conversation

@wolpert

@wolpert wolpert commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What

Tunes the SonarCloud quality gate that went red on the first analysis, and fixes the genuine findings behind it.

The red gate was an onboarding artifact, not a regression. Overall code health already passes every threshold (coverage 88.3%, duplication 2.3%); the gate only failed on new_* conditions, where the first analysis scored a non-representative slice of the backlog against strict Clean-as-You-Code thresholds. All 407 issues were triaged; the headline counts were dominated by rules that conflict with this project's conventions, not by defects.

Changes

Config (build.gradle.kts, documented in ADR 0017):

  • Suppress java:S4449 project-wide — it demands JSR-305 javax.annotation.Nullable; we standardize on JSpecify, enforced by Error Prone (CONTRIBUTING.md §7).
  • Suppress java:S2699 on **/*Test.java — the persistence/in-memory suites delegate assertions to shared testkit *Scenarios classes so one suite runs against every backend; the rule can't see across the call. Test effectiveness is already gated by JaCoCo floors + mutation testing.
  • Exclude DynamoDB *Item beans and module-info.java from coverage — mandatory SDK-driven POJOs / no executable statements.

Genuine code fixes:

  • Annotate Micronaut admin controller @Body params @Nullable, matching the Spring adapter. Micronaut can inject a null body, so the existing body == null guards are correct — this clears the S2583/S2589 "dead condition" cluster the right way instead of deleting the guards.
  • CeremonyScenarios: Optional.orElseThrow() instead of get() (S3655).

Deliberately not done (would be number-chasing)

Defensive jti == null guards, Spring getPrincipal() (returns a non-null final field), and DynamoDB bean pk fields are false positives on correct/structural code — left as-is.

Verification

spotlessCheck, module compilation, and the Micronaut admin controller tests all pass.

🤖 Generated with Claude Code

…indings

The first SonarCloud analysis flagged the full backlog against new-code
thresholds. Overall health already passes (~88% coverage, ~2% duplication);
the noise came from rules that conflict with the project's conventions plus a
couple of real findings. Triaged all 407 issues and addressed the legitimate
ones without deleting correct defensive code.

Config (version-controlled, rationale in docs/adr/0017):
- Suppress java:S4449 project-wide (demands JSR-305 javax.annotation.Nullable;
  we standardize on JSpecify, enforced by Error Prone).
- Suppress java:S2699 on **/*Test.java (persistence/in-memory suites delegate
  assertions to shared testkit *Scenarios classes; gated by JaCoCo + mutation).
- Exclude DynamoDB *Item beans and module-info.java from coverage (structural
  SDK-driven POJOs / no executable statements).

Genuine fixes:
- Annotate Micronaut admin controller @Body params @nullable, matching the
  Spring adapter, so the existing null-guards are no longer flagged as dead
  code (java:S2583/S2589) — the framework can inject a null body.
- CeremonyScenarios: Optional.orElseThrow() instead of get() (java:S3655).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@wolpert

wolpert commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by the SonarQube removal — see new PR. We're dropping SonarQube entirely and enforcing line+branch coverage natively via JaCoCo instead of suppressing false positives.

@wolpert wolpert closed this Jun 12, 2026
@wolpert
wolpert deleted the fix/sonar-quality-gate-tuning branch June 27, 2026 18:56
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.

1 participant