Fix configuration parsing error in `unused_declaration` rule (#4619)
This commit is contained in:
parent
4dfef014ab
commit
93d0d8fa7f
|
@ -34,6 +34,10 @@
|
|||
|
||||
#### Bug Fixes
|
||||
|
||||
* Fix configuration parsing error in `unused_declaration` rule.
|
||||
[SimplyDanny](https://github.com/SimplyDanny)
|
||||
[#4612](https://github.com/realm/SwiftLint/issues/4612)
|
||||
|
||||
* Fix false positives in `empty_enum_arguments` when the called expression
|
||||
is an identifier or an init call.
|
||||
[Steffen Matthischke](https://github.com/heeaad)
|
||||
|
|
|
@ -32,7 +32,7 @@ struct UnusedDeclarationConfiguration: RuleConfiguration, Equatable {
|
|||
}
|
||||
switch (key, value) {
|
||||
case (.severity, let stringValue as String):
|
||||
try severityConfiguration.apply(configuration: [key: stringValue])
|
||||
try severityConfiguration.apply(configuration: stringValue)
|
||||
case (.includePublicAndOpen, let boolValue as Bool):
|
||||
includePublicAndOpen = boolValue
|
||||
case (.relatedUSRsToSkip, let value):
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
@testable import SwiftLintFramework
|
||||
import XCTest
|
||||
|
||||
class UnusedDeclarationConfigurationTests: XCTestCase {
|
||||
func testParseConfiguration() throws {
|
||||
var testee = UnusedDeclarationConfiguration(
|
||||
severity: .warning,
|
||||
includePublicAndOpen: false,
|
||||
relatedUSRsToSkip: []
|
||||
)
|
||||
let config: Any = [
|
||||
"severity": "error",
|
||||
"include_public_and_open": true,
|
||||
"related_usrs_to_skip": ["a", "b"]
|
||||
]
|
||||
|
||||
try testee.apply(configuration: config)
|
||||
|
||||
XCTAssertEqual(testee.severityConfiguration.severity, .error)
|
||||
XCTAssertTrue(testee.includePublicAndOpen)
|
||||
XCTAssertEqual(testee.relatedUSRsToSkip, ["a", "b"])
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue