Skip to content

Commit

Permalink
Respect configuration in unneeded_override rule's rewriter (#5579)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyDanny committed May 15, 2024
1 parent e84a6fc commit 40bee88
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
[SimplyDanny](https://github.com/SimplyDanny)
[#5573](https://github.com/realm/SwiftLint/issues/5573)

* Remove redundant initializers in `unneeded_override` rule only when checking
initializers is actually enabled in the configuration.
[SimplyDanny](https://github.com/SimplyDanny)
[#5571](https://github.com/realm/SwiftLint/issues/5571)

## 0.55.0: Universal Washing Powder

#### Breaking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private extension UnneededOverrideRule {
}

override func visit(_ node: InitializerDeclSyntax) -> DeclSyntax {
guard node.isUnneededOverride else {
guard configuration.affectInits, node.isUnneededOverride else {
return super.visit(node)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,21 @@ struct UnneededOverrideRuleExamples {
// This is another function
func baz() {}
}
"""),
// Nothing happens to initializers by default.
Example("""
class Foo {
↓override func foo() { super.foo() }
override init(i: Int) {
super.init(i: i)
}
}
"""): Example("""
class Foo {
override init(i: Int) {
super.init(i: i)
}
}
""")
]
}

0 comments on commit 40bee88

Please sign in to comment.