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
- state: (states.include? status) ? status : 'pending',
+ state: states.include? status ? status : 'pending',
And perhaps there are other, better, ways to write these lines.
Obviously, a "real" problem is that the parens are in the wrong place. It should be defined?(thing) instead of (defined? thing). It should be states.include?(status) instead of (states.include? status).
But it would be preferable to not attempt a bad autocorrect and just flag it as an error and let me sort it out myself.
Expected behavior
Should not attempt to autocorrect
Actual behavior
Attempts to autocorrect to invalid code
Steps to reproduce the problem
Have code which matches the above "-" lines, and then run rubocop -a
@benhutton: You are correct. We should never auto-correct in a way that breaks code, or changes its meaning.
I implemented this cop originally. I will see if I can fix this when I have time (which may or may not be anytime soon.) If someone else feels like giving it a go, please feel free to do so. 😀
…afe corrections
This cop, when configured to omit parentheses, would remove them even when the
condition contained an unparenthesized method call, e.g.:
```
foo = (bar? baz) ? 'Yes' : 'No'
```
which would change the semantics of the expression. This change fixes that.
…afe corrections (rubocop#3505)
This cop, when configured to omit parentheses, would remove them even when the
condition contained an unparenthesized method call, e.g.:
```
foo = (bar? baz) ? 'Yes' : 'No'
```
which would change the semantics of the expression. This change fixes that.
When updating to the latest rubocop version, we ran
rubocop -a
and ended up with two bad lines:And perhaps there are other, better, ways to write these lines.
Obviously, a "real" problem is that the parens are in the wrong place. It should be
defined?(thing)
instead of(defined? thing)
. It should bestates.include?(status)
instead of(states.include? status)
.But it would be preferable to not attempt a bad autocorrect and just flag it as an error and let me sort it out myself.
Expected behavior
Should not attempt to autocorrect
Actual behavior
Attempts to autocorrect to invalid code
Steps to reproduce the problem
Have code which matches the above "-" lines, and then run
rubocop -a
RuboCop version
Include the output of
rubocop -V
:The text was updated successfully, but these errors were encountered: