Sha256: 59d407694afbb21c6deb44277cb49a8742bb29bd199d7b1e1c0f32abdd7412fa

Contents?: true

Size: 506 Bytes

Versions: 13

Compression:

Stored size: 506 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    class UnlessElse < Cop
      ERROR_MESSAGE = 'Never use unless with else. Rewrite these with the ' +
        'positive case first.'

      def inspect(file, source, tokens, sexp)
        each(:unless, sexp) do |unless_sexp|
          if unless_sexp.compact.find { |s| s[0] == :else }
            add_offence(:convention, all_positions(unless_sexp).first.lineno,
                        ERROR_MESSAGE)
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rubocop-0.6.1 lib/rubocop/cop/unless_else.rb
rubocop-0.6.0 lib/rubocop/cop/unless_else.rb
rubocop-0.5.0 lib/rubocop/cop/unless_else.rb
rubocop-0.4.6 lib/rubocop/cop/unless_else.rb
rubocop-0.4.5 lib/rubocop/cop/unless_else.rb
rubocop-0.4.4 lib/rubocop/cop/unless_else.rb
rubocop-0.4.3 lib/rubocop/cop/unless_else.rb
rubocop-0.4.2 lib/rubocop/cop/unless_else.rb
rubocop-0.4.1 lib/rubocop/cop/unless_else.rb
rubocop-0.4.0 lib/rubocop/cop/unless_else.rb
rubocop-0.3.2 lib/rubocop/cop/unless_else.rb
rubocop-0.3.1 lib/rubocop/cop/unless_else.rb
rubocop-0.3.0 lib/rubocop/cop/unless_else.rb