-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Update Implicit return to check if/switch for single expression #6310
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
base: main
Are you sure you want to change the base?
Conversation
…ent with single return expression
Generated by 🚫 Danger |
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.
That's cool. Thanks @nandhinisubbu!
Logically, this looks about right. Did you consider if expressions as the only statements in switch cases and vice versa? I think, there should be some kind of recursion to cover that.
With respect to code structure, I'd add all the functions with a single syntax node argument as computed properties to the syntax node itself. That also separates them a little from the rule's implementation, so that the visitor as the entry point is rather small and only provides the entry points.
Other than that, we should probably make checking of if and switch expression optional. I can imagine, not everyone wants to have them checked. Then, for SwiftLint itself, keep the option off and enable to only in a follow-up PR to separate the concerns.
Enhancement - #6167