Betterment / betterlint

MIT License
41 stars 15 forks source link

Disable Style/IfUnlessModifier #17

Closed rzane closed 1 year ago

rzane commented 1 year ago

The Style/IfUnlessModifier encourages us to use the modifier form of if or unless.

# bad
if ready?
  perform_action!
end

# good
perform_action! if ready?

Generally, I think most people agree with this. However, our Layout/LineLength is set to a very generous 140. So, Rubocop would also encourage us to put this on one line:

# rubocop says bad?
unless user.profile_configuration.ready?
  redirect_to user_profile_configuration_path, flash: { error: "We're setting up your profile." }
end

# rubocop says good?
redirect_to user_profile_configuration_path, flash: { error: "We're setting up your profile." } unless user.profile_configuration.ready?

As a reader, these conditionals are the most important thing for me to see. I think we should leave the decision to use a modifier up to the author.

samandmoore commented 1 year ago

Huge fan of this change.

rzane commented 1 year ago

I always forget to bump the version 🤦