From 51b867515f94a3aea4554543d85b065f085b4777 Mon Sep 17 00:00:00 2001 From: Daniel Vandersluis Date: Mon, 27 Jan 2025 15:51:21 -0500 Subject: [PATCH] Use node groups in node patterns to replace unions of types `rubocop-ast` defines some node groups (https://github.com/rubocop/rubocop-ast/blob/85bfe84/lib/rubocop/ast/node.rb#L89-L116) that can be used in place of a union of node types. --- lib/rubocop/cop/rspec/be_eq.rb | 2 +- lib/rubocop/cop/rspec/be_eql.rb | 2 +- lib/rubocop/cop/rspec/predicate_matcher.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rubocop/cop/rspec/be_eq.rb b/lib/rubocop/cop/rspec/be_eq.rb index 4616762be..dfdcd7c5a 100644 --- a/lib/rubocop/cop/rspec/be_eq.rb +++ b/lib/rubocop/cop/rspec/be_eq.rb @@ -31,7 +31,7 @@ class BeEq < Base # @!method eq_type_with_identity?(node) def_node_matcher :eq_type_with_identity?, <<~PATTERN - (send nil? :eq {true false nil}) + (send nil? :eq {boolean nil}) PATTERN def on_send(node) diff --git a/lib/rubocop/cop/rspec/be_eql.rb b/lib/rubocop/cop/rspec/be_eql.rb index be9628471..f49a69231 100644 --- a/lib/rubocop/cop/rspec/be_eql.rb +++ b/lib/rubocop/cop/rspec/be_eql.rb @@ -45,7 +45,7 @@ class BeEql < Base # @!method eql_type_with_identity(node) def_node_matcher :eql_type_with_identity, <<~PATTERN - (send _ :to $(send nil? :eql {true false int float sym nil})) + (send _ :to $(send nil? :eql {boolean int float sym nil})) PATTERN def on_send(node) diff --git a/lib/rubocop/cop/rspec/predicate_matcher.rb b/lib/rubocop/cop/rspec/predicate_matcher.rb index a9b51e262..28ed70eb0 100644 --- a/lib/rubocop/cop/rspec/predicate_matcher.rb +++ b/lib/rubocop/cop/rspec/predicate_matcher.rb @@ -37,7 +37,7 @@ def check_inflected(node) # @!method be_bool?(node) def_node_matcher :be_bool?, <<~PATTERN - (send nil? {:be :eq :eql :equal} {true false}) + (send nil? {:be :eq :eql :equal} boolean) PATTERN # @!method be_boolthy?(node)