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.
The
Style/IfUnlessModifier
encourages us to use the modifier form of if or unless.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: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.