Skip to content

Commit

Permalink
Fix Style/RedundantBegin: begin-end in a proc literal
Browse files Browse the repository at this point in the history
closes #80
  • Loading branch information
veelenga committed Sep 22, 2018
1 parent d7b0e10 commit 12aa48c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions spec/ameba/rule/style/redundant_begin_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ module Ameba::Rule::Style
subject.catch(s).should_not be_valid
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
s = Source.new %q(
def method
Expand Down
2 changes: 1 addition & 1 deletion src/ameba/rule/style/redundant_begin.cr
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ module Ameba::Rule::Style
token = lexer.next_token

case token.type
when :EOF
when :EOF, :"->"
break
when :IDENT
return token.value == :begin if in_body?
Expand Down

0 comments on commit 12aa48c

Please sign in to comment.