Skip to content

Commit 664b6b0

Browse files
committed
Add missing RESTRICT_ON_SEND for two cops
For these, it is known on what methods they will operate
1 parent b83ff1e commit 664b6b0

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/rubocop/cop/performance/chain_array_allocation.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class ChainArrayAllocation < Base
4545

4646
RETURNS_NEW_ARRAY = (ALWAYS_RETURNS_NEW_ARRAY + RETURNS_NEW_ARRAY_WHEN_NO_BLOCK).freeze
4747

48+
RESTRICT_ON_SEND = RETURNS_NEW_ARRAY
49+
4850
MSG = 'Use unchained `%<method>s` and `%<second_method>s!` ' \
4951
'(followed by `return array` if required) instead of chaining ' \
5052
'`%<method>s...%<second_method>s`.'

lib/rubocop/cop/performance/collection_literal_in_loop.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class CollectionLiteralInLoop < Base
6565

6666
HASH_METHODS = (ENUMERABLE_METHOD_NAMES | NONMUTATING_HASH_METHODS).to_set.freeze
6767

68+
RESTRICT_ON_SEND = ARRAY_METHODS + HASH_METHODS
69+
6870
def_node_matcher :kernel_loop?, <<~PATTERN
6971
(block
7072
(send {nil? (const nil? :Kernel)} :loop)

0 commit comments

Comments
 (0)