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
Rubocop should not report a warning on a case block with an "empty when" if it also has an else block. This style is useful to indicate that in some cases/whens, no action is necessary.
Expected behavior
Rubocop should not report a warning on a case block with an "empty when" if it also has an else block.
Actual behavior
Rubocop reports a warning that an "empty when" exists:
$ rubocop temp.rb
Inspecting 1 file
W
Offenses:
temp.rb:9:1: W: Avoid when branches without a body.
when 'something else'
^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 1 offense detected
Steps to reproduce the problem
def handle_foo
puts 'foo'
end
input = 'foo'
case input
when 'foo'
handle_foo
when 'something else'
# nothing needs to happen
else
puts 'unexpected value!'
end
RuboCop version
Include the output of rubocop -V. Here's an example:
Fixesrubocop#3696 and rubocop#3754.
This PR add `AllowComments` option to `Lint/EmptyWhen` cop.
This option is enabled by default based on user feedback.
It is also the same default as the option of `Lint/SuppressedException`
set in rubocop#7805.
Rubocop should not report a warning on a case block with an "empty when" if it also has an else block. This style is useful to indicate that in some cases/whens, no action is necessary.
Expected behavior
Rubocop should not report a warning on a case block with an "empty when" if it also has an else block.
Actual behavior
Rubocop reports a warning that an "empty when" exists:
Steps to reproduce the problem
RuboCop version
Include the output of
rubocop -V
. Here's an example:The text was updated successfully, but these errors were encountered: