-
Notifications
You must be signed in to change notification settings - Fork 622
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
Rule idea: computed vars over functions with 0 arguments #1653
Comments
Unfortunately this isn't really feasible due to the need to change all the call sites. SwiftFormat only operates on a per-file basis, so it wouldn't know if a call to foo() in another file referred to the same function and needs to have the parens removed. Also, even if it were possible, I'm not sure it's a good idea. If foo() is just retrieving a value then it should be a property, but what about something like this method: func popLast() -> Element? { … } Here it's actually mutating the collection and returning the result. It wouldn't make sense to change that to a property. I suppose SwiftFormat could try to detect if the method name is a verb or noun and infer from that. Might work better as a SwiftLint rule in that case though. |
have generally always preferred computed variables over functions with 0 arguments, would be awesome to be able to enforce that:
don't prefer:
prefer:
The text was updated successfully, but these errors were encountered: