Skip to content

Commit

Permalink
Merge pull request #487 from Earlopain/missing-restrict-on-send
Browse files Browse the repository at this point in the history
Add missing `RESTRICT_ON_SEND` for two cops
  • Loading branch information
koic authored Jan 25, 2025
2 parents b83ff1e + 664b6b0 commit 2f8ae50
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rubocop/cop/performance/chain_array_allocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 `%<method>s` and `%<second_method>s!` ' \
'(followed by `return array` if required) instead of chaining ' \
'`%<method>s...%<second_method>s`.'
Expand Down
2 changes: 2 additions & 0 deletions lib/rubocop/cop/performance/collection_literal_in_loop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2f8ae50

Please sign in to comment.