Class: FiberAudit::Static::CallSite

Inherits:
Data
  • Object
show all
Defined in:
lib/fiber_audit/static/call_site.rb

Overview

CallSite represents a single method call extracted from source code. Carries exactly 13 fields as specified in the remediation plan.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, line:, column:, receiver_source:, receiver_constant:, method_name:, arguments:, enclosing_symbol:, nesting:, execution_context:, resolution:, confidence:) ⇒ CallSite

Override initialize to ensure proper contract:

  • method_name normalized to Symbol or nil
  • confidence validated via Confidence.coerce
  • arguments and nesting frozen to prevent caller mutation


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fiber_audit/static/call_site.rb', line 20

def initialize(
  path:, line:, column:,
  receiver_source:, receiver_constant:, method_name:,
  arguments:, enclosing_symbol:, nesting:,
  execution_context:, resolution:, confidence:
)
  # Normalize method_name to Symbol if it's a String, preserve nil
  method_name_value = case method_name
                      when String
                        method_name.to_sym
                      when Symbol, nil
                        method_name
                      else
                        raise ArgumentError,
                              "method_name must be String, Symbol, or nil, got #{method_name.class}"
                      end

  # Validate confidence via Confidence.coerce
  validated_confidence = Confidence.coerce(confidence)

  # Freeze duplicates of mutable collections to prevent caller mutation
  frozen_arguments = arguments.dup.freeze
  frozen_nesting = nesting.dup.freeze

  super(
    path: path,
    line: line,
    column: column,
    receiver_source: receiver_source,
    receiver_constant: receiver_constant,
    method_name: method_name_value,
    arguments: frozen_arguments,
    enclosing_symbol: enclosing_symbol,
    nesting: frozen_nesting,
    execution_context: execution_context,
    resolution: resolution,
    confidence: validated_confidence
  )
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments

Returns:

  • (Object)

    the current value of arguments



10
11
12
# File 'lib/fiber_audit/static/call_site.rb', line 10

def arguments
  @arguments
end

#columnObject (readonly)

Returns the value of attribute column

Returns:

  • (Object)

    the current value of column



10
11
12
# File 'lib/fiber_audit/static/call_site.rb', line 10

def column
  @column
end

#confidenceObject (readonly)

Returns the value of attribute confidence

Returns:

  • (Object)

    the current value of confidence



10
11
12
# File 'lib/fiber_audit/static/call_site.rb', line 10

def confidence
  @confidence
end

#enclosing_symbolObject (readonly)

Returns the value of attribute enclosing_symbol

Returns:

  • (Object)

    the current value of enclosing_symbol



10
11
12
# File 'lib/fiber_audit/static/call_site.rb', line 10

def enclosing_symbol
  @enclosing_symbol
end

#execution_contextObject (readonly)

Returns the value of attribute execution_context

Returns:

  • (Object)

    the current value of execution_context



10
11
12
# File 'lib/fiber_audit/static/call_site.rb', line 10

def execution_context
  @execution_context
end

#lineObject (readonly)

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



10
11
12
# File 'lib/fiber_audit/static/call_site.rb', line 10

def line
  @line
end

#method_nameObject (readonly)

Returns the value of attribute method_name

Returns:

  • (Object)

    the current value of method_name



10
11
12
# File 'lib/fiber_audit/static/call_site.rb', line 10

def method_name
  @method_name
end

#nestingObject (readonly)

Returns the value of attribute nesting

Returns:

  • (Object)

    the current value of nesting



10
11
12
# File 'lib/fiber_audit/static/call_site.rb', line 10

def nesting
  @nesting
end

#pathObject (readonly)

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



10
11
12
# File 'lib/fiber_audit/static/call_site.rb', line 10

def path
  @path
end

#receiver_constantObject (readonly)

Returns the value of attribute receiver_constant

Returns:

  • (Object)

    the current value of receiver_constant



10
11
12
# File 'lib/fiber_audit/static/call_site.rb', line 10

def receiver_constant
  @receiver_constant
end

#receiver_sourceObject (readonly)

Returns the value of attribute receiver_source

Returns:

  • (Object)

    the current value of receiver_source



10
11
12
# File 'lib/fiber_audit/static/call_site.rb', line 10

def receiver_source
  @receiver_source
end

#resolutionObject (readonly)

Returns the value of attribute resolution

Returns:

  • (Object)

    the current value of resolution



10
11
12
# File 'lib/fiber_audit/static/call_site.rb', line 10

def resolution
  @resolution
end

Instance Method Details

#locationObject

Returns a Location object for this call site



61
62
63
# File 'lib/fiber_audit/static/call_site.rb', line 61

def location
  FiberAudit::Location.new(path: path, line: line, column: column)
end

#method_name_symObject

Returns method_name as a Symbol or nil (convenience accessor)



66
67
68
# File 'lib/fiber_audit/static/call_site.rb', line 66

def method_name_sym
  method_name
end