class RuboCop::Cop::Performance::FixedSize
Do not compute the size of statically sized objects.
def contains_double_splat?(node)
def contains_double_splat?(node) return unless node.hash_type? node.children.any? do |child| child.respond_to?(:kwsplat_type?) && child.kwsplat_type? end end
def contains_splat?(node)
def contains_splat?(node) return unless node.array_type? node.children.any? do |child| child.respond_to?(:splat_type?) && child.splat_type? end end
def on_send(node)
def on_send(node) counter(node) do |variable, arg| return if contains_splat?(variable) return if contains_double_splat?(variable) return if !arg.nil? && string_argument?(arg.first) if node.parent return if node.parent.casgn_type? || node.parent.block_type? end add_offense(node, :expression) end end
def string_argument?(node)
def string_argument?(node) node && !node.str_type? end