-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make architecture report log issues (#83460)
- Loading branch information
1 parent
6ed2f39
commit a490311
Showing
4 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/com/intershop/tool/architecture/report/common/issue/IssueComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.intershop.tool.architecture.report.common.issue; | ||
|
||
import java.util.Comparator; | ||
|
||
public class IssueComparator implements Comparator<Issue> | ||
{ | ||
private static final Comparator<Issue> DELEGATE = Comparator.comparing( | ||
(Issue a) -> a.getProjectRef().getIdentifier()) | ||
.thenComparing(Issue::getKey) | ||
.thenComparing(Issue::getParametersString); | ||
|
||
private static final IssueComparator INSTANCE = new IssueComparator(); | ||
|
||
public static Comparator<Issue> getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
public int compare(Issue issue1, Issue issue2) | ||
{ | ||
return DELEGATE.compare(issue1, issue2); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/intershop/tool/architecture/report/common/issue/IssueLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.intershop.tool.architecture.report.common.issue; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.stream.Collectors; | ||
|
||
public class IssueLogger | ||
{ | ||
private static final Logger LOGGER = LoggerFactory.getLogger(IssueLogger.class); | ||
|
||
/** | ||
* @param issues List of issues | ||
*/ | ||
public void logIssues(List<Issue> issues) | ||
{ | ||
AtomicInteger idx = new AtomicInteger(1); | ||
String renderedIssues = issues.stream().sorted(IssueComparator.getInstance()).map(issue -> | ||
String.format("%d: project=%s, key=%s, parameters=%s", idx.getAndIncrement(), issue.getProjectRef().getIdentifier(), issue.getKey(), issue.getParametersString()) | ||
).collect(Collectors.joining("\n")); | ||
|
||
LOGGER.error("Architecture report contains the following new errors:\n{}", renderedIssues); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters