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`
67 lines
1.8 KiB
Swift
67 lines
1.8 KiB
Swift
@testable import SwiftLintBuiltInRules
|
|
import TestHelpers
|
|
|
|
final class UnneededOverrideRuleTests: SwiftLintTestCase {
|
|
func testIncludeAffectInits() {
|
|
let nonTriggeringExamples = [
|
|
Example("""
|
|
override init() {
|
|
super.init(frame: .zero)
|
|
}
|
|
"""),
|
|
Example("""
|
|
override init?() {
|
|
super.init()
|
|
}
|
|
"""),
|
|
Example("""
|
|
override init!() {
|
|
super.init()
|
|
}
|
|
"""),
|
|
Example("""
|
|
private override init() {
|
|
super.init()
|
|
}
|
|
"""),
|
|
] + UnneededOverrideRuleExamples.nonTriggeringExamples
|
|
|
|
let triggeringExamples = [
|
|
Example("""
|
|
class Foo {
|
|
↓override init() {
|
|
super.init()
|
|
}
|
|
}
|
|
"""),
|
|
Example("""
|
|
class Foo {
|
|
↓public override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
}
|
|
}
|
|
"""),
|
|
]
|
|
|
|
let corrections = [
|
|
Example("""
|
|
class Foo {
|
|
↓override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
}
|
|
}
|
|
"""): Example("""
|
|
class Foo {
|
|
}
|
|
"""),
|
|
]
|
|
|
|
let description = UnneededOverrideRule.description
|
|
.with(nonTriggeringExamples: nonTriggeringExamples)
|
|
.with(triggeringExamples: triggeringExamples)
|
|
.with(corrections: corrections)
|
|
|
|
verifyRule(description, ruleConfiguration: ["affect_initializers": true])
|
|
}
|
|
}
|