Allow comment after if/unless clause

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2018-05-28 15:00:09 +02:00
parent 2b8eb7273e
commit 1c5106fadf
No known key found for this signature in database
GPG key ID: 98DFFD1C0C62B70B
2 changed files with 13 additions and 1 deletions

View file

@ -95,7 +95,7 @@ module RuboCop
end
def end_clause_line?(line)
line =~ /^\s*(rescue|else|elsif|when)/
line =~ /^\s*(#|rescue|else|elsif|when)/
end
def begin_line?(line)

View file

@ -256,6 +256,18 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} followed by a comment" do
source = <<~RUBY
#{conditional} condition
do_something
end
# a short comment
RUBY
inspect_source(source)
expect(cop.offenses).to be_empty
end
it "doesn't flag violation for #{conditional} followed by an end" do
source = <<~RUBY
class Foo