-
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 ExplicitInitRule #715
Add ExplicitInitRule #715
Conversation
Current coverage is 88.64% (diff: 100%)
|
Do people really write |
I've seen some people at work do it, especially developers migrating from Obj-C. Also I think it might be because of Xcode autocomplete combined with laziness. Which is why I want to enforce with this rule on everybody. What do you think about:
|
We could make this opt-in. I'm generally more ok with false positives with opt-in rules. Don't special case NSURL, there's nothing unique about it when it comes to using its initializer as a function reference. |
@jpsim made this rule opt-in / correctable, lmk what you think |
@@ -10,6 +10,10 @@ | |||
[bootstraponline](https://github.com/bootstraponline) | |||
[#689](https://github.com/realm/SwiftLint/issues/689) | |||
|
|||
* Add ExplicitInitRule. |
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.
missing two trailing spaces according to the guidelines at https://github.com/realm/SwiftLint/blob/master/CONTRIBUTING.md#tracking-changes
I'm still pretty dubious of the value of such a rule, but since it's opt-in and if some find it useful, then why not. @mtaube please address my latest round of comments and rebase this so I can review again. |
@jpsim made those changes. Lmk if anything else is needed. Thanks for SwiftLint / Realm by the way – we use both at work. |
Thanks for doing this! 🙏 |
Hey guys, I added a quick rule to discourage the explicit use of
init
(#672). The current implementation only catchesinit
s that are prefixed by a well-formed class / struct name.