diff --git a/src/ameba/rule/lint/comparison_to_boolean.cr b/src/ameba/rule/lint/comparison_to_boolean.cr index 649d61a5..474cbc86 100644 --- a/src/ameba/rule/lint/comparison_to_boolean.cr +++ b/src/ameba/rule/lint/comparison_to_boolean.cr @@ -25,10 +25,11 @@ module Ameba::Rule::Lint description "Disallows comparison to booleans" end - MSG = "Comparison to a boolean is pointless" + MSG = "Comparison to a boolean is pointless" + OP_NAMES = %w(== != ===) def test(source, node : Crystal::Call) - comparison = %w(== != ===).includes?(node.name) + comparison = node.name.in?(OP_NAMES) to_boolean = node.args.first?.try &.is_a?(Crystal::BoolLiteral) || node.obj.is_a?(Crystal::BoolLiteral)