-
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
Detect redundant extensions #5359
Comments
I would be interested in how regular you really stumble upon empty extensions. Have you seen this often, @inotetw? |
I often find the code such as following, may be my team coder use xcode template to generate code // MARK: UITableViewDelegate |
I will take on this Issue. |
Its a first attempt based on variable and function declarations. There are more cases that needs to be address as well. A part from variable and function declarations, extensions can have other declarations as well. Any suggestions? |
@mzeeshanid you could also check for type declarations (structs, enums, classes), and perhaps associated types and type aliases? Also idk if subscripts count as function declaration in SwiftSyntax but if not you could check for those as well 🙂 |
I found a 1 liner solution i.e. if memberBlock is empty then the extension is redundant. See the last commit :) |
Oh neat. Good one! 👏 |
… into redundant_extension * 'redundant_extension' of github.com:mzeeshanid/SwiftLint: - change log updated - change log updated - new example added - simplified logic - new case added in non triggering example - rule added for avoiding redundant extensions resolve realm#5359
New rule request
extension without any function will be avoid
Bad
The text was updated successfully, but these errors were encountered: