gnodet-bot commented on code in PR #30857:
URL: https://github.com/apache/camel/pull/30857#discussion_r4706197694


##########
catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/AuditMojo.java:
##########
@@ -267,7 +275,9 @@ public void execute() throws MojoExecutionException, 
MojoFailureException {
                     "No known vulnerabilities" + ("low".equals(listLevel) ? "" 
: " of " + listLevel + " severity or worse")
                           + " in " + collected.deps().size() + " dependencies 
of " + name + note + more);
         } else {
-            AuditReport.table(listed).forEach(line -> getLog().warn(line));
+            List<String> table = byArtifact
+                    ? AuditReport.artifactTable(CveScan.artifactRows(listed)) 
: AuditReport.table(listed);
+            table.forEach(line -> getLog().warn(line));
             getLog().warn(listed.size() + " vulnerabilities in " + 
CveScan.artifactRows(listed).size() + " of "

Review Comment:
   When `byArtifact=true`, `CveScan.artifactRows(listed)` is called twice on 
the same list — once in the new `artifactTable()` call above (line 279) and 
again here for `.size()`. Both calls perform the same grouping computation.
   
   Extract to a local variable to avoid the redundant work:
   
   ```suggestion
               List<CveArtifact> artifactRows = byArtifact ? 
CveScan.artifactRows(listed) : null;
               List<String> table = byArtifact
                       ? AuditReport.artifactTable(artifactRows) : 
AuditReport.table(listed);
               table.forEach(line -> getLog().warn(line));
               int artifactCount = byArtifact ? artifactRows.size() : 
listed.size();
               getLog().warn(listed.size() + " vulnerabilities in " + 
artifactCount + " of "
   ```
   
   (Alternatively, use a local `artifactRows` only in the `byArtifact` branch 
and keep the existing `listed.size()` check in the summary line, or simply call 
`.size()` on the already-computed `table` if the semantics are equivalent.)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to