File tree Expand file tree Collapse file tree 4 files changed +9
-2
lines changed Expand file tree Collapse file tree 4 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ public struct Finding {
16
16
public enum Severity {
17
17
case warning
18
18
case error
19
+ case refactoring
19
20
}
20
21
21
22
/// The file path and location in that file where a finding was encountered.
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ extension Rule {
46
46
public func diagnose< SyntaxType: SyntaxProtocol > (
47
47
_ message: Finding . Message ,
48
48
on node: SyntaxType ? ,
49
+ severity: Finding . Severity ? = nil ,
49
50
leadingTriviaIndex: Trivia . Index ? = nil ,
50
51
notes: [ Finding . Note ] = [ ]
51
52
) {
@@ -57,9 +58,10 @@ extension Rule {
57
58
syntaxLocation = node? . startLocation ( converter: context. sourceLocationConverter)
58
59
}
59
60
61
+ let category = RuleBasedFindingCategory ( ruleType: type ( of: self ) , severity: severity)
60
62
context. findingEmitter. emit (
61
63
message,
62
- category: RuleBasedFindingCategory ( ruleType : type ( of : self ) ) ,
64
+ category: category ,
63
65
location: syntaxLocation. flatMap ( Finding . Location. init) ,
64
66
notes: notes)
65
67
}
Original file line number Diff line number Diff line change @@ -22,8 +22,11 @@ struct RuleBasedFindingCategory: FindingCategorizing {
22
22
23
23
var description : String { ruleType. ruleName }
24
24
25
+ var severity : Finding . Severity ?
26
+
25
27
/// Creates a finding category that wraps the given rule type.
26
- init ( ruleType: Rule . Type ) {
28
+ init ( ruleType: Rule . Type , severity : Finding . Severity ? = nil ) {
27
29
self . ruleType = ruleType
30
+ self . severity = severity
28
31
}
29
32
}
Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ final class DiagnosticsEngine {
116
116
switch finding. severity {
117
117
case . error: severity = . error
118
118
case . warning: severity = . warning
119
+ case . refactoring: severity = . warning
119
120
}
120
121
return Diagnostic (
121
122
severity: severity,
You can’t perform that action at this time.
0 commit comments