Fix Style/RedundantBegin: begin-end in a proc literal

closes #80
This commit is contained in:
Vitalii Elenhaupt 2018-09-22 21:58:38 +03:00
parent d7b0e10d1e
commit 12aa48c98f
No known key found for this signature in database
GPG key ID: 7558EF3A4056C706
2 changed files with 14 additions and 1 deletions

View file

@ -192,6 +192,19 @@ module Ameba::Rule::Style
subject.catch(s).should_not be_valid subject.catch(s).should_not be_valid
end end
it "doesn't report if begin-end block in a proc literal" do
s = Source.new %q(
foo = ->{
begin
raise "Foo!"
rescue ex
pp ex
end
}
)
subject.catch(s).should be_valid
end
it "reports rule, pos and message" do it "reports rule, pos and message" do
s = Source.new %q( s = Source.new %q(
def method def method

View file

@ -113,7 +113,7 @@ module Ameba::Rule::Style
token = lexer.next_token token = lexer.next_token
case token.type case token.type
when :EOF when :EOF, :"->"
break break
when :IDENT when :IDENT
return token.value == :begin if in_body? return token.value == :begin if in_body?