Skip to content

Commit

Permalink
[Fix rubocop#3696] modified empty_when lint to not warn when branches…
Browse files Browse the repository at this point in the history
… when body has comments
  • Loading branch information
kanth committed Nov 15, 2016
1 parent 5870837 commit 8e71773
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rubocop/cop/lint/empty_when.rb
Expand Up @@ -15,6 +15,10 @@ module Lint
class EmptyWhen < Cop
MSG = 'Avoid `when` branches without a body.'.freeze

def investigate(processed_source)
@processed_source = processed_source
end

def on_case(node)
_cond_node, *when_nodes, _else_node = *node

Expand Down
7 changes: 7 additions & 0 deletions spec/rubocop/cop/lint/empty_when_spec.rb
Expand Up @@ -47,6 +47,13 @@
'when :baz',
'end'].join("\n")

it_behaves_like 'code with offense',
['case foo',
'when :bar then 1',
'when :baz # nothing',
'else',
'end'].join("\n")

it_behaves_like 'code with offense',
['case foo',
'when :bar then 1',
Expand Down

0 comments on commit 8e71773

Please sign in to comment.