mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
15b285527a
* Short names for test modules * Lint plugins and `Package.swift` in integration tests * Simplify and merge file groups in Bazel * Move common functions to `TestHelpers`
45 lines
1.4 KiB
Swift
45 lines
1.4 KiB
Swift
@testable import SwiftLintBuiltInRules
|
|
import TestHelpers
|
|
|
|
final class DiscouragedDirectInitRuleTests: SwiftLintTestCase {
|
|
private let baseDescription = DiscouragedDirectInitRule.description
|
|
|
|
func testDiscouragedDirectInitWithConfiguredSeverity() {
|
|
verifyRule(baseDescription, ruleConfiguration: ["severity": "error"])
|
|
}
|
|
|
|
func testDiscouragedDirectInitWithNewIncludedTypes() {
|
|
let triggeringExamples = [
|
|
Example("let foo = ↓Foo()"),
|
|
Example("let bar = ↓Bar()"),
|
|
]
|
|
|
|
let nonTriggeringExamples = [
|
|
Example("let foo = Foo(arg: toto)"),
|
|
Example("let bar = Bar(arg: \"toto\")"),
|
|
]
|
|
|
|
let description = baseDescription
|
|
.with(triggeringExamples: triggeringExamples)
|
|
.with(nonTriggeringExamples: nonTriggeringExamples)
|
|
|
|
verifyRule(description, ruleConfiguration: ["types": ["Foo", "Bar"]])
|
|
}
|
|
|
|
func testDiscouragedDirectInitWithReplacedTypes() {
|
|
let triggeringExamples = [
|
|
Example("let bundle = ↓Bundle()")
|
|
]
|
|
|
|
let nonTriggeringExamples = [
|
|
Example("let device = UIDevice()")
|
|
]
|
|
|
|
let description = baseDescription
|
|
.with(triggeringExamples: triggeringExamples)
|
|
.with(nonTriggeringExamples: nonTriggeringExamples)
|
|
|
|
verifyRule(description, ruleConfiguration: ["types": ["Bundle"]])
|
|
}
|
|
}
|