Class: RuboCop::Cop::Ipepe::MultipleConditionUnless
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Ipepe::MultipleConditionUnless
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/ipepe/multiple_condition_unless.rb
Constant Summary collapse
- MSG =
"Use only one condition in unless or change to if".freeze
Instance Method Summary collapse
Instance Method Details
#on_if(node) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/rubocop/cop/ipepe/multiple_condition_unless.rb', line 8 def on_if(node) return unless node.unless? return unless node.condition.and_type? add_offense(node) do |corrector| # change `unless` to `if !(condition)` corrector.replace(node, "if !(#{node.condition.source})\n#{node.if_branch.source}\nend") end end |