Pattern: Use of count
instead of size
Issue: -
This rule is used to identify usages of count
on an Array
and Hash
and change them to size
.
# bad
[1, 2, 3].count
# bad
{a: 1, b: 2, c: 3}.count
# good
[1, 2, 3].size
# good
{a: 1, b: 2, c: 3}.size
# good
[1, 2, 3].count { |e| e > 2 }