Sha256: e54328ffaf823e257343231ec8e003dc893fcbc6f1a42151a17a578db89d1b12

Contents?: true

Size: 518 Bytes

Versions: 15

Compression:

Stored size: 518 Bytes

Contents

# encoding: utf-8

module RuboCop
  module Cop
    module Style
      # TODO: Make configurable.
      # Checks for uses of if/then/else/end on a single line.
      class OneLineConditional < Cop
        include OnNormalIfUnless

        MSG = 'Favor the ternary operator (?:) ' \
              'over if/then/else/end constructs.'

        def on_normal_if_unless(node)
          return if node.loc.expression.source.include?("\n")
          add_offense(node, :expression, MSG)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/style/one_line_conditional.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.32.1 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.32.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.31.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.30.1 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.30.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.29.1 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.29.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.28.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.27.1 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.27.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.26.1 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.26.0 lib/rubocop/cop/style/one_line_conditional.rb
rubocop-0.25.0 lib/rubocop/cop/style/one_line_conditional.rb