Skip to content

Commit

Permalink
Merge pull request realm#1142 from realm/jp-api-guidelines-framework-…
Browse files Browse the repository at this point in the history
…reporters

update SwiftLintFramework/Reporters to follow Swift 3 API Design Guidelines
  • Loading branch information
jpsim authored Jan 10, 2017
2 parents df99e64 + 00cd61a commit 86ebc9c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Source/SwiftLintFramework/Reporters/CSVReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public struct CSVReporter: Reporter {
"reason",
"rule_id"
]
return (keys + violations.flatMap(arrayForViolation)).joined(separator: ",")
return (keys + violations.flatMap(array(for:))).joined(separator: ",")
}

fileprivate static func arrayForViolation(_ violation: StyleViolation) -> [String] {
fileprivate static func array(for violation: StyleViolation) -> [String] {
return [
violation.location.file?.escapedForCSV() ?? "",
violation.location.line?.description ?? "",
Expand Down
4 changes: 2 additions & 2 deletions Source/SwiftLintFramework/Reporters/EmojiReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public struct EmojiReporter: Reporter {
public static func generateReport(_ violations: [StyleViolation]) -> String {
return violations.group { violation in
violation.location.file ?? "Other"
}.map(reportFor).joined(separator: "\n")
}.map(report).joined(separator: "\n")
}

private static func reportFor(file: String, with violations: [StyleViolation]) -> String {
private static func report(for file: String, with violations: [StyleViolation]) -> String {
let lines = [file] + violations.sorted(by: { lhs, rhs in
guard lhs.severity == rhs.severity else {
return lhs.severity > rhs.severity
Expand Down
4 changes: 2 additions & 2 deletions Source/SwiftLintFramework/Reporters/JSONReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public struct JSONReporter: Reporter {
}

public static func generateReport(_ violations: [StyleViolation]) -> String {
return toJSON(violations.map(dictionaryForViolation))
return toJSON(violations.map(dictionary(for:)))
}

fileprivate static func dictionaryForViolation(_ violation: StyleViolation) -> [String: Any] {
fileprivate static func dictionary(for violation: StyleViolation) -> [String: Any] {
return [
"file": violation.location.file ?? NSNull() as Any,
"line": violation.location.line ?? NSNull() as Any,
Expand Down

0 comments on commit 86ebc9c

Please sign in to comment.