Files
SwiftLint/Tests/BuiltInRulesTests/UnneededOverrideRuleTests.swift
Danny Mösch 15b285527a Separate built-in rule tests from framework tests (#5924)
* 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`
2024-12-30 12:26:46 +01:00

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])
}
}