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

Limit SafeNavigation #5606

Merged
merged 3 commits into from
Mar 3, 2018
Merged

Limit SafeNavigation #5606

merged 3 commits into from
Mar 3, 2018

Conversation

rrosenblum
Copy link
Contributor

This addresses the changes mentioned in #5595. I will start working on a separate cop to handle consistent usage of safe navigation on all sides of && and ||.

@@ -41,6 +41,8 @@ module Style
# foo&.bar(param1, param2)
# foo&.bar { |e| e.something }
# foo&.bar(param) { |e| e.something }
# foo && foo.bar.baz.qux # method chain with more than 2 methods
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you should mention this in free text in the cop description as well.

@rrosenblum
Copy link
Contributor Author

@bbatsov one more thought that I had for Lint/SafeNavigationChain is to change the offense location from the next method, :selector, to the rest of the expression. Let me know if I should make this change.

@bbatsov
Copy link
Collaborator

bbatsov commented Feb 28, 2018

Yeah, this makes sense.

@rrosenblum
Copy link
Contributor Author

Updated with new highlighting. The method_chain method might be useful to have on SendNode.

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

Successfully merging this pull request may close these issues.

None yet

2 participants