Skip to content

Commit 7f8c50d

Browse files
committed
Finding all violations for files
* Even if same file is reported twice (with absolute and relative path)
1 parent a379175 commit 7f8c50d

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

src/main/java/org/jenkinsci/plugins/jvcts/perform/JvctsPerformer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,18 @@ private static void commentStash(Map<String, List<Violation>> violationsPerFile,
9595
*/
9696
private static List<Violation> getViolationsForFile(Map<String, List<Violation>> violationsPerFile,
9797
String changedFileInStash, BuildListener listener) {
98+
List<Violation> found = newArrayList();
9899
for (String reportedFile : violationsPerFile.keySet()) {
99100
if (reportedFile.endsWith(changedFileInStash) || changedFileInStash.endsWith(reportedFile)) {
100101
JvctsLogger.doLog(listener, FINE, "Changed file and reported file matches. Stash: \"" + changedFileInStash
101102
+ "\" Reported: \"" + reportedFile + "\"");
102-
return violationsPerFile.get(reportedFile);
103+
found.addAll(violationsPerFile.get(reportedFile));
103104
} else {
104105
doLog(listener, FINE, "Changed file and reported file not matching. Stash: \"" + changedFileInStash
105106
+ "\" Reported: \"" + reportedFile + "\"");
106107
}
107108
}
108-
return newArrayList();
109+
return found;
109110
}
110111

111112
private static String constructCommentMessage(Violation v) {

src/test/java/org/jenkinsci/plugins/jvcts/stash/StashClientFaker.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public String invokeUrl(ViolationsToStashConfig config, String url, Method metho
6161
fake(readFile("checkstyle_checkstylefile_1.json"), "");
6262
fake(readFile("checkstyle_checkstylefile_2.json"), "");
6363
fake(readFile("checkstyle_checkstylefile_3_relativePath.json"), "");
64+
fake(readFile("checkstyle_checkstylefile_3.json"), "");
6465
fake(readFile("checkstyle_pmdandcheckstyle.json"), "");
6566
fake(readFile("pmd_pmdandcheckstyle.json"), "");
6667
fake(readFile("pmd_pmdfile.json"), "");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
http://stash.server/rest/api/1.0/projects/stashProject/repos/stashRepo/pull-requests/1/comments POST { "text": "checkstyle L77 Low (4) Same file also rel.", "anchor": { "line": "77", "lineType": "ADDED", "fileType": "TO", "path": "module/src/main/java/se/bjurr/code/CheckstyleFile.java" }}

src/test/resources/freestyle/checkstyle/checkstyle_relativePath.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
<file name="../module/src/main/java/se/bjurr/code/CheckstyleFileRel.java">
44
<error line="10" column="25" severity="warning" message="Relative path." source="com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck"/>
55
</file>
6+
<file name="../module/src/main/java/se/bjurr/code/CheckstyleFile.java">
7+
<error line="77" severity="info" message="Same file also rel." source="com.puppycrawl.tools.checkstyle.checks.TrailingCommentCheck"/>
8+
</file>
69
</checkstyle>

0 commit comments

Comments
 (0)