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
Hello. I've found a false positive of IfUnlessModifier for array elements with conditions.
You can write an array element with multi-line condition, and with one-line condition, but only with parentheses, without them there is a syntax error:
unexpected `if' modifier, expecting ']'
But IfUnlessModifier doesn't count this specific condition (for conditions), and offenses a multi-line condition, which can be placed into one line with syntax error, but with parentheses it already exceeds LineLength.
Expected behavior
No offenses for multi-line condition in array, which can't be placed into one line without LineLength offense.
rubocop/test.rb:2:3: C: Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
if foo
^^
[(bariffoo)]
rubocop/test.rb:2:8: C: Style/IfUnlessModifier: Modifier form of if makes the line too long.
(bar if foo)
^^
rubocop/test.rb:2:13: C: Layout/LineLength: Line is too long. [14/12]
(bar if foo)
^^
RuboCop version
Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:
Hello. I've found a false positive of
IfUnlessModifier
for array elements with conditions.You can write an array element with multi-line condition, and with one-line condition, but only with parentheses, without them there is a syntax error:
But
IfUnlessModifier
doesn't count this specific condition (for conditions), and offenses a multi-line condition, which can be placed into one line with syntax error, but with parentheses it already exceedsLineLength
.Expected behavior
No offenses for multi-line condition in array, which can't be placed into one line without
LineLength
offense.Actual behavior
There is a "fork" with offenses in any case.
Steps to reproduce the problem
RuboCop version
Include the output of
rubocop -V
orbundle exec rubocop -V
if using Bundler. Here's an example:The text was updated successfully, but these errors were encountered: