BigW Consortium Gitlab

Allow comment after if/unless clause

Signed-off-by: 's avatarRémy Coutable <remy@rymai.me>
parent 2b8eb727
...@@ -95,7 +95,7 @@ module RuboCop ...@@ -95,7 +95,7 @@ module RuboCop
end end
def end_clause_line?(line) def end_clause_line?(line)
line =~ /^\s*(rescue|else|elsif|when)/ line =~ /^\s*(#|rescue|else|elsif|when)/
end end
def begin_line?(line) def begin_line?(line)
......
...@@ -256,6 +256,18 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do ...@@ -256,6 +256,18 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
expect(cop.offenses).to be_empty expect(cop.offenses).to be_empty
end 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 it "doesn't flag violation for #{conditional} followed by an end" do
source = <<~RUBY source = <<~RUBY
class Foo class Foo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment