Skip to content

fix(sonar): drive open findings to zero and document gate policy#89

Merged
OliverWolffGIP merged 7 commits into
mainfrom
feature/sonar-zero-findings
Jul 21, 2026
Merged

fix(sonar): drive open findings to zero and document gate policy#89
OliverWolffGIP merged 7 commits into
mainfrom
feature/sonar-zero-findings

Conversation

@OliverWolffGIP

Copy link
Copy Markdown
Collaborator

Summary

Drives the API Sheriff codebase toward zero open SonarCloud findings and documents the zero-findings compliance policy. Fixes the two gate-failing java:S3655 unguarded-Optional bugs first (RouteTableBuilder, RouteRuntimeAssembler), investigates and remediates the four flagged care-item findings, extracts duplicated string literals to constants, applies a mechanical Java-25 modernization sweep across api-sheriff, and adds contributor-facing documentation of the SonarCloud compliance policy.

Changes

  • Bug fixes (java:S3655 unguarded-Optional): api-sheriff/src/main/java/de/cuioss/sheriff/api/config/RouteTableBuilder.java, api-sheriff/src/main/java/de/cuioss/sheriff/api/edge/RouteRuntimeAssembler.java, with matching empty-Optional regression tests in RouteTableBuilderTest.java and RouteRuntimeAssemblerTest.java.
  • Care-item investigation/remediation: api-sheriff/src/main/java/de/cuioss/sheriff/api/edge/DispatchStage.java and DispatchStageTest.java.
  • Duplicated-literal extraction (java:S1192): api-sheriff/src/main/java/de/cuioss/sheriff/api/config/validation/ConfigValidator.java, api-sheriff/src/main/java/de/cuioss/sheriff/api/auth/TokenValidatorProducer.java.
  • Mechanical Java-25 modernization sweep across api-sheriff/src/main/java/de/cuioss/sheriff/api/ (asset, config, edge, forward packages) and matching test files: AssetSource.java, DirectoryAssetSource.java, PathConfinement.java, UpstreamAssetSource.java (+ UpstreamAssetSourceTest.java), EnvSecretResolver.java (+ ConfigLoaderTest.java), GatewayEdgeRoute.java, ForwardPolicyStage.java, TcpPeerGate.java (+ TcpPeerGateTest.java), GatewayEventCounterTest.java.
  • Documentation: new contributor page doc/development/sonar-quality-gate.adoc (with doc/development/README.adoc index update) documenting the org-owned SonarCloud gate as authoritative and blocking, zero-new-findings policy, never-merge-over-red-or-stale-green rule, PR-new-code-vs-project-analysis auditability nuance, and fix-by-default / suppress-with-rationale rule; new "Sonar / Quality Gate" section in CLAUDE.md referencing the org gate and the new page.
  • Operator addendum: README.adoc benchmark badge link fixes and WRK→k6 prose update.

Test Plan

  • Verification command passed (python3 .plan/execute-script.py plan-marshall:build-maven:maven run --command-args "verify -Ppre-commit")
  • Verification command passed (python3 .plan/execute-script.py plan-marshall:build-maven:maven run --command-args "verify")
  • Post-push SonarCloud new-code gate green
  • Manual testing completed (if applicable)

Related Issues

None.


Generated by plan-finalize skill

OliverWolffGIP and others added 6 commits July 21, 2026 16:50
Hoist route.asset() into a single local Optional in RouteTableBuilder and
RouteRuntimeAssembler so the isPresent() guard and the value access
(asset.get()) are driven from the same reference, clearing both gate-failing
java:S3655 unguarded-Optional findings. Behavior is preserved (asset XOR
upstream terminal action, ADR-0014). Adds empty-Optional regression tests
asserting the no-asset proxy path resolves without throwing.

Co-Authored-By: Claude <noreply@anthropic.com>
Resolve the four investigate-first care items:
- java:S2589 (DispatchStage.upstreamRequestUri): drop the always-false
  `rawQuery == null` sub-expression (rawQuery is non-null under @NullMarked)
  and add an explicit Objects.requireNonNull boundary check.
- java:S112 (DispatchStage.awaitDispatch): replace the generic `throws
  Exception` with the specific `throws InterruptedException, ExecutionException`
  actually raised by CompletableFuture#get; the in-class Callable caller is
  unaffected.
- java:S3776 (ConfigValidator.validateAnchorNamespaceMembership): extract the
  rule-3 and rule-4 membership checks into named private helpers, preserving
  exact ADR-0007 semantics (squatter/undeclared-anchor boot failures unchanged).
- java:S125 (DispatchStageTest): the flagged block is legitimate explanatory
  prose about the ExecutionException-wrapping contract, not commented-out code
  (false positive) — apply an auditable NOSONAR java:S125 suppression.

Co-Authored-By: Claude <noreply@anthropic.com>
…192)

- ConfigValidator: use the existing REQUIRE_BEARER / REQUIRE_SESSION constants
  in the effective-auth requires.contains(...) checks instead of raw literals.
- TokenValidatorProducer: extract the four-times-repeated "Issuer '" error-
  message prefix into a private static final ISSUER_PREFIX constant.

Literal values are unchanged — a behavior-neutral refactor; no test assertion
changes value and existing tests pass unmodified.

Co-Authored-By: Claude <noreply@anthropic.com>
…7467/S6353/S4276/S6878)

Behavior-preserving mechanical sweep clearing the D4 SonarCloud findings:
- S5778 x21: hoist multi-invocation setup out of assertThrows lambdas so each wraps a single throwing call (ConfigLoaderTest, RouteRuntimeAssemblerTest, TcpPeerGateTest, RouteTableBuilderTest)
- S7467 x14: unnamed variable pattern (_) for unused catch parameters (7) and unused lambda parameters (7)
- S6353: concise \w regex token in EnvSecretResolver placeholder patterns
- S4276: UnaryOperator<String> for the Function<String,String> header lookup in ForwardPolicyStage
- S6878: record deconstruction patterns in Served/Fetched equals()

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add the contributor SonarCloud compliance page and a reference-first CLAUDE.md section:
- doc/development/sonar-quality-gate.adoc: authoritative/blocking gate, zero new findings, never-merge-over-red-or-stale-green, PR-new-code vs post-merge project-gate auditability, fix-by-default / suppress-with-rationale; references org thresholds without restating them
- doc/development/README.adoc: index row linking the new page
- CLAUDE.md: concise Sonar / Quality Gate section linking the full policy

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Correct the two integration-benchmark badge link targets to the operator-verified live paths (benchmarks/integration/index.html, benchmarks/integration/trends.html) and align the Performance Benchmarking prose with the k6 migration from PR #82.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @OliverWolffGIP, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@OliverWolffGIP, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository: cuioss/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3626e456-44bf-4751-8956-ff91cfc2259c

📥 Commits

Reviewing files that changed from the base of the PR and between d1545a3 and 0eac4da.

📒 Files selected for processing (26)
  • .plan/project-architecture/api-sheriff-parent/enriched.json
  • .plan/project-architecture/api-sheriff/enriched.json
  • CLAUDE.md
  • README.adoc
  • api-sheriff/src/main/java/de/cuioss/sheriff/api/asset/AssetSource.java
  • api-sheriff/src/main/java/de/cuioss/sheriff/api/asset/DirectoryAssetSource.java
  • api-sheriff/src/main/java/de/cuioss/sheriff/api/asset/PathConfinement.java
  • api-sheriff/src/main/java/de/cuioss/sheriff/api/asset/UpstreamAssetSource.java
  • api-sheriff/src/main/java/de/cuioss/sheriff/api/auth/TokenValidatorProducer.java
  • api-sheriff/src/main/java/de/cuioss/sheriff/api/config/RouteTableBuilder.java
  • api-sheriff/src/main/java/de/cuioss/sheriff/api/config/load/EnvSecretResolver.java
  • api-sheriff/src/main/java/de/cuioss/sheriff/api/config/validation/ConfigValidator.java
  • api-sheriff/src/main/java/de/cuioss/sheriff/api/edge/DispatchStage.java
  • api-sheriff/src/main/java/de/cuioss/sheriff/api/edge/GatewayEdgeRoute.java
  • api-sheriff/src/main/java/de/cuioss/sheriff/api/edge/RouteRuntimeAssembler.java
  • api-sheriff/src/main/java/de/cuioss/sheriff/api/forward/ForwardPolicyStage.java
  • api-sheriff/src/main/java/de/cuioss/sheriff/api/forward/TcpPeerGate.java
  • api-sheriff/src/test/java/de/cuioss/sheriff/api/asset/UpstreamAssetSourceTest.java
  • api-sheriff/src/test/java/de/cuioss/sheriff/api/config/RouteTableBuilderTest.java
  • api-sheriff/src/test/java/de/cuioss/sheriff/api/config/load/ConfigLoaderTest.java
  • api-sheriff/src/test/java/de/cuioss/sheriff/api/edge/DispatchStageTest.java
  • api-sheriff/src/test/java/de/cuioss/sheriff/api/edge/RouteRuntimeAssemblerTest.java
  • api-sheriff/src/test/java/de/cuioss/sheriff/api/events/GatewayEventCounterTest.java
  • api-sheriff/src/test/java/de/cuioss/sheriff/api/forward/TcpPeerGateTest.java
  • doc/development/README.adoc
  • doc/development/sonar-quality-gate.adoc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive SonarCloud Quality Gate compliance policy, documented in a new sonar-quality-gate.adoc file and referenced in CLAUDE.md and README.adoc. Code changes focus on modernization and refactoring, including the adoption of Java 21 unnamed variables (_) and record pattern matching, extracting helper methods in ConfigValidator, refactoring local variables to prevent redundant calls, and improving test coverage for empty-Optional asset branches. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Route two durable project-config facts (Sonar HTTPS credential-config
guardrail, Java-25 unnamed-variable source-level guardrail) into the
project-local architecture-hints store.

Co-Authored-By: Claude <noreply@anthropic.com>
@OliverWolffGIP
OliverWolffGIP enabled auto-merge July 21, 2026 17:26
@OliverWolffGIP
OliverWolffGIP added this pull request to the merge queue Jul 21, 2026
Merged via the queue into main with commit 5265ed6 Jul 21, 2026
23 of 24 checks passed
@OliverWolffGIP
OliverWolffGIP deleted the feature/sonar-zero-findings branch July 21, 2026 17:39
OliverWolffGIP added a commit that referenced this pull request Jul 21, 2026
Align shouldFailBootForSessionAndAssembleProtocolRoutes with the
hoisted-local pattern PR #89 established (and the file's dominant
style) after the rebase conflict resolution kept the plan-side test
semantics.

Co-Authored-By: Claude <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.

1 participant