Skip to content
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

SafeNavigationChain doesn't see past blocks #5286

Closed
aquach opened this issue Dec 20, 2017 · 0 comments
Closed

SafeNavigationChain doesn't see past blocks #5286

aquach opened this issue Dec 20, 2017 · 0 comments

Comments

@aquach
Copy link

aquach commented Dec 20, 2017

Expected behavior

I expect this code to trigger SafeNavigationChain:

b&.select { true }.join

This should be corrected to

b&.select { true }&.join

Actual behavior

No offense is surfaced.

Steps to reproduce the problem

Try the example above.

RuboCop version

0.52.0 (using Parser 2.4.0.2, running on ruby 2.4.2 x86_64-linux)

This issue was exacerbated by autocorrect for SafeNavigation, which turned a && a.select {}.join into a&.select {}.join, which would be bad if a is nil. But I think the fault lies with SafeNavigationChain for not propagating that through. However, propagation is not always possible, such as in the case of a && a.select {}.length > 1 or a && a.select {}[0].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant