Sha256: ace6edf19d5c34690da85eaebc41dc8e296de03990783de555b828eb10dc0efd

Contents?: true

Size: 670 Bytes

Versions: 8

Compression:

Stored size: 670 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # Checks for uses of while with a negated condition.
      class NegatedWhile < Cop
        include NegativeConditional

        MSG = 'Favor `%s` over `%s` for negative conditions.'.freeze

        def on_while(node)
          check_negative_conditional(node)
        end

        def on_until(node)
          check_negative_conditional(node)
        end

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

        private

        def autocorrect(node)
          negative_conditional_corrector(node)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rubocop-0.51.0 lib/rubocop/cop/style/negated_while.rb
rubocop-0.50.0 lib/rubocop/cop/style/negated_while.rb
rubocop-0.49.1 lib/rubocop/cop/style/negated_while.rb
rubocop-0.49.0 lib/rubocop/cop/style/negated_while.rb
rubocop-0.48.1 lib/rubocop/cop/style/negated_while.rb
rubocop-0.48.0 lib/rubocop/cop/style/negated_while.rb
rubocop-0.47.1 lib/rubocop/cop/style/negated_while.rb
rubocop-0.47.0 lib/rubocop/cop/style/negated_while.rb