mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
parent
3e099e9afc
commit
3887da1438
2 changed files with 7 additions and 3 deletions
|
@ -153,7 +153,7 @@ module Ameba::Rule
|
|||
subject.catch(s).should_not be_valid
|
||||
end
|
||||
|
||||
it "fails if there is an inner redundant block" do
|
||||
it "doesn't report if there is an inner redundant block" do
|
||||
s = Source.new %q(
|
||||
def method
|
||||
begin
|
||||
|
@ -164,7 +164,7 @@ module Ameba::Rule
|
|||
rescue
|
||||
end
|
||||
)
|
||||
subject.catch(s).should_not be_valid
|
||||
subject.catch(s).should be_valid
|
||||
end
|
||||
|
||||
it "fails if there is a redundant block with yield" do
|
||||
|
|
|
@ -88,7 +88,7 @@ module Ameba::Rule
|
|||
end
|
||||
|
||||
private def redundant_begin_in_handler?(source, handler, node)
|
||||
return false if begin_exprs_in_handler?(handler)
|
||||
return false if begin_exprs_in_handler?(handler) || inner_handler?(handler)
|
||||
|
||||
code = node_source(node, source.lines).try &.join("\n")
|
||||
def_redundant_begin? code if code
|
||||
|
@ -96,6 +96,10 @@ module Ameba::Rule
|
|||
false
|
||||
end
|
||||
|
||||
private def inner_handler?(handler)
|
||||
handler.body.is_a?(Crystal::ExceptionHandler)
|
||||
end
|
||||
|
||||
private def begin_exprs_in_handler?(handler)
|
||||
if (body = handler.body).is_a?(Crystal::Expressions)
|
||||
exception_handler?(body.expressions.first)
|
||||
|
|
Loading…
Reference in a new issue