Sha256: 52bf2eb434a93811fc27181eeed942decd229529fa683d222d2680524324b3af

Contents?: true

Size: 610 Bytes

Versions: 4

Compression:

Stored size: 610 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # Common functionality for cops checking if and unless statements.
      module IfThenElse
        def on_if(node)
          check(node)
        end

        def on_unless(node)
          check(node)
        end

        def check(node)
          # We won't check modifier or ternary conditionals.
          if node.loc.expression.source =~ /\A(if|unless)\b/
            if offending_line(node)
              add_offence(:convention, node.loc.expression, error_message)
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.12.0 lib/rubocop/cop/style/if_then_else.rb
rubocop-0.11.1 lib/rubocop/cop/style/if_then_else.rb
rubocop-0.11.0 lib/rubocop/cop/style/if_then_else.rb
rubocop-0.10.0 lib/rubocop/cop/style/if_then_else.rb