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

Enable Style/IfWithBooleanLiteralBranches #551

Merged
merged 1 commit into from Jun 27, 2023

Conversation

nvasilevski
Copy link
Contributor

I find it really hard to find a reason for this rule to be disabled. It is very unlikely that in any situation a code like
is_admin = current_user.is_admin? ? true : false will be more readable than is_admin = is_admin

And even when the result is flipped like is_admin = current_user.ordinary_user? ? false : true an alternative - is_admin = !current_user.ordinary_user? looks much more readable to me

To be honest I even disagree that we should have anything in AllowedMethods since I find !!value.nonzero? to be much more readable than value.nonzero? ? true : false

@nvasilevski nvasilevski requested a review from a team as a code owner June 27, 2023 19:05
@github-actions github-actions bot added the config change Changes the Rubocop config by enabling, disabling, or reconfiguring one or many cops label Jun 27, 2023
Copy link
Member

@rafaelfranca rafaelfranca left a comment

Choose a reason for hiding this comment

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

I run this cop on Shopify/shopify and I saw no valid use case for using the disallowed style

Copy link
Contributor

@sambostock sambostock left a comment

Choose a reason for hiding this comment

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

I've been meaning to go and audit default cops we've disabled, and either enable them, or add a comment explaining why we've chosen to disable them.

@sambostock sambostock merged commit a5ce6e1 into main Jun 27, 2023
21 checks passed
@sambostock sambostock deleted the enable-IfWithBooleanLiteralBranches branch June 27, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config change Changes the Rubocop config by enabling, disabling, or reconfiguring one or many cops
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants