mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Simplify implementation of Lint/EmptyExpression
rule
This commit is contained in:
parent
8e86374d08
commit
3b79392ef2
1 changed files with 2 additions and 10 deletions
|
@ -34,19 +34,11 @@ module Ameba::Rule::Lint
|
|||
description "Disallows empty expressions"
|
||||
end
|
||||
|
||||
MSG = "Avoid empty expression %s"
|
||||
MSG_EXRS = "Avoid empty expressions"
|
||||
|
||||
def test(source, node : Crystal::NilLiteral)
|
||||
exp = node_source(node, source.lines)
|
||||
return if exp.in?(nil, "nil")
|
||||
|
||||
issue_for node, MSG % exp
|
||||
end
|
||||
MSG = "Avoid empty expressions"
|
||||
|
||||
def test(source, node : Crystal::Expressions)
|
||||
return unless node.expressions.size == 1 && node.expressions.first.nop?
|
||||
issue_for node, MSG_EXRS
|
||||
issue_for node, MSG
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue