Class: RuboCop::Cop::OpenHAB::StatePredicate
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::OpenHAB::StatePredicate
- Defined in:
- lib/rubocop/cop/openhab/state_predicate.rb
Overview
When comparing against named states and commands, prefer predicate methods.
Constant Summary collapse
- MSG =
"Use `%<predicate>s?` instead of `== %<constant>s`."
- METHODS =
%i[ REFRESH OPEN CLOSED ON OFF INCREASE DECREASE UP DOWN STOP MOVE PLAYING PAUSED REWINDING FASTFORWARDING PLAY PAUSE REWIND FASTFORWARD NEXT PREVIOUS ].to_set.freeze
Instance Method Summary collapse
Instance Method Details
#message(constant) ⇒ Object
51 52 53 |
# File 'lib/rubocop/cop/openhab/state_predicate.rb', line 51 def (constant) format(MSG, predicate: constant.downcase, constant: constant) end |
#on_send(node) ⇒ Object
55 56 57 |
# File 'lib/rubocop/cop/openhab/state_predicate.rb', line 55 def on_send(node) bad_comparison?(node) { |constant| add_offense(node, message: (constant)) } end |