From cdf0405496c6b5e86e120550281f4540d3be38f1 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Thu, 1 Dec 2022 00:15:09 +0100 Subject: [PATCH] Refactor `Style/IsANil` rule to use newly added `path_named?` helper --- src/ameba/rule/style/is_a_nil.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ameba/rule/style/is_a_nil.cr b/src/ameba/rule/style/is_a_nil.cr index 72568b3a..8b075385 100644 --- a/src/ameba/rule/style/is_a_nil.cr +++ b/src/ameba/rule/style/is_a_nil.cr @@ -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