Sha256: 48f4a494e9ad76d3ec61774d8e4414dbda437d7b1ff33d7819a5af1c20435491

Contents?: true

Size: 719 Bytes

Versions: 6836

Compression:

Stored size: 719 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.source_range,
                              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

6,836 entries across 6,811 versions & 27 rubygems

Version Path
ory-kratos-client-0.7.6.alpha3 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
ory-kratos-client-0.7.6.alpha1 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
ory-kratos-client-0.7.5.alpha2 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
mx-platform-ruby-0.4.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
mx-platform-ruby-0.3.2 vendor/bundle/ruby/2.6.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
mx-platform-ruby-0.3.1 vendor/bundle/ruby/2.6.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
passbase-1.3.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
mfk_openapi_ruby_client-1.0.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
passbase-1.2.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
passbase-1.1.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
passbase-1.0.3 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
passbase-1.0.2 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
passbase-1.0.1 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
passbase-1.0.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/cop/correctors/condition_corrector.rb
talon_one-2.0.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
talon_one-2.0.0 vendor/bundle/ruby/2.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/condition_corrector.rb
rubocop-0.81.0 lib/rubocop/cop/correctors/condition_corrector.rb
rubocop-0.80.1 lib/rubocop/cop/correctors/condition_corrector.rb
rubocop-0.80.0 lib/rubocop/cop/correctors/condition_corrector.rb