lib/rubocop/cop/performance/chain_array_allocation.rb in rubocop-0.63.1 vs lib/rubocop/cop/performance/chain_array_allocation.rb in rubocop-0.64.0
- old
+ new
@@ -45,11 +45,12 @@
# These methods have a mutation alternative. For example :collect
# can be called as :collect!
HAS_MUTATION_ALTERNATIVE = ':collect :compact :flatten :map :reject '\
':reverse :rotate :select :shuffle :sort '\
':uniq '.freeze
- MSG = 'Use `%<method>s...%<second_method>s!` instead of `%<method>s' \
- '...%<second_method>s`.'.freeze
+ MSG = 'Use unchained `%<method>s!` and `%<second_method>s!` '\
+ '(followed by `return array` if required) instead of chaining '\
+ '`%<method>s...%<second_method>s`.'.freeze
def_node_matcher :flat_map_candidate?, <<-PATTERN
{
(send (send _ ${#{RETURN_NEW_ARRAY_WHEN_ARGS}} {int lvar ivar cvar gvar}) ${#{HAS_MUTATION_ALTERNATIVE}} $...)
(send (block (send _ ${#{ALWAYS_RETURNS_NEW_ARRAY} }) ...) ${#{HAS_MUTATION_ALTERNATIVE}} $...)