Print a warning for Analyzer rules misplaced in the configuration (#4620)
This commit is contained in:
parent
93d0d8fa7f
commit
4adabd8e4b
|
@ -32,6 +32,11 @@
|
|||
[Martin Redington](https://github.com/mildm8nnered)
|
||||
[#4200](https://github.com/realm/SwiftLint/issues/4200)
|
||||
|
||||
* Show warnings in the console for Analyzer rules that are listed in the
|
||||
`opt_in_rules` configuration section.
|
||||
[SimplyDanny](https://github.com/SimplyDanny)
|
||||
[#4612](https://github.com/realm/SwiftLint/issues/4612)
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* Fix configuration parsing error in `unused_declaration` rule.
|
||||
|
|
|
@ -57,6 +57,7 @@ extension Configuration {
|
|||
configurationDictionary: dict, disabledRules: disabledRules,
|
||||
optInRules: optInRules, onlyRules: onlyRules, ruleList: ruleList
|
||||
)
|
||||
Self.warnAboutMisplacedAnalyzerRules(optInRules: optInRules, ruleList: ruleList)
|
||||
|
||||
let allRulesWrapped: [ConfigurationRuleWrapper]
|
||||
do {
|
||||
|
@ -202,4 +203,18 @@ extension Configuration {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static func warnAboutMisplacedAnalyzerRules(optInRules: [String], ruleList: RuleList) {
|
||||
let analyzerRules = ruleList.list
|
||||
.filter { $0.value.self is AnalyzerRule.Type }
|
||||
.map(\.key)
|
||||
Set(analyzerRules).intersection(optInRules)
|
||||
.sorted()
|
||||
.forEach {
|
||||
queuedPrintError("""
|
||||
warning: '\($0)' should be listed in the 'analyzer_rules' configuration section \
|
||||
for more clarity as it is only run by 'swiftlint analyze'
|
||||
""")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue