-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unneeded_override rule #5139
Conversation
ad64295
to
f703595
Compare
8c0f207
to
86b8ed6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this!
Did you think about adding a rewriter removing the superfluous overrides when running in --fix
mode?
Also, don't forget the CHANGELOG entry. 😉
Source/SwiftLintBuiltInRules/Rules/Lint/UnneededOverrideRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/UnneededOverrideRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/UnneededOverrideRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/UnneededOverrideRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/UnneededOverrideRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/UnneededOverrideRuleExamples.swift
Outdated
Show resolved
Hide resolved
fde0577
to
21cccce
Compare
Thanks for the review! I implemented fixing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All triggering examples miss the violation marker ↓
.
Other than that, it seems to be good to go.
This rule flags functions where the only thing they do is call their super function and therefore could be omitted. For example: ```swift override func foo() { super.foo() } ``` This can get pretty complex since there are a lot of slight variations the subclasses' functions can call the superclasses' functions with, but this covers many of the cases. Ideally this would handle variable overrides too but it doesn't currently.
21cccce
to
171f125
Compare
This rule flags functions where the only thing they do is call their
super function and therefore could be omitted. For example:
This can get pretty complex since there are a lot of slight variations
the subclasses' functions can call the superclasses' functions with, but
this covers many of the cases. Ideally this would handle variable
overrides too but it doesn't currently.