Sha256: fc75f567f583b7d76084041dd7b46125fb7dbed8e301968a87ba5a286dc6d7a8

Contents?: true

Size: 458 Bytes

Versions: 12

Compression:

Stored size: 458 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # Checks for uses of if/then/else/end on a single line.
      class OneLineConditional < Cop
        include IfThenElse

        def offending_line(node)
          node.loc.expression.line unless node.loc.expression.source =~ /\n/
        end

        def error_message
          'Favor the ternary operator (?:) over if/then/else/end constructs.'
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
rubocop-0.16.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.15.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.14.1 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.14.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.13.1 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.13.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.12.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.11.1 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.11.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.10.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.9.1 lib/rubocop/cop/style/one_line_conditional.rb
sabat-rubocop-0.9.0 lib/rubocop/cop/style/one_line_conditional.rb