Sha256: 107621a02c6dae8e26b44252ccda622af8cc6c403a1b439f31c3009862d6418c

Contents?: true

Size: 881 Bytes

Versions: 276

Compression:

Stored size: 881 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 < Base
        include NegativeConditional
        extend AutoCorrector

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

          check_negative_conditional(node, message: message) do |corrector|
            ConditionCorrector.correct_negative_condition(corrector, node)
          end
        end
        alias on_until on_while
      end
    end
  end
end

Version data entries

276 entries across 267 versions & 26 rubygems

Version Path
rubocop-1.74.0 lib/rubocop/cop/style/negated_while.rb
rubocop-1.73.2 lib/rubocop/cop/style/negated_while.rb
siteimprove_api_client-1.0.1 vendor/bundle/ruby/3.2.0/gems/rubocop-1.73.1/lib/rubocop/cop/style/negated_while.rb
rubocop-1.73.1 lib/rubocop/cop/style/negated_while.rb
rubocop-1.73.0 lib/rubocop/cop/style/negated_while.rb
rubocop-1.72.2 lib/rubocop/cop/style/negated_while.rb
rubocop-1.72.1 lib/rubocop/cop/style/negated_while.rb
rubocop-1.72.0 lib/rubocop/cop/style/negated_while.rb
rubocop-1.71.2 lib/rubocop/cop/style/negated_while.rb
tailscale_middleware-0.0.3 vendor/cache/ruby/3.4.0/gems/rubocop-1.71.1/lib/rubocop/cop/style/negated_while.rb
rubocop-1.71.1 lib/rubocop/cop/style/negated_while.rb
rubocop-1.71.0 lib/rubocop/cop/style/negated_while.rb
rubocop-1.70.0 lib/rubocop/cop/style/negated_while.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/cop/style/negated_while.rb
rubocop-1.69.2 lib/rubocop/cop/style/negated_while.rb
rubocop-1.69.1 lib/rubocop/cop/style/negated_while.rb
rubocop-1.69.0 lib/rubocop/cop/style/negated_while.rb
rubocop-1.68.0 lib/rubocop/cop/style/negated_while.rb
rubocop-1.67.0 lib/rubocop/cop/style/negated_while.rb
rubocop-1.66.1 lib/rubocop/cop/style/negated_while.rb