Sha256: e0e7cee4e600754fcddec5f3d76efbaad05a8285b69989f1618c50a560c53cc7
Contents?: true
Size: 961 Bytes
Versions: 8
Compression:
Stored size: 961 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 def if_node_parts(node) case node.loc.keyword.source when 'if', 'elsif' then condition, body, else_clause = *node when 'unless' then condition, else_clause, body = *node else condition, body = *node end [condition, body, else_clause] end end end end
Version data entries
8 entries across 8 versions & 1 rubygems