Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make emoji and checkstyle reporter to output report sorted by file name #1430

Merged
merged 3 commits into from
Apr 14, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

##### Bug Fixes

* None.
* `emoji` and `checkstyle` reporter output report sorted by file name.
[norio-nomura](https://github.com/norio-nomura)
[#1429](https://github.com/realm/SwiftLint/issues/1429)

## 0.18.1: Misaligned Drum

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public struct CheckstyleReporter: Reporter {
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<checkstyle version=\"4.3\">",
violations
.group(by: { ($0.location.file ?? "<nopath>").escapedForXML() })
.sorted(by: { $0.key < $1.key })
.map(generateForViolationFile).joined(),
"\n</checkstyle>"
].joined()
Expand Down
7 changes: 4 additions & 3 deletions Source/SwiftLintFramework/Reporters/EmojiReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ public struct EmojiReporter: Reporter {
}

public static func generateReport(_ violations: [StyleViolation]) -> String {
return violations.group { violation in
violation.location.file ?? "Other"
}.map(report).joined(separator: "\n")
return violations
.group(by: { $0.location.file ?? "Other" })
.sorted(by: { $0.key < $1.key })
.map(report).joined(separator: "\n")
}

private static func report(for file: String, with violations: [StyleViolation]) -> String {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="&lt;nopath&gt;">
<error line="0" column="0" severity="error" message="Colons should be next to the identifier when specifying a type and next to the key in dictionary literals." source="swiftlint.rules.colon"/>
</file>
<file name="filename">
<error line="1" column="2" severity="warning" message="Violation Reason." source="swiftlint.rules.line_length"/>
<error line="1" column="2" severity="error" message="Violation Reason." source="swiftlint.rules.line_length"/>
<error line="1" column="2" severity="error" message="Shorthand syntactic sugar should be used, i.e. [Int] instead of Array&lt;Int&gt;." source="swiftlint.rules.syntactic_sugar"/>
</file>
<file name="&lt;nopath&gt;">
<error line="0" column="0" severity="error" message="Colons should be next to the identifier when specifying a type and next to the key in dictionary literals." source="swiftlint.rules.colon"/>
</file>
</checkstyle>