mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
Do not throw deprecation warning if property is not present in configuration (#5792)
This commit is contained in:
committed by
GitHub
parent
8241909add
commit
0d04196f92
@@ -19,6 +19,11 @@
|
||||
[SimplyDanny](https://github.com/SimplyDanny)
|
||||
[#5787](https://github.com/realm/SwiftLint/issues/5787)
|
||||
|
||||
* Do not throw deprecation warning if deprecated property is not
|
||||
presented in configuration.
|
||||
[chipp](https://github.com/chipp)
|
||||
[#5791](https://github.com/realm/SwiftLint/issues/5791)
|
||||
|
||||
## 0.57.0: Squeaky Clean Cycle
|
||||
|
||||
#### Breaking
|
||||
|
||||
@@ -74,7 +74,9 @@ enum AutoConfigParser: MemberMacro {
|
||||
"""
|
||||
for option in nonInlinedOptions {
|
||||
"""
|
||||
try \(raw: option).apply(configuration[$\(raw: option).key], ruleID: Parent.identifier)
|
||||
if let value = configuration[$\(raw: option).key] {
|
||||
try \(raw: option).apply(value, ruleID: Parent.identifier)
|
||||
}
|
||||
"""
|
||||
}
|
||||
"""
|
||||
|
||||
@@ -80,8 +80,12 @@ final class AutoConfigParserTests: XCTestCase {
|
||||
guard let configuration = configuration as? [String: Any] else {
|
||||
throw Issue.invalidConfiguration(ruleID: Parent.identifier)
|
||||
}
|
||||
try eA.apply(configuration[$eA.key], ruleID: Parent.identifier)
|
||||
try eB.apply(configuration[$eB.key], ruleID: Parent.identifier)
|
||||
if let value = configuration[$eA.key] {
|
||||
try eA.apply(value, ruleID: Parent.identifier)
|
||||
}
|
||||
if let value = configuration[$eB.key] {
|
||||
try eB.apply(value, ruleID: Parent.identifier)
|
||||
}
|
||||
if !supportedKeys.isSuperset(of: configuration.keys) {
|
||||
let unknownKeys = Set(configuration.keys).subtracting(supportedKeys)
|
||||
Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys).print()
|
||||
@@ -131,8 +135,12 @@ final class AutoConfigParserTests: XCTestCase {
|
||||
guard let configuration = configuration as? [String: Any] else {
|
||||
return
|
||||
}
|
||||
try eA.apply(configuration[$eA.key], ruleID: Parent.identifier)
|
||||
try eC.apply(configuration[$eC.key], ruleID: Parent.identifier)
|
||||
if let value = configuration[$eA.key] {
|
||||
try eA.apply(value, ruleID: Parent.identifier)
|
||||
}
|
||||
if let value = configuration[$eC.key] {
|
||||
try eC.apply(value, ruleID: Parent.identifier)
|
||||
}
|
||||
if !supportedKeys.isSuperset(of: configuration.keys) {
|
||||
let unknownKeys = Set(configuration.keys).subtracting(supportedKeys)
|
||||
Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys).print()
|
||||
@@ -177,7 +185,6 @@ final class AutoConfigParserTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testSeverityAppliedTwice() {
|
||||
// swiftlint:disable line_length
|
||||
assertMacroExpansion(
|
||||
"""
|
||||
@AutoConfigParser
|
||||
@@ -211,8 +218,12 @@ final class AutoConfigParserTests: XCTestCase {
|
||||
guard let configuration = configuration as? [String: Any] else {
|
||||
return
|
||||
}
|
||||
try severityConfiguration.apply(configuration[$severityConfiguration.key], ruleID: Parent.identifier)
|
||||
try foo.apply(configuration[$foo.key], ruleID: Parent.identifier)
|
||||
if let value = configuration[$severityConfiguration.key] {
|
||||
try severityConfiguration.apply(value, ruleID: Parent.identifier)
|
||||
}
|
||||
if let value = configuration[$foo.key] {
|
||||
try foo.apply(value, ruleID: Parent.identifier)
|
||||
}
|
||||
if !supportedKeys.isSuperset(of: configuration.keys) {
|
||||
let unknownKeys = Set(configuration.keys).subtracting(supportedKeys)
|
||||
Issue.invalidConfigurationKeys(ruleID: Parent.identifier, keys: unknownKeys).print()
|
||||
@@ -222,6 +233,5 @@ final class AutoConfigParserTests: XCTestCase {
|
||||
""",
|
||||
macros: macros
|
||||
)
|
||||
// swiftlint:enable line_length
|
||||
}
|
||||
}
|
||||
|
||||
@@ -499,6 +499,12 @@ final class RuleConfigurationDescriptionTests: XCTestCase {
|
||||
)
|
||||
}
|
||||
|
||||
func testNoDeprecationWarningIfNoDeprecatedPropertySet() throws {
|
||||
var configuration = TestConfiguration()
|
||||
|
||||
XCTAssert(try Issue.captureConsole { try configuration.apply(configuration: ["flag": false]) }.isEmpty)
|
||||
}
|
||||
|
||||
func testInvalidKeys() throws {
|
||||
var configuration = TestConfiguration()
|
||||
|
||||
@@ -511,10 +517,7 @@ final class RuleConfigurationDescriptionTests: XCTestCase {
|
||||
"unsupported": true,
|
||||
])
|
||||
},
|
||||
"""
|
||||
warning: Configuration option 'set' in 'my_rule' rule is deprecated. Use the option 'other_opt' instead.
|
||||
warning: Configuration for 'RuleMock' rule contains the invalid key(s) 'unknown', 'unsupported'.
|
||||
"""
|
||||
"warning: Configuration for 'RuleMock' rule contains the invalid key(s) 'unknown', 'unsupported'."
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user