Add rules to SARIF exporter (#6502)

Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
This commit is contained in:
Ahmad Alfy
2026-02-23 12:08:49 +02:00
committed by GitHub
parent 5707e17dff
commit 21d66e5dc7
5 changed files with 152 additions and 95 deletions
@@ -23,6 +23,9 @@ struct SARIFReporter: Reporter {
"name": "SwiftLint",
"semanticVersion": Version.current.value,
"informationUri": swiftlintVersion,
"rules": RuleRegistry.shared.list.list.values
.sorted { $0.identifier < $1.identifier }
.map(dictionary(for:)),
],
],
"results": violations.map(dictionary(for:)),
@@ -35,6 +38,20 @@ struct SARIFReporter: Reporter {
// MARK: - Private
private static func dictionary(for ruleType: any Rule.Type) -> [String: Any] {
let description = ruleType.description
return [
"id": description.identifier,
"shortDescription": [
"text": description.name
],
"fullDescription": [
"text": description.description
],
"helpUri": "https://realm.github.io/SwiftLint/\(description.identifier).html",
]
}
private static func dictionary(for violation: StyleViolation) -> [String: Any] {
[
"level": violation.severity.rawValue,