Sha256: 81918466e1ebe54f18b3c45589d27147e465dfb3118a6a64192a726ce924ec95

Contents?: true

Size: 471 Bytes

Versions: 6

Compression:

Stored size: 471 Bytes

Contents

# encoding: utf-8

module RuboCop
  module Cop
    module Style
      # Checks for uses of semicolon in if statements.
      class IfWithSemicolon < Cop
        include OnNormalIfUnless

        MSG = 'Never use if x; Use the ternary operator instead.'

        def on_normal_if_unless(node)
          beginning = node.loc.begin
          return unless beginning && beginning.is?(';')
          add_offense(node, :expression, MSG)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/style/if_with_semicolon.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/style/if_with_semicolon.rb
rubocop-0.27.0 lib/rubocop/cop/style/if_with_semicolon.rb
rubocop-0.26.1 lib/rubocop/cop/style/if_with_semicolon.rb
rubocop-0.26.0 lib/rubocop/cop/style/if_with_semicolon.rb
rubocop-0.25.0 lib/rubocop/cop/style/if_with_semicolon.rb