Sha256: 8c2dc51b460e790b344793a8db7e03077b41bba1fe718e1cdd5ae4d0e7e5ed2a

Contents?: true

Size: 676 Bytes

Versions: 16

Compression:

Stored size: 676 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # This class does condition auto-correction
    class ConditionCorrector
      class << self
        def correct_negative_condition(node)
          condition = negated_condition(node)

          lambda do |corrector|
            corrector.replace(node.loc.keyword, node.inverse_keyword)
            corrector.replace(condition, condition.children.first.source)
          end
        end

        private

        def negated_condition(node)
          condition = node.condition
          condition = condition.children.first while condition.begin_type?
          condition
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
rubocop-0.89.1 lib/rubocop/cop/correctors/condition_corrector.rb
rubocop-0.89.0 lib/rubocop/cop/correctors/condition_corrector.rb
rubocop-0.88.0 lib/rubocop/cop/correctors/condition_corrector.rb
rbhint-0.87.1.rc1 lib/rubocop/cop/correctors/condition_corrector.rb
rubocop-0.87.1 lib/rubocop/cop/correctors/condition_corrector.rb
rubocop-0.87.0 lib/rubocop/cop/correctors/condition_corrector.rb
rubocop-0.86.0 lib/rubocop/cop/correctors/condition_corrector.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/rubocop-0.85.1/lib/rubocop/cop/correctors/condition_corrector.rb
rbhint-0.85.1.rc2 lib/rubocop/cop/correctors/condition_corrector.rb
rbhint-0.85.1.rc1 lib/rubocop/cop/correctors/condition_corrector.rb
rubocop-0.85.1 lib/rubocop/cop/correctors/condition_corrector.rb
rbhint-0.8.5.rc1 lib/rubocop/cop/correctors/condition_corrector.rb
rubocop-0.85.0 lib/rubocop/cop/correctors/condition_corrector.rb
rubocop-0.84.0 lib/rubocop/cop/correctors/condition_corrector.rb
rubocop-0.83.0 lib/rubocop/cop/correctors/condition_corrector.rb
rubocop-0.82.0 lib/rubocop/cop/correctors/condition_corrector.rb