mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
Current events have renewed the conversation in our community about the roles of terminology with racist connotations in our software. Many companies and developers are now taking appropriate steps to remove this terminology from their codebases and products. (e.g. [GitHub](https://twitter.com/natfriedman/status/1271253144442253312)) This small rule prevents the use of declarations that contain any of the terms: whitelist, blacklist, master, and slave. It may be appropriate to add more terms to this list now or in the future.
39 lines
1.5 KiB
Swift
39 lines
1.5 KiB
Swift
@testable import SwiftLintFramework
|
|
import XCTest
|
|
|
|
final class ConfigurationAliasesTests: XCTestCase {
|
|
let testRuleList = RuleList(rules: RuleWithLevelsMock.self)
|
|
|
|
func testConfiguresCorrectlyFromDeprecatedAlias() throws {
|
|
let ruleConfiguration = [1, 2]
|
|
let config = ["mock": ruleConfiguration]
|
|
let rules = try testRuleList.configuredRules(with: config)
|
|
XCTAssertTrue(rules == [try RuleWithLevelsMock(configuration: ruleConfiguration)])
|
|
}
|
|
|
|
func testReturnsNilWithDuplicatedConfiguration() {
|
|
let dict = ["mock": [1, 2], "severity_level_mock": [1, 3]]
|
|
let configuration = Configuration(dict: dict, ruleList: testRuleList)
|
|
XCTAssertNil(configuration)
|
|
}
|
|
|
|
func testInitsFromDeprecatedAlias() {
|
|
let ruleConfiguration = [1, 2]
|
|
let configuration = Configuration(dict: ["mock": ruleConfiguration], ruleList: testRuleList)
|
|
XCTAssertNotNil(configuration)
|
|
}
|
|
|
|
func testOnlyRulesFromDeprecatedAlias() {
|
|
let configuration = Configuration(dict: ["only_rules": ["mock"]], ruleList: testRuleList)!
|
|
let configuredIdentifiers = configuration.rules.map {
|
|
type(of: $0).description.identifier
|
|
}
|
|
XCTAssertEqual(configuredIdentifiers, ["severity_level_mock"])
|
|
}
|
|
|
|
func testDisabledRulesFromDeprecatedAlias() {
|
|
let configuration = Configuration(dict: ["disabled_rules": ["mock"]], ruleList: testRuleList)!
|
|
XCTAssert(configuration.rules.isEmpty)
|
|
}
|
|
}
|