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 guideline for using safe operator. #912

Merged
merged 7 commits into from
Dec 29, 2022
Merged

Conversation

Gauravpurohit409
Copy link
Contributor

#889 - Add guidance for safe navigation operator (&.)
Based on the 889 issue added guidelines for using safe navigation operators using some resources from the thought bot.

The idea here is to not use a safe navigation operator in unnecessary chaining which may lead to confusion to the reader regarding the existence of the object instead use delegation.

NOTE: This is my first pr so if there is any suggestion please let me know thanks in advance :).

@@ -323,6 +323,29 @@ foo&. bar
foo&.bar
----

=== Safe navigation
Copy link
Member

Choose a reason for hiding this comment

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

I'd argue regarding the section, Source code layout.
Maybe it would be a better fit for Misc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you elaborate more regarding this comment?

Copy link
Member

Choose a reason for hiding this comment

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

If I'm not mistaken, presently this new guideline resides in the "Source code layout" section. This section is mostly all about whitespace, formatting, those things that don't change code semantics.

The new guideline suggests code changes that may, depending on constraints, change its behaviour.

Basing on this observation, I propose moving this new guideline to a different section. I don't have a better section in mind, so I suggested "Misc".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it

add language name along with source.
Copy link
Member

@pirj pirj left a comment

Choose a reason for hiding this comment

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

Thank you!

@pirj pirj requested a review from a team December 29, 2022 07:52
@pirj pirj merged commit 7e54062 into rubocop:master Dec 29, 2022
@pirj
Copy link
Member

pirj commented Dec 29, 2022

Thank you, @Gauravpurohit409 !

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.

3 participants