mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
fcf848608e
* Add Example wrapper in order to display test failures inline when running in Xcode. * Stop using Swift 5.1-only features so we can compile on Xcode 10.2. * Wrap strings in Example. * Add Changelog entry. * Wrap all examples in Example struct. * Better and more complete capturing of line numbers. * Fix broken test. * Better test traceability. * Address or disable linting warnings. * Add documentation comments. * Disable linter for a few cases. * Limit mutability and add copy-and-mutate utility functions. * Limit scope of mutability.
32 lines
1.1 KiB
Swift
32 lines
1.1 KiB
Swift
/// Reports violations in the format Xcode uses to display in the IDE. (default)
|
|
public struct XcodeReporter: Reporter {
|
|
// MARK: - Reporter Conformance
|
|
|
|
public static let identifier = "xcode"
|
|
public static let isRealtime = true
|
|
|
|
public var description: String {
|
|
return "Reports violations in the format Xcode uses to display in the IDE. (default)"
|
|
}
|
|
|
|
public static func generateReport(_ violations: [StyleViolation]) -> String {
|
|
return violations.map(generateForSingleViolation).joined(separator: "\n")
|
|
}
|
|
|
|
/// Generates a report for a single violation.
|
|
///
|
|
/// - parameter violation: The violation to report.
|
|
///
|
|
/// - returns: The report for a single violation.
|
|
internal static func generateForSingleViolation(_ violation: StyleViolation) -> String {
|
|
// {full_path_to_file}{:line}{:character}: {error,warning}: {content}
|
|
return [
|
|
"\(violation.location): ",
|
|
"\(violation.severity.rawValue): ",
|
|
"\(violation.ruleName) Violation: ",
|
|
violation.reason,
|
|
" (\(violation.ruleIdentifier))"
|
|
].joined()
|
|
}
|
|
}
|