diff --git a/lib/rubocop/cop/performance/chain_array_allocation.rb b/lib/rubocop/cop/performance/chain_array_allocation.rb index d422013c5..bf4364d62 100644 --- a/lib/rubocop/cop/performance/chain_array_allocation.rb +++ b/lib/rubocop/cop/performance/chain_array_allocation.rb @@ -45,6 +45,8 @@ class ChainArrayAllocation < Base RETURNS_NEW_ARRAY = (ALWAYS_RETURNS_NEW_ARRAY + RETURNS_NEW_ARRAY_WHEN_NO_BLOCK).freeze + RESTRICT_ON_SEND = RETURNS_NEW_ARRAY + MSG = 'Use unchained `%s` and `%s!` ' \ '(followed by `return array` if required) instead of chaining ' \ '`%s...%s`.' diff --git a/lib/rubocop/cop/performance/collection_literal_in_loop.rb b/lib/rubocop/cop/performance/collection_literal_in_loop.rb index 937c5e9ea..f75847a6b 100644 --- a/lib/rubocop/cop/performance/collection_literal_in_loop.rb +++ b/lib/rubocop/cop/performance/collection_literal_in_loop.rb @@ -65,6 +65,8 @@ class CollectionLiteralInLoop < Base HASH_METHODS = (ENUMERABLE_METHOD_NAMES | NONMUTATING_HASH_METHODS).to_set.freeze + RESTRICT_ON_SEND = ARRAY_METHODS + HASH_METHODS + def_node_matcher :kernel_loop?, <<~PATTERN (block (send {nil? (const nil? :Kernel)} :loop)