Sha256: d92c02a5b2b64b305a11281f0ae2b05f4cfbcc22a01ff7c6d3f66635d060b080
Contents?: true
Size: 569 Bytes
Versions: 7
Compression:
Stored size: 569 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop # Common code for ordinary arrays with [] that can be written with % # syntax. module ArraySyntax def array_of?(element_type, node) return false unless square_brackets?(node) array_elems = node.children # no need to check empty arrays return false unless array_elems && array_elems.size > 1 array_elems.all? { |e| e.type == element_type } end def square_brackets?(node) node.loc.begin && node.loc.begin.is?('[') end end end end
Version data entries
7 entries across 7 versions & 1 rubygems