Module: RuboCop::Cop::OperationWithThreadsafeResult

Extended by:
NodePattern::Macros
Included in:
ThreadSafety::MutableClassInstanceVariable, ThreadSafety::RackMiddlewareInstanceVariable
Defined in:
lib/rubocop/cop/mixin/operation_with_threadsafe_result.rb

Overview

Common functionality for checking if a well-known operation produces an object with thread-safe semantics.

Instance Method Summary collapse

Instance Method Details

#operation_produces_threadsafe_object?(node) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rubocop/cop/mixin/operation_with_threadsafe_result.rb', line 11

def_node_matcher :operation_produces_threadsafe_object?, <<~PATTERN
  {
    (send (const {nil? cbase} :Queue) :new ...)
    (send
      (const (const {nil? cbase} :ThreadSafe) {:Hash :Array})
      :new ...)
    (block
      (send
        (const (const {nil? cbase} :ThreadSafe) {:Hash :Array})
        :new ...)
      ...)
    (send (const (const {nil? cbase} :Concurrent) _) :new ...)
    (block
      (send (const (const {nil? cbase} :Concurrent) _) :new ...)
      ...)
    (send (const (const (const {nil? cbase} :Concurrent) _) _) :new ...)
    (block
      (send
        (const (const (const {nil? cbase} :Concurrent) _) _)
        :new ...)
      ...)
    (send
      (const (const (const (const {nil? cbase} :Concurrent) _) _) _)
      :new ...)
    (block
      (send
        (const (const (const (const {nil? cbase} :Concurrent) _) _) _)
        :new ...)
      ...)
  }
PATTERN