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
-a flag rewritten code incorrectly #5856
Comments
You said Can you be more specific about the how it changed the code's behavior? |
Having a closer look at this, in fact the transformation to Following line is rewritten: a = 'test'
if a.is_a? StandardError then true else false end into a = 'test'
a.is_a? StandardError ? true : false Which results in an error: a = 'test'
(a.is_a? StandardError) ? true : false |
@laplacesdemon Thanks for the clarification! Some details for the person who fixes this bug: note that this is the output of an
So I think the preferred syntax should be obj.is_a?(StandardError) ? maybe.add_error(obj) : maybe.add_value(obj) but I'm not sure which cop should be responsible. |
This sounds similar to other bugs that have been reported with |
Indeed it’s the same issue. Feel free to dupe it. |
I have an interesting problem. Rubocop has rewritten my code incorrectly. The piece of code reduces a list to an object using
inject
. I'm not a ruby master, in fact I rarely code in ruby and probably there's a better way to achieve what I was doing. But the resulting code after runningrubocop -a
did a different thing than the original one. See below:Original code:
Expected behavior
The code behavior should not change.
Actual behavior
here,
inject
becameeach_with_object
which does a different thing.Steps to reproduce the problem
RuboCop version
The text was updated successfully, but these errors were encountered: