mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
Add rules to SARIF exporter (#6502)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user