-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Style/SafeNavigation throws an offense and can autocorrect into a style that violates another cop (Lint/SafeNavigationChain) #4889
Comments
Looks like |
I think street.lines.first.to_s.strip.presence if street Then it auto-corrects it to this, which is broken and violates street&.lines.first.to_s.strip.presence To make it correct and satisfy both cops, I would need to change it to this: street&.lines&.first&.to_s&.strip.presence This is arguably slower and harder to read than the original. |
Yeah, essentially I don't think it’s correct for |
It's maybe a little oftop but that: |
I think that in normal cases we should not use more then one |
@Tab10id: I agree with you in principle, that the only function of the lonely operator is to make us feel better about bad code. However, it is the direction decided by the core team, so we'll have to work with it. We might be able to add some more cops that can be used by teams who want to prevent writing |
…o all methods in a chain
Code that violates
Style/SafeNavigation
:Auto-corrects to code that violates
Lint/SafeNavigationChain
:This is especially problematic because it’s a style cop auto-correcting to code that violates a lint cop. That is, it's recommending (or auto-correcting) code that works fine to code that actually does not work.
The text was updated successfully, but these errors were encountered: