Skip to content

Commit

Permalink
Add Subito custom reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
Faber92 committed Aug 14, 2024
1 parent cf03a6a commit f8f6176
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions Source/SwiftLintCore/Models/ReportersList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public let reportersList: [any Reporter.Type] = [
RelativePathReporter.self,
SARIFReporter.self,
SonarQubeReporter.self,
SubitoReporter.self,
SummaryReporter.self,
XcodeReporter.self
]
28 changes: 28 additions & 0 deletions Source/SwiftLintCore/Reporters/SubitoReporter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/// Reports violations in the custom Subito format.
struct SubitoReporter: Reporter {
// MARK: - Reporter Conformance

static let identifier = "subito"
static let isRealtime = true
static let description = "Reports violations in the custom Subito format."

static func generateReport(_ violations: [StyleViolation]) -> String {
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.
static func generateForSingleViolation(_ violation: StyleViolation) -> String {
// {error,warning}
// {full_path_to_file}{:line}{:character}
// {content} - {content}
"""
\(violation.severity.rawValue)
\(violation.location)
\(violation.ruleName) Violation - \(violation.reason) \(violation.ruleIdentifier)
"""
}
}

0 comments on commit f8f6176

Please sign in to comment.