-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #293 from realm/jp-checkstyle-reporter
add checkstyle reporter
- Loading branch information
Showing
6 changed files
with
57 additions
and
3 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
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
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
33 changes: 33 additions & 0 deletions
33
Source/SwiftLintFramework/Reporters/CheckstyleReporter.swift
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,33 @@ | ||
// | ||
// CheckstyleReporter.swift | ||
// SwiftLint | ||
// | ||
// Created by JP Simard on 12/25/15. | ||
// Copyright © 2015 Realm. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct CheckstyleReporter: Reporter { | ||
public static let identifier = "checkstyle" | ||
public static let isRealtime = false | ||
|
||
public var description: String { | ||
return "Reports violations as Checkstyle XML." | ||
} | ||
|
||
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 | ||
} | ||
} |
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
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