-
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
Make explicit_type_interface compatible with redundant_type_annotation #2312
Comments
IMO those rules are completely incompatible with each other by definition. Why do want to enable both? 🤔 |
IMO redundant_type_annotation is only to prevent listing the type twice (< 2) and explicit_type_interface on the other hand is here to make sure the type is listed at least once (>= 1). Both together ensure that the type is listed exactly once (== 1) – that's the use case. |
IMO |
Exactly. And I don't need it (for legibility) if the type is redundant, nor does the compiler, AFAIK. |
The compiler still needs it for performance. It doesn't know it's redundant. |
Yeah, for sure. I just thought it's like explicit types and initializers for implicit type checking are both But since you both seem not to be very understanding of combining those rules, I'll rather make this a configuration option. This way people who want to use both can opt-in to do so. |
This is reintroduced with 0.43 version for Bool warnings. https://github.com/realm/SwiftLint/pull/3438/files |
Currently when the two rules
explicit_type_interface
andredundant_type_annotation
are active, the most common way of writing a Singleton doesn't work any more. The following violates the ruleexplicit_type_interface
:When fixing it by explicitly stating the type, the code violates the rule
redundant_type_annotation
:While this could be fixed both ways, I think the rule
explicit_type_interface
is to be fixed here. Since the goal of it is to make clear what the type is and the type is the next thing right after the=
sign, I think this can be seen as a false positive. One could also make it an option, but since Singletons are very common and there's no real added value (correct me if I'm wrong) in stating the type explicitly again if the next thing to be seen is the exact same thing (that's exactly the point of the ruleredundant_type_annotation
), I think we should make it non-violating by default.The text was updated successfully, but these errors were encountered: