Class: RuboCop::Cop::RSpec::AvoidBeTruthy
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::RSpec::AvoidBeTruthy
- Defined in:
- lib/rubocop/cop/rspec/avoid_be_truthy.rb
Overview
Constant Summary collapse
- MSG =
"Use `#be true` instead of `#be_truthy`."- RESTRICT_ON_SEND =
i[be_truthy].freeze
Instance Method Summary collapse
- #be_truthy?(node) ⇒ Object
-
#on_send(node) ⇒ Object
(also: #on_csend)
Called on every
sendnode (method call) while walking the AST.
Instance Method Details
#be_truthy?(node) ⇒ Object
25 26 27 |
# File 'lib/rubocop/cop/rspec/avoid_be_truthy.rb', line 25 def_node_matcher :be_truthy?, "(send nil? :be_truthy ...)\n" |
#on_send(node) ⇒ Object Also known as: on_csend
Called on every send node (method call) while walking the AST.
TODO: remove this method if inspecting send nodes is unneeded for your cop.
By default, this is aliased to on_csend as well to handle method calls
with safe navigation, remove the alias if this is unnecessary.
If kept, ensure your tests cover safe navigation as well!
34 35 36 37 38 |
# File 'lib/rubocop/cop/rspec/avoid_be_truthy.rb', line 34 def on_send(node) return unless be_truthy?(node) add_offense(node) end |