Skip to content

Commit

Permalink
Warn if we find a configuration for a disabled rule, that is disabled…
Browse files Browse the repository at this point in the history
… in a parent configuration
  • Loading branch information
mildm8nnered committed Apr 19, 2023
1 parent 789a609 commit 491bea8
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions Source/SwiftLintFramework/Extensions/Configuration+Parsing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,25 +217,32 @@ extension Configuration {
optInRules: Set<String>,
ruleType: Rule.Type
) {
if ruleType is OptInRule.Type {
var allOptInRules = optInRules
if let parentConfiguration {
switch parentConfiguration.rulesMode {
case .allEnabled:
return
case .only(let parentOnlyRules):
allOptInRules.formUnion(parentOnlyRules)
case let .default(disabled: _, optIn: parentOptInRules):
allOptInRules.formUnion(parentOptInRules)
}
var allOptInRules = optInRules
var allDisabledRules = disabledRules

if let parentConfiguration {
switch parentConfiguration.rulesMode {
case .allEnabled:
return
case .only(let parentOnlyRules):
allOptInRules.formUnion(parentOnlyRules)
case let .default(disabled: parentDisabledRules, optIn: parentOptInRules):
allOptInRules.formUnion(parentOptInRules)
allDisabledRules.formUnion(parentDisabledRules)
}
if Set(allOptInRules).isDisjoint(with: ruleType.description.allIdentifiers) {
}

let allIdentifiers = ruleType.description.allIdentifiers
if ruleType is OptInRule.Type {
if Set(allOptInRules).isDisjoint(with: allIdentifiers) {
queuedPrintError("\(message), but it is not enabled on " +
"'\(Key.optInRules.rawValue)'.")
}
} else if Set(disabledRules).isSuperset(of: ruleType.description.allIdentifiers) {
} else if Set(disabledRules).isSuperset(of: allIdentifiers) {
queuedPrintError("\(message), but it is disabled on " +
"'\(Key.disabledRules.rawValue)'.")
"'\(Key.disabledRules.rawValue)'.")
} else if Set(allDisabledRules.subtracting(disabledRules)).isSuperset(of: allIdentifiers) {
queuedPrintError("\(message), but it is disabled in a parent configuration.")
}
}

Expand Down

0 comments on commit 491bea8

Please sign in to comment.