lib/rubocop/cop/rspec/predicate_matcher.rb in rubocop-rspec-1.18.0 vs lib/rubocop/cop/rspec/predicate_matcher.rb in rubocop-rspec-1.19.0
- old
+ new
@@ -10,29 +10,33 @@
private
def check_inflected(node)
predicate_in_actual?(node) do |predicate|
- add_offense(node, node.loc.expression, message_inflected(predicate))
+ add_offense(
+ node,
+ location: :expression,
+ message: message_inflected(predicate)
+ )
end
end
def_node_matcher :predicate_in_actual?, <<-PATTERN
(send
- (send nil :expect {
- (block $(send !nil #predicate? ...) ...)
- $(send !nil #predicate? ...)})
+ (send nil? :expect {
+ (block $(send !nil? #predicate? ...) ...)
+ $(send !nil? #predicate? ...)})
${:to :not_to :to_not}
$#boolean_matcher?)
PATTERN
def_node_matcher :be_bool?, <<-PATTERN
- (send nil {:be :eq :eql :equal} {true false})
+ (send nil? {:be :eq :eql :equal} {true false})
PATTERN
def_node_matcher :be_boolthy?, <<-PATTERN
- (send nil {:be_truthy :be_falsey :be_falsy :a_truthy_value :a_falsey_value :a_falsy_value})
+ (send nil? {:be_truthy :be_falsey :be_falsy :a_truthy_value :a_falsey_value :a_falsy_value})
PATTERN
def boolean_matcher?(node)
if cop_config['Strict']
be_boolthy?(node)
@@ -128,36 +132,44 @@
be_between be_within
].freeze
private
- def check_explicit(node)
+ def check_explicit(node) # rubocop:disable Metrics/MethodLength
predicate_matcher_block?(node) do |_actual, matcher|
- add_offense(node, :expression, message_explicit(matcher))
+ add_offense(
+ node,
+ location: :expression,
+ message: message_explicit(matcher)
+ )
ignore_node(node.children.first)
return
end
return if part_of_ignored_node?(node)
predicate_matcher?(node) do |_actual, matcher|
- add_offense(node, :expression, message_explicit(matcher))
+ add_offense(
+ node,
+ location: :expression,
+ message: message_explicit(matcher)
+ )
end
end
def_node_matcher :predicate_matcher?, <<-PATTERN
(send
- (send nil :expect $!nil)
+ (send nil? :expect $!nil?)
{:to :not_to :to_not}
- {$(send nil #predicate_matcher_name? ...)
- (block $(send nil #predicate_matcher_name? ...) ...)})
+ {$(send nil? #predicate_matcher_name? ...)
+ (block $(send nil? #predicate_matcher_name? ...) ...)})
PATTERN
def_node_matcher :predicate_matcher_block?, <<-PATTERN
(block
(send
- (send nil :expect $!nil)
+ (send nil? :expect $!nil?)
{:to :not_to :to_not}
- $(send nil #predicate_matcher_name?))
+ $(send nil? #predicate_matcher_name?))
...)
PATTERN
def predicate_matcher_name?(name)
name = name.to_s