[MNG-7799] Plugin validation may falsely report there are issues (#1136)

But to show no issue, as locality to be shown is not same as reported
issues.

---

https://issues.apache.org/jira/browse/MNG-7799
This commit is contained in:
Tamas Cservenak 2023-06-01 19:01:11 +02:00
parent 8552ac3fea
commit b430e7d826
1 changed files with 14 additions and 5 deletions

View File

@ -161,12 +161,11 @@ public final class DefaultPluginValidationManager extends AbstractEventSpy imple
return; // we were asked to not report anything OR reporting already happened inline
}
ConcurrentHashMap<String, PluginValidationIssues> issuesMap = pluginIssues(mavenSession.getRepositorySession());
if (!issuesMap.isEmpty()) {
EnumSet<IssueLocality> issueLocalitiesToReport = validationReportLevel == ValidationReportLevel.VERBOSE
? EnumSet.allOf(IssueLocality.class)
: EnumSet.of(IssueLocality.INTERNAL);
EnumSet<IssueLocality> issueLocalitiesToReport = validationReportLevel == ValidationReportLevel.VERBOSE
? EnumSet.allOf(IssueLocality.class)
: EnumSet.of(IssueLocality.INTERNAL);
if (hasAnythingToReport(issuesMap, issueLocalitiesToReport)) {
logger.warn("");
logger.warn("Plugin {} validation issues were detected in following plugin(s)", issueLocalitiesToReport);
logger.warn("");
@ -227,6 +226,16 @@ public final class DefaultPluginValidationManager extends AbstractEventSpy imple
}
}
private boolean hasAnythingToReport(
Map<String, PluginValidationIssues> issuesMap, EnumSet<IssueLocality> issueLocalitiesToReport) {
for (PluginValidationIssues issues : issuesMap.values()) {
if (hasAnythingToReport(issues, issueLocalitiesToReport)) {
return true;
}
}
return false;
}
private boolean hasAnythingToReport(PluginValidationIssues issues, EnumSet<IssueLocality> issueLocalitiesToReport) {
for (IssueLocality issueLocality : issueLocalitiesToReport) {
Set<String> pluginIssues = issues.pluginIssues.get(issueLocality);