class RuboCop::Cop::Performance::Size

have been assigned to an array or a hash.
TODO: Add advanced detection of variables that could
[1, 2, 3].count { |e| e > 2 }
# good
Hash(key: :value).size<br>Hash.size
[[:foo, :bar], [1, 2]].to_h.size
{a: 1, b: 2, c: 3}.size
# good<br><br>Array(1..3).size<br>Array.size
(1..3).to_a.size
[1, 2, 3].size
# good
Hash(key: :value).count<br>Hash.count
[[:foo, :bar], [1, 2]].to_h.count
{a: 1, b: 2, c: 3}.count
# bad<br><br>Array(1..3).count<br>Array.count
(1..3).to_a.count
[1, 2, 3].count
# bad
@example
Identifies usages of ‘count` on an `Array` and `Hash` and change them to `size`.

def on_send(node)

def on_send(node)
  return if node.parent&.block_type? || !count?(node)
  add_offense(node.loc.selector) do |corrector|
    corrector.replace(node.loc.selector, 'size')
  end
end