mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Refactor Style/IsANil
rule to use newly added path_named?
helper
This commit is contained in:
parent
f45d6a2ef0
commit
cdf0405496
1 changed files with 4 additions and 4 deletions
|
@ -20,19 +20,19 @@ module Ameba::Rule::Style
|
|||
# Enabled: true
|
||||
# ```
|
||||
class IsANil < Base
|
||||
include AST::Util
|
||||
|
||||
properties do
|
||||
description "Disallows calls to `is_a?(Nil)` in favor of `nil?`"
|
||||
end
|
||||
|
||||
MSG = "Use `nil?` instead of `is_a?(Nil)`"
|
||||
PATH_NIL_NAMES = %w(Nil)
|
||||
MSG = "Use `nil?` instead of `is_a?(Nil)`"
|
||||
|
||||
def test(source, node : Crystal::IsA)
|
||||
return if node.nil_check?
|
||||
|
||||
const = node.const
|
||||
return unless const.is_a?(Crystal::Path)
|
||||
return unless const.names == PATH_NIL_NAMES
|
||||
return unless path_named?(const, "Nil")
|
||||
|
||||
issue_for const, MSG
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue