Sha256: 5f34b5e94c8fa4b624ab0689d44b55c1c34fa2b49d59d57342ef3f9ff4f6493b
Contents?: true
Size: 950 Bytes
Versions: 6
Compression:
Stored size: 950 Bytes
Contents
# encoding: utf-8 # frozen_string_literal: true module RuboCop module Cop # Common functionality for checking if nodes. module IfNode def ternary?(node) node.loc.respond_to?(:question) end def modifier_if?(node) node.loc.respond_to?(:keyword) && %w(if unless).include?(node.loc.keyword.source) && node.modifier_form? 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
6 entries across 6 versions & 2 rubygems