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

Add guidance for safe navigation operator (&.) #889

Closed
andyw8 opened this issue Oct 14, 2021 · 3 comments
Closed

Add guidance for safe navigation operator (&.) #889

andyw8 opened this issue Oct 14, 2021 · 3 comments

Comments

@andyw8
Copy link
Contributor

andyw8 commented Oct 14, 2021

Reading https://thoughtbot.com/blog/ruby-safe-navigation reminded me that over-use of &. is common. I think it would be helpful to add a guideline such as:

Avoid long chains of &.. Replace with . if they introduce unnecessary conditional logic. Consider other approaches such as delegation.

This could also be added as a rule in RuboCop with a maximum number of chained calls (e.g. 2 or 3).

@bbatsov
Copy link
Collaborator

bbatsov commented Dec 26, 2021

Yeah, I agree. We should definitely add some guidelines about &..

@Gauravpurohit409
Copy link
Contributor

Created PR for it please review it #912

@pirj
Copy link
Member

pirj commented Nov 17, 2023

Fixed in #912

@pirj pirj closed this as completed Nov 17, 2023
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

4 participants