You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the rubocop autocorrect for the first time today. I am really impressed (by rubocop in general). But I managed to get in a situation where result is wrong (although using the safe-variant). My command was:
It seems that the 'Rails/Blank' and 'Style/UnlessElse' cops don't work together.
Are they meant to be? If not, at least a warning would be nice (and yes, reviewing automated changes is advisable in most cases, I know).
Thanks for any response!
# original
unless User.current.present?
# do some stuff
redirect_to :login
else
redirect_to :internal_route
end
# rubocop result
if User.current.blank?
redirect_to :internal_route
else
# do some stuff
redirect_to :login
end
# original
unless user.present?
redirect_to :login
else
redirect_to :internal_route
end
# rubocop result
if user.blank?
redirect_to :internal_route
else
redirect_to :login
end
This issue will apply to both Rails/Blank and Rails/Present.
Thanks for the bug report. The auto-correction of cops is typically only flagged as unsafe once we have a reasonable reason to do so.
The issue here happens because both cops register independent offenses and auto-correct independently. I think we can make Rails/Blank and Rails/Present aware of if Style/UnlessElse is enabled and avoid registering an offense for this situation. Essentially, disable the option for UnlessPresent and UnlessBlank if Style/UnlessElse is activated.
Hi,
I used the rubocop autocorrect for the first time today. I am really impressed (by rubocop in general). But I managed to get in a situation where result is wrong (although using the safe-variant). My command was:
rubocop --safe-auto-correct -c .rubocop.yml app/ lib/
It seems that the 'Rails/Blank' and 'Style/UnlessElse' cops don't work together.
Are they meant to be? If not, at least a warning would be nice (and yes, reviewing automated changes is advisable in most cases, I know).
Thanks for any response!
My rubocop.yml:
Steps to reproduce the problem
CnP the code in a file and run 'rubocop --safe-auto-correct -c .rubocop.yml FILE.rb' with my rubocop.yml.
RuboCop version
Tested with ruby 2.6.1 and rubocop 0.63.1 and 0.65.0
The text was updated successfully, but these errors were encountered: