Class: Necropsy::Analyzers::Static::NameResolution

Inherits:
Necropsy::Analyzer show all
Defined in:
lib/necropsy/analyzers/static/name_resolution.rb

Instance Method Summary collapse

Instance Method Details

#analyze(graph, _project) ⇒ Object



7
8
9
10
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
42
# File 'lib/necropsy/analyzers/static/name_resolution.rb', line 7

def analyze(graph, _project)
  edge_evidences = []
  resolutions = []
  uncertainties = {}
  blockers = []
  graph.call_sites.each do |site|
    lookup = graph.method_lookup(site)
    candidates = lookup.targets
    fallback = %w[dynamic_message unknown_receiver unknown_self_owner self_lookup_fallback].include?(
      lookup.reason
    )
    site_edges = edge_evidences_for(site, candidates, fallback, lookup)
    edge_evidences.concat(site_edges)
    resolutions << resolution_record(
      site,
      candidates,
      site_edges,
      status: lookup.status,
      rejected_targets: lookup.rejected_targets,
      unknown_scope: graph.residual_scope_for(site)
    )
    record_unresolved_uncertainty(graph, site, lookup, uncertainties)
    blocker = unresolved_blocker(graph, site, lookup)
    blockers << blocker if blocker
  end

  AnalyzerResult.new(
    edge_evidences: edge_evidences,
    alive_evidences: [],
    uncertainties: uncertainties,
    observation: {},
    blockers: blockers,
    resolutions: resolutions,
    evidences: result_evidences(edge_evidences)
  )
end

#capabilitiesObject



55
56
57
# File 'lib/necropsy/analyzers/static/name_resolution.rb', line 55

def capabilities
  [:complete_resolution].freeze
end

#profileObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/necropsy/analyzers/static/name_resolution.rb', line 44

def profile
  AnalyzerProfile.new(
    name: :name_resolution,
    kind: :static,
    soundness: :unsound,
    description: 'Resolves Ruby call sites by exact receiver and method name, falling back to same-name candidates.',
    version: Necropsy::VERSION,
    assumptions: %w[bounded_same_name_fallback scanned_receiver_hints]
  )
end