mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
66 lines
1.7 KiB
Swift
66 lines
1.7 KiB
Swift
@testable import SwiftLintBuiltInRules
|
|
|
|
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])
|
|
}
|
|
}
|