Skip to content

Commit dd2c0e1

Browse files
committed
fix: eliminate duplicate vulnerability annotations in CAAnnotator
Create single annotation per element instead of one per vulnerability source to avoid showing duplicate messages for the same dependency
1 parent f74d0fd commit dd2c0e1

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/main/java/org/jboss/tools/intellij/componentanalysis/CAAnnotator.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,23 +170,24 @@ public void apply(@NotNull PsiFile file, Map<Dependency, Result> annotationResul
170170
elements.forEach(e -> {
171171
if (e != null) {
172172
if (!quickfixes.isEmpty() && this.isQuickFixApplicable(e)) {
173-
quickfixes.forEach((source, report) ->{
174-
AnnotationBuilder builder = holder
175-
.newAnnotation(getHighlightSeverity(report, e), messageBuilder.toString())
176-
.tooltip(tooltipBuilder.toString())
177-
.range(e);
173+
DependencyReport firstReport = quickfixes.values().iterator().next();
174+
AnnotationBuilder builder = holder
175+
.newAnnotation(getHighlightSeverity(firstReport, e), messageBuilder.toString())
176+
.tooltip(tooltipBuilder.toString())
177+
.range(e);
178+
179+
quickfixes.forEach((source, report) -> {
178180
if(CAIntentionAction.isQuickFixAvailable(report)) {
179-
CAUpdateManifestIntentionAction patchManifest = this.patchManifest(file, report);
180181
builder.withFix(this.createQuickFix(e, source, report));
182+
CAUpdateManifestIntentionAction patchManifest = this.patchManifest(file, report);
181183
if(Objects.nonNull(patchManifest)) {
182184
builder.withFix(patchManifest);
183185
}
184186
}
185-
builder.withFix(new SAIntentionAction());
186-
builder.withFix(new ExcludeManifestIntentionAction());
187-
builder.create();
188-
}
189-
);
187+
});
188+
builder.withFix(new SAIntentionAction());
189+
builder.withFix(new ExcludeManifestIntentionAction());
190+
builder.create();
190191
}
191192
}
192193
});

0 commit comments

Comments
 (0)