Class: FiberAudit::Static::Rules::ThreadJoin

Inherits:
Base
  • Object
show all
Defined in:
lib/fiber_audit/static/rules/thread_join.rb

Overview

FA1002: Thread#join / Thread#value may block the fiber-scheduler thread.

Matches join/value on Thread instances whose receiver_constant is 'Thread' but whose receiver_source is not the bare literal 'Thread'. Covers direct constructor chains (Thread.new.join), assigned receivers (t = Thread.new; t.join), and the exact syntactic Thread.current form.

Skips direct Thread.join/value, arbitrary worker.join, wrong methods, and workspace-shadowed Thread (checked via workspace or workspace.semantic_index resolve_constant seam). Adapter errors from those seams are swallowed — they never raise.

Constant Summary collapse

TITLE =
'Thread wait'
CATEGORY =
:synchronization
MESSAGE =
'Waiting for a thread may block the thread running the fiber scheduler.'
REMEDIATION =
'Replace thread waits with scheduler-aware coordination, ' \
'or move the work outside the fiber-scheduled path.'
TARGET_METHODS =
%i[join value].freeze
CANONICAL_OPS =
%w[Thread.join Thread.value].freeze
DIRECT_CLASS_SOURCE =
'Thread'

Constants inherited from Base

Base::CONTEXT_CEILING

Instance Method Summary collapse

Methods inherited from Base

confidence, default_confidence, default_severity, description, id, #initialize, severity

Constructor Details

This class inherits a constructor from FiberAudit::Static::Rules::Base

Instance Method Details

#analyze(call_sites:) ⇒ Object



37
38
39
# File 'lib/fiber_audit/static/rules/thread_join.rb', line 37

def analyze(call_sites:)
  call_sites.filter_map { |site| match(site) }
end