mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Compress identical method definitions
This commit is contained in:
parent
b79f3e6e07
commit
a8f953a2b2
6 changed files with 6 additions and 51 deletions
|
@ -52,11 +52,7 @@ module Ameba::Rule::Lint
|
|||
check_node(source, node, node.block)
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::While)
|
||||
check_node(source, node, node.body) if literal?(node.cond)
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::Until)
|
||||
def test(source, node : Crystal::While | Crystal::Until)
|
||||
check_node(source, node, node.body) if literal?(node.cond)
|
||||
end
|
||||
|
||||
|
|
|
@ -33,15 +33,7 @@ module Ameba::Rule::Lint
|
|||
issue_for node, MSG if static_literal?(node.cond)
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::If)
|
||||
check_node source, node
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::Unless)
|
||||
check_node source, node
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::Case)
|
||||
def test(source, node : Crystal::If | Crystal::Unless | Crystal::Case)
|
||||
check_node source, node
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,11 +45,7 @@ module Ameba::Rule::Lint
|
|||
]
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::ProcLiteral, scope : AST::Scope)
|
||||
find_shadowing source, scope
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::Block, scope : AST::Scope)
|
||||
def test(source, node : Crystal::ProcLiteral | Crystal::Block, scope : AST::Scope)
|
||||
find_shadowing source, scope
|
||||
end
|
||||
|
||||
|
|
|
@ -61,12 +61,7 @@ module Ameba::Rule::Lint
|
|||
@parent.accept self
|
||||
end
|
||||
|
||||
def visit(node : Crystal::If)
|
||||
@rule.check_node(@source, @parent, node.cond)
|
||||
true
|
||||
end
|
||||
|
||||
def visit(node : Crystal::Unless)
|
||||
def visit(node : Crystal::If | Crystal::Unless)
|
||||
@rule.check_node(@source, @parent, node.cond)
|
||||
true
|
||||
end
|
||||
|
|
|
@ -66,23 +66,7 @@ module Ameba::Rule::Style
|
|||
issue_for node, MSG % {expected, name}
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::ClassDef)
|
||||
check_node(source, node)
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::Alias)
|
||||
check_node(source, node)
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::LibDef)
|
||||
check_node(source, node)
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::EnumDef)
|
||||
check_node(source, node)
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::ModuleDef)
|
||||
def test(source, node : Crystal::Alias | Crystal::ClassDef | Crystal::ModuleDef | Crystal::LibDef | Crystal::EnumDef)
|
||||
check_node(source, node)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,15 +39,7 @@ module Ameba::Rule::Style
|
|||
VarVisitor.new self, source
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::Var)
|
||||
check_node source, node
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::InstanceVar)
|
||||
check_node source, node
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::ClassVar)
|
||||
def test(source, node : Crystal::Var | Crystal::InstanceVar | Crystal::ClassVar)
|
||||
check_node source, node
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue