mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
rewrite CheckstyleReporter.generateReport to compile 100x faster
before: 10s after: 100ms
This commit is contained in:
@@ -17,17 +17,15 @@ public struct CheckstyleReporter: Reporter {
|
||||
}
|
||||
|
||||
public static func generateReport(violations: [StyleViolation]) -> String {
|
||||
var report = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<checkstyle version=\"4.3\">"
|
||||
report += violations.map { violation in
|
||||
let fileName = violation.location.file ?? "<nopath>"
|
||||
return "\n\t<file name=\"\(fileName)\">\n" +
|
||||
"\t\t<error line=\"\(violation.location.line ?? 0)\" " +
|
||||
"column=\"\(violation.location.character ?? 0)\" " +
|
||||
"severity=\"\(violation.severity.rawValue.lowercaseString)\" " +
|
||||
"message=\"\(violation.reason)\"/>\n" +
|
||||
"\t</file>"
|
||||
}.joinWithSeparator("")
|
||||
report += "\n</checkstyle>"
|
||||
return report
|
||||
return "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<checkstyle version=\"4.3\">" +
|
||||
violations.map({ violation in
|
||||
let fileName = violation.location.file ?? "<nopath>"
|
||||
return ["\n\t<file name=\"\(fileName)\">\n",
|
||||
"\t\t<error line=\"\(violation.location.line ?? 0)\" ",
|
||||
"column=\"\(violation.location.character ?? 0)\" ",
|
||||
"severity=\"\(violation.severity.rawValue.lowercaseString)\" ",
|
||||
"message=\"\(violation.reason)\"/>\n",
|
||||
"\t</file>"].joinWithSeparator("")
|
||||
}).joinWithSeparator("") + "\n</checkstyle>"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user