Fix warnings in Swift 5.8/Xcode 14.3 (#4850)
This commit is contained in:
parent
6a09af169e
commit
3d15419adb
|
@ -24,8 +24,8 @@ public struct SonarQubeReporter: Reporter {
|
|||
"filePath": violation.location.relativeFile ?? "",
|
||||
"textRange": [
|
||||
"startLine": violation.location.line ?? 1
|
||||
]
|
||||
],
|
||||
] as Any
|
||||
] as Any,
|
||||
"type": "CODE_SMELL",
|
||||
"severity": violation.severity == .error ? "MAJOR" : "MINOR"
|
||||
]
|
||||
|
|
|
@ -158,9 +158,9 @@ struct UnusedImportRuleExamples {
|
|||
[
|
||||
"module": "Foundation",
|
||||
"allowed_transitive_imports": ["CoreFoundation"]
|
||||
]
|
||||
] as [String: Any]
|
||||
]
|
||||
], testMultiByteOffsets: false, testOnLinux: false):
|
||||
] as [String: Any], testMultiByteOffsets: false, testOnLinux: false):
|
||||
Example("""
|
||||
import CoreFoundation
|
||||
typealias Foo = CFArray
|
||||
|
@ -186,9 +186,9 @@ struct UnusedImportRuleExamples {
|
|||
[
|
||||
"module": "Foundation",
|
||||
"allowed_transitive_imports": ["CoreFoundation"]
|
||||
]
|
||||
] as [String: Any]
|
||||
]
|
||||
]):
|
||||
] as [String: Any]):
|
||||
Example("""
|
||||
import Foundation
|
||||
typealias Foo = CFData
|
||||
|
|
|
@ -12,7 +12,7 @@ class ExplicitTypeInterfaceConfigurationTests: XCTestCase {
|
|||
var config = ExplicitTypeInterfaceConfiguration()
|
||||
try config.apply(configuration: ["severity": "error",
|
||||
"excluded": ["local"],
|
||||
"allow_redundancy": true])
|
||||
"allow_redundancy": true] as [String: Any])
|
||||
XCTAssertEqual(config.severityConfiguration.severity, .error)
|
||||
XCTAssertEqual(config.allowedKinds, Set([.instance, .class, .static]))
|
||||
XCTAssertTrue(config.allowRedundancy)
|
||||
|
|
|
@ -143,7 +143,7 @@ class FileTypesOrderRuleTests: XCTestCase {
|
|||
verifyRule(
|
||||
groupedOrderDescription,
|
||||
ruleConfiguration: [
|
||||
"order": ["main_type", ["extension", "supporting_type"], "preview_provider"]
|
||||
"order": ["main_type", ["extension", "supporting_type"] as Any, "preview_provider"] as Any
|
||||
]
|
||||
)
|
||||
}
|
||||
|
|
|
@ -123,12 +123,12 @@ class LinterCacheTests: XCTestCase {
|
|||
}
|
||||
|
||||
func testConfigFileReorderedReusesCache() {
|
||||
let helper = makeCacheTestHelper(dict: ["only_rules": ["mock"], "disabled_rules": []])
|
||||
let helper = makeCacheTestHelper(dict: ["only_rules": ["mock"], "disabled_rules": [Any]()])
|
||||
let file = "foo.swift"
|
||||
let violations = helper.makeViolations(file: file)
|
||||
|
||||
cacheAndValidate(violations: violations, forFile: file, configuration: helper.configuration)
|
||||
let configuration2 = helper.makeConfig(dict: ["disabled_rules": [], "only_rules": ["mock"]])
|
||||
let configuration2 = helper.makeConfig(dict: ["disabled_rules": [Any](), "only_rules": ["mock"]])
|
||||
XCTAssertEqual(cache.violations(forFile: file, configuration: configuration2)!, violations)
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ class LinterCacheTests: XCTestCase {
|
|||
let violations = helper.makeViolations(file: file)
|
||||
|
||||
cacheAndValidate(violations: violations, forFile: file, configuration: helper.configuration)
|
||||
let configuration2 = helper.makeConfig(dict: ["disabled_rules": [], "only_rules": ["mock"]])
|
||||
let configuration2 = helper.makeConfig(dict: ["disabled_rules": [Any](), "only_rules": ["mock"]])
|
||||
XCTAssertEqual(cache.violations(forFile: file, configuration: configuration2)!, violations)
|
||||
let configYamlWithComment = try YamlParser.parse("# comment1\nonly_rules:\n - mock # comment2")
|
||||
let configuration3 = helper.makeConfig(dict: configYamlWithComment)
|
||||
|
@ -232,7 +232,7 @@ class LinterCacheTests: XCTestCase {
|
|||
// Addition
|
||||
try validateNewConfigDoesntHitCache(dict: ["disabled_rules": ["nesting", "todo"]], initialConfig: initialConfig)
|
||||
// Removal
|
||||
try validateNewConfigDoesntHitCache(dict: ["disabled_rules": []], initialConfig: initialConfig)
|
||||
try validateNewConfigDoesntHitCache(dict: ["disabled_rules": [Any]()], initialConfig: initialConfig)
|
||||
}
|
||||
|
||||
func testOptInRulesChangedOrAddedOrRemovedCausesAllFilesToBeReLinted() throws {
|
||||
|
@ -245,7 +245,7 @@ class LinterCacheTests: XCTestCase {
|
|||
try validateNewConfigDoesntHitCache(dict: ["opt_in_rules": ["attributes", "empty_count"]],
|
||||
initialConfig: initialConfig)
|
||||
// Removal
|
||||
try validateNewConfigDoesntHitCache(dict: ["opt_in_rules": []], initialConfig: initialConfig)
|
||||
try validateNewConfigDoesntHitCache(dict: ["opt_in_rules": [Any]()], initialConfig: initialConfig)
|
||||
}
|
||||
|
||||
func testEnabledRulesChangedOrAddedOrRemovedCausesAllFilesToBeReLinted() throws {
|
||||
|
@ -258,7 +258,7 @@ class LinterCacheTests: XCTestCase {
|
|||
try validateNewConfigDoesntHitCache(dict: ["enabled_rules": ["attributes", "empty_count"]],
|
||||
initialConfig: initialConfig)
|
||||
// Removal
|
||||
try validateNewConfigDoesntHitCache(dict: ["enabled_rules": []], initialConfig: initialConfig)
|
||||
try validateNewConfigDoesntHitCache(dict: ["enabled_rules": [Any]()], initialConfig: initialConfig)
|
||||
}
|
||||
|
||||
func testOnlyRulesChangedOrAddedOrRemovedCausesAllFilesToBeReLinted() throws {
|
||||
|
@ -270,7 +270,7 @@ class LinterCacheTests: XCTestCase {
|
|||
// Addition
|
||||
try validateNewConfigDoesntHitCache(dict: ["only_rules": ["nesting", "todo"]], initialConfig: initialConfig)
|
||||
// Removal
|
||||
try validateNewConfigDoesntHitCache(dict: ["only_rules": []], initialConfig: initialConfig)
|
||||
try validateNewConfigDoesntHitCache(dict: ["only_rules": [Any]()], initialConfig: initialConfig)
|
||||
}
|
||||
|
||||
func testRuleConfigurationChangedOrAddedOrRemovedCausesAllFilesToBeReLinted() throws {
|
||||
|
|
|
@ -129,7 +129,9 @@ class MissingDocsRuleTests: XCTestCase {
|
|||
|
||||
func testInvalidDuplicateAcl() {
|
||||
var configuration = MissingDocsRuleConfiguration()
|
||||
XCTAssertThrowsError(try configuration.apply(configuration: ["warning": ["public", "open"], "error": "public"]))
|
||||
XCTAssertThrowsError(
|
||||
try configuration.apply(configuration: ["warning": ["public", "open"] as Any, "error": "public"])
|
||||
)
|
||||
}
|
||||
|
||||
func testExcludesFalse() {
|
||||
|
@ -175,7 +177,7 @@ class MissingDocsRuleTests: XCTestCase {
|
|||
"excludes_extensions": true,
|
||||
"excludes_inherited_types": false,
|
||||
"error": ["public"]
|
||||
]
|
||||
] as [String: Any]
|
||||
)
|
||||
|
||||
XCTAssertTrue(configuration.excludesExtensions)
|
||||
|
|
|
@ -93,9 +93,9 @@ class NumberSeparatorRuleTests: XCTestCase {
|
|||
"exclude_ranges": [
|
||||
["min": 1900, "max": 2030],
|
||||
["min": 2.0, "max": 3.0]
|
||||
],
|
||||
] as Any,
|
||||
"minimum_fraction_length": 3
|
||||
]
|
||||
] as Any
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ class NumberSeparatorRuleTests: XCTestCase {
|
|||
)
|
||||
}
|
||||
|
||||
private func violations(in code: String, config: Any = []) -> [String] {
|
||||
private func violations(in code: String, config: Any = [Any]()) -> [String] {
|
||||
var rule = NumberSeparatorRule()
|
||||
try? rule.configuration.apply(configuration: config)
|
||||
let visitor = rule.makeVisitor(file: SwiftLintFile(contents: ""))
|
||||
|
|
|
@ -25,7 +25,7 @@ class RegexConfigurationTests: XCTestCase {
|
|||
"excluded": [
|
||||
"^Tests/.*\\.swift",
|
||||
"^MyFramework/Tests/.*\\.swift"
|
||||
]
|
||||
] as Any
|
||||
])
|
||||
|
||||
XCTAssertFalse(config.shouldValidate(filePath: "Tests/file.swift"))
|
||||
|
@ -52,7 +52,7 @@ class RegexConfigurationTests: XCTestCase {
|
|||
"included": [
|
||||
"App/.*\\.swift",
|
||||
"MyFramework/.*\\.swift"
|
||||
]
|
||||
] as Any
|
||||
])
|
||||
|
||||
XCTAssertFalse(config.shouldValidate(filePath: "Tests/file.swift"))
|
||||
|
@ -67,11 +67,11 @@ class RegexConfigurationTests: XCTestCase {
|
|||
"included": [
|
||||
"App/.*\\.swift",
|
||||
"MyFramework/.*\\.swift"
|
||||
],
|
||||
] as Any,
|
||||
"excluded": [
|
||||
"Tests/.*\\.swift",
|
||||
"App/Fixtures/.*\\.swift"
|
||||
]
|
||||
] as Any
|
||||
])
|
||||
|
||||
XCTAssertTrue(config.shouldValidate(filePath: "App/file.swift"))
|
||||
|
|
|
@ -11,7 +11,7 @@ class TrailingClosureConfigurationTests: XCTestCase {
|
|||
func testApplyingCustomConfiguration() throws {
|
||||
var config = TrailingClosureConfiguration()
|
||||
try config.apply(configuration: ["severity": "error",
|
||||
"only_single_muted_parameter": true])
|
||||
"only_single_muted_parameter": true] as [String: Any])
|
||||
XCTAssertEqual(config.severityConfiguration.severity, .error)
|
||||
XCTAssertTrue(config.onlySingleMutedParameter)
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ class TypeContentsOrderRuleTests: XCTestCase {
|
|||
"subtype",
|
||||
["type_alias", "associated_type"],
|
||||
"case"
|
||||
]
|
||||
] as [Any]
|
||||
]
|
||||
)
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@ class UnusedDeclarationConfigurationTests: XCTestCase {
|
|||
includePublicAndOpen: false,
|
||||
relatedUSRsToSkip: []
|
||||
)
|
||||
let config: Any = [
|
||||
let config = [
|
||||
"severity": "error",
|
||||
"include_public_and_open": true,
|
||||
"related_usrs_to_skip": ["a", "b"]
|
||||
]
|
||||
] as [String: Any]
|
||||
|
||||
try testee.apply(configuration: config)
|
||||
|
||||
|
|
Loading…
Reference in New Issue