mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Small refactor
This commit is contained in:
parent
7f6bd2289e
commit
b6f3d41211
2 changed files with 6 additions and 12 deletions
|
@ -58,16 +58,12 @@ module Ameba::Rule::Style
|
|||
|
||||
MSG = "Type name should be camelcased: %s, but it was %s"
|
||||
|
||||
private def check_node(source, node)
|
||||
def test(source, node : Crystal::Alias | Crystal::ClassDef | Crystal::ModuleDef | Crystal::LibDef | Crystal::EnumDef)
|
||||
name = node.name.to_s
|
||||
expected = name.camelcase
|
||||
return if name == expected
|
||||
|
||||
issue_for node, MSG % {expected, name}
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::Alias | Crystal::ClassDef | Crystal::ModuleDef | Crystal::LibDef | Crystal::EnumDef)
|
||||
check_node(source, node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,18 +29,16 @@ module Ameba::Rule::Style
|
|||
|
||||
MSG = "Var name should be underscore-cased: %s, not %s"
|
||||
|
||||
private def check_node(source, node)
|
||||
return if (expected = node.name.underscore) == node.name
|
||||
|
||||
issue_for node, MSG % {expected, node.name}
|
||||
end
|
||||
|
||||
def test(source : Source)
|
||||
VarVisitor.new self, source
|
||||
end
|
||||
|
||||
def test(source, node : Crystal::Var | Crystal::InstanceVar | Crystal::ClassVar)
|
||||
check_node source, node
|
||||
name = node.name.to_s
|
||||
expected = name.underscore
|
||||
return if name == expected
|
||||
|
||||
issue_for node, MSG % {expected, name}
|
||||
end
|
||||
|
||||
private class VarVisitor < AST::NodeVisitor
|
||||
|
|
Loading…
Reference in a new issue