From 3d158169a3c8722ef9fcb5ea48a5fb19fd431eb8 Mon Sep 17 00:00:00 2001 From: alsergs Date: Wed, 7 Oct 2026 17:10:49 +0300 Subject: [PATCH] fix(httproutes-generator): report test coverage to Sonar 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 --- .../httproutes-generator-maven-plugin/pom.xml | 19 +++++++++++++++++++ .../routes/gateway/plugin/RouteScanner.java | 5 +---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/core-maven-plugins/httproutes-generator-maven-plugin/pom.xml b/core-maven-plugins/httproutes-generator-maven-plugin/pom.xml index ecfc24ba1..d560d7f72 100644 --- a/core-maven-plugins/httproutes-generator-maven-plugin/pom.xml +++ b/core-maven-plugins/httproutes-generator-maven-plugin/pom.xml @@ -110,6 +110,25 @@ 21 + + org.jacoco + jacoco-maven-plugin + 0.8.15 + + + + prepare-agent + + + + report + verify + + report + + + + diff --git a/core-maven-plugins/httproutes-generator-maven-plugin/src/main/java/com/netcracker/routes/gateway/plugin/RouteScanner.java b/core-maven-plugins/httproutes-generator-maven-plugin/src/main/java/com/netcracker/routes/gateway/plugin/RouteScanner.java index 7a930684f..1c79e1b70 100644 --- a/core-maven-plugins/httproutes-generator-maven-plugin/src/main/java/com/netcracker/routes/gateway/plugin/RouteScanner.java +++ b/core-maven-plugins/httproutes-generator-maven-plugin/src/main/java/com/netcracker/routes/gateway/plugin/RouteScanner.java @@ -388,13 +388,10 @@ private boolean hasOwnRoute(ClassInfo classInfo) { * the order in which Spring's {@code AnnotationUtils.findAnnotation} searches */ private static Stream hierarchy(ClassInfo classInfo) { - if (classInfo == null) { - return Stream.empty(); - } return Stream.of( Stream.of(classInfo), classInfo.getInterfaces().directOnly().stream().flatMap(RouteScanner::hierarchy), - hierarchy(classInfo.getSuperclass()) + Stream.ofNullable(classInfo.getSuperclass()).flatMap(RouteScanner::hierarchy) ).flatMap(Function.identity()); }