Skip to content

fix(httproutes-generator): report test coverage to Sonar - #216

Merged
alsergs merged 1 commit into
fix/istio-regex-routesfrom
fix/httproutes-plugin-sonar-coverage
Oct 7, 2026
Merged

alsergs merged 1 commit into
fix/istio-regex-routesfrom
fix/httproutes-plugin-sonar-coverage

Conversation

@alsergs

@alsergs alsergs commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Why

The Sonar quality gate on #212 fails with 0.0% coverage on new code and a C reliability rating. The tests run and pass, but httproutes-generator-maven-plugin has no parent POM and never configured JaCoCo. Sonar gets no coverage report for the module and counts all 414 new lines as uncovered.

The reliability rating comes from one java:S2259 issue at RouteScanner.java:189. hierarchy() checked its argument for null, so Sonar treated every caller's ClassInfo as nullable. Callers never pass null; only getSuperclass() can return it.

What

  • Add jacoco-maven-plugin 0.8.15 (the version other modules use) with prepare-agent and a report execution in verify. The report lands in target/site/jacoco/jacoco.xml, the path the Sonar scanner reads by default.
  • In RouteScanner.hierarchy(), handle the missing superclass with Stream.ofNullable(classInfo.getSuperclass()) and drop the null check on the argument.

How to verify

  • mvn verify in core-maven-plugins/httproutes-generator-maven-plugin writes target/site/jacoco/jacoco.xml.
  • The SonarCloud check on this PR reports non-zero coverage on new code and no java:S2259 issue.

Base branch is fix/istio-regex-routes; merge this into #212.

🤖 Generated with Claude Code

The plugin module has no parent POM and never ran JaCoCo, so Sonar got
no coverage report for it and counted every new line as uncovered.
Add the prepare-agent and report goals so verify writes
target/site/jacoco/jacoco.xml, which the Sonar scanner picks up by
default.

Also resolve java:S2259 in RouteScanner: hierarchy() checked its
argument for null, which made Sonar treat every caller's ClassInfo as
nullable. Handle the missing superclass at the call site instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alsergs
alsergs requested a review from lis0x90 as a code owner October 7, 2026 14:11
@sonarqubecloud

sonarqubecloud Bot commented Oct 7, 2026

Copy link
Copy Markdown

@alsergs
alsergs merged commit b7dd0d2 into fix/istio-regex-routes Oct 7, 2026
6 checks passed
@alsergs
alsergs deleted the fix/httproutes-plugin-sonar-coverage branch October 7, 2026 23:59
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