Class: RuboCop::Cop::UmtsCustomCops::PredicateMethodMatcher
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::UmtsCustomCops::PredicateMethodMatcher
- Defined in:
- lib/umts-custom-cops/predicate_method_matcher.rb
Overview
See the specs for examples.
Constant Summary collapse
- MESSAGE =
'Prefer predicate matcher over checking the return value of a predicate method.'
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/umts-custom-cops/predicate_method_matcher.rb', line 33 def on_send(node) ends_with_question_mark = ->(method) { method.to_s.end_with? '?' } if generic_equality_expectation(node, &ends_with_question_mark) || boolean_equality_expectation(node, &ends_with_question_mark) add_offense node, location: :expression, message: MESSAGE end end |