Sha256: 14e117fcf236940a8c39222dedf22fdf95db35c5dfc5495d0c5933b0d1650eec

Contents?: true

Size: 930 Bytes

Versions: 6956

Compression:

Stored size: 930 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # Checks for uses of while with a negated condition.
      #
      # @example
      #   # bad
      #   while !foo
      #     bar
      #   end
      #
      #   # good
      #   until foo
      #     bar
      #   end
      #
      #   # bad
      #   bar until !foo
      #
      #   # good
      #   bar while foo
      #   bar while !foo && baz
      class NegatedWhile < Cop
        include NegativeConditional

        def on_while(node)
          check_negative_conditional(node)
        end

        def on_until(node)
          check_negative_conditional(node)
        end

        def autocorrect(node)
          ConditionCorrector.correct_negative_condition(node)
        end

        private

        def message(node)
          format(MSG, inverse: node.inverse_keyword, current: node.keyword)
        end
      end
    end
  end
end

Version data entries

6,956 entries across 6,931 versions & 30 rubygems

Version Path
passbase-1.0.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/negated_while.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/cop/style/negated_while.rb
rubocop-0.89.1 lib/rubocop/cop/style/negated_while.rb
rubocop-0.89.0 lib/rubocop/cop/style/negated_while.rb
rubocop-0.88.0 lib/rubocop/cop/style/negated_while.rb
rbhint-0.87.1.rc1 lib/rubocop/cop/style/negated_while.rb
rubocop-0.87.1 lib/rubocop/cop/style/negated_while.rb
rubocop-0.87.0 lib/rubocop/cop/style/negated_while.rb
rubocop-0.86.0 lib/rubocop/cop/style/negated_while.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/rubocop-0.85.1/lib/rubocop/cop/style/negated_while.rb
rbhint-0.85.1.rc2 lib/rubocop/cop/style/negated_while.rb
rbhint-0.85.1.rc1 lib/rubocop/cop/style/negated_while.rb
rubocop-0.85.1 lib/rubocop/cop/style/negated_while.rb
rbhint-0.8.5.rc1 lib/rubocop/cop/style/negated_while.rb
rubocop-0.85.0 lib/rubocop/cop/style/negated_while.rb
rubocop-0.84.0 lib/rubocop/cop/style/negated_while.rb
rubocop-0.83.0 lib/rubocop/cop/style/negated_while.rb
rubocop-0.82.0 lib/rubocop/cop/style/negated_while.rb
talon_one-2.0.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/negated_while.rb
talon_one-2.0.0 vendor/bundle/ruby/2.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/negated_while.rb