Update Implicit return to check if/switch for single expression#6310
Update Implicit return to check if/switch for single expression#6310nandhinisubbu wants to merge 4 commits intorealm:mainfrom
Conversation
…ent with single return expression
Generated by 🚫 Danger |
There was a problem hiding this comment.
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