Skip to content

Commit

Permalink
Ignore but report invalid keys
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyDanny committed May 11, 2024
1 parent b17bbaa commit 079801c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@

#### Bug Fixes

* Invalid keys in a configuration don't lead to the default configuration being
used anymore. The invalid key will just be reported but otherwise ignored.
[SimplyDanny](https://github.com/SimplyDanny)
[#5565](https://github.com/realm/SwiftLint/issues/5565)

* Fix version comparison algorithm which caused some version-dependent rules to
misbehave with Swift 5.10.
[chandlerwall](https://github.com/chandlerwall)
Expand Down
2 changes: 1 addition & 1 deletion Source/SwiftLintCoreMacros/RuleConfigurationMacros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ enum AutoApply: MemberMacro {
"""
if !supportedKeys.isSuperset(of: configuration.keys) {
let unknownKeys = Set(configuration.keys).subtracting(supportedKeys)
throw Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys)
Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys).print()
}
"""
})
Expand Down
10 changes: 5 additions & 5 deletions Tests/MacroTests/AutoApplyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final class AutoApplyTests: XCTestCase {
}
if !supportedKeys.isSuperset(of: configuration.keys) {
let unknownKeys = Set(configuration.keys).subtracting(supportedKeys)
throw Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys)
Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys).print()
}
}
}
Expand Down Expand Up @@ -84,7 +84,7 @@ final class AutoApplyTests: XCTestCase {
try eB.apply(configuration[$eB.key], ruleID: Parent.identifier)
if !supportedKeys.isSuperset(of: configuration.keys) {
let unknownKeys = Set(configuration.keys).subtracting(supportedKeys)
throw Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys)
Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys).print()
}
}
}
Expand Down Expand Up @@ -135,7 +135,7 @@ final class AutoApplyTests: XCTestCase {
try eC.apply(configuration[$eC.key], ruleID: Parent.identifier)
if !supportedKeys.isSuperset(of: configuration.keys) {
let unknownKeys = Set(configuration.keys).subtracting(supportedKeys)
throw Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys)
Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys).print()
}
}
}
Expand All @@ -161,7 +161,7 @@ final class AutoApplyTests: XCTestCase {
}
if !supportedKeys.isSuperset(of: configuration.keys) {
let unknownKeys = Set(configuration.keys).subtracting(supportedKeys)
throw Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys)
Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys).print()
}
}
}
Expand Down Expand Up @@ -215,7 +215,7 @@ final class AutoApplyTests: XCTestCase {
try foo.apply(configuration[$foo.key], ruleID: Parent.identifier)
if !supportedKeys.isSuperset(of: configuration.keys) {
let unknownKeys = Set(configuration.keys).subtracting(supportedKeys)
throw Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys)
Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys).print()
}
}
}
Expand Down

0 comments on commit 079801c

Please sign in to comment.