Sha256: 117412c4d76560f5727c80e4dee82c88fd102f5ece848797f6c8be8a928c0540

Contents?: true

Size: 637 Bytes

Versions: 8

Compression:

Stored size: 637 Bytes

Contents

# encoding: utf-8

module RuboCop
  module Cop
    # Common functionality for checking if nodes.
    module IfNode
      def modifier_if?(node)
        node.loc.respond_to?(:keyword) &&
          %w(if unless).include?(node.loc.keyword.source) &&
          node.loc.respond_to?(:end) && node.loc.end.nil?
      end

      def ternary_op?(node)
        node.loc.respond_to?(:question)
      end

      def elsif?(node)
        node.loc.respond_to?(:keyword) && node.loc.keyword &&
          node.loc.keyword.is?('elsif')
      end

      def if_else?(node)
        node.loc.respond_to?(:else) && node.loc.else
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rubocop-0.31.0 lib/rubocop/cop/mixin/if_node.rb
rubocop-0.30.1 lib/rubocop/cop/mixin/if_node.rb
rubocop-0.30.0 lib/rubocop/cop/mixin/if_node.rb
rubocop-0.29.1 lib/rubocop/cop/mixin/if_node.rb
rubocop-0.29.0 lib/rubocop/cop/mixin/if_node.rb
rubocop-0.28.0 lib/rubocop/cop/mixin/if_node.rb
rubocop-0.27.1 lib/rubocop/cop/mixin/if_node.rb
rubocop-0.27.0 lib/rubocop/cop/mixin/if_node.rb