Class: Necropsy::Confidence::Scorer

Inherits:
Object
  • Object
show all
Defined in:
lib/necropsy/confidence/scorer.rb

Constant Summary collapse

RUBY_HOOKS =
%w[
  inherited included extended prepended method_added singleton_method_added
  const_missing method_missing respond_to_missing?
].freeze
RUBY_PROTOCOLS =
%w[
  == eql? hash <=> to_s to_str to_a to_h to_proc inspect each call coerce
  succ initialize_copy marshal_dump marshal_load
].freeze
BUILTIN_IMPLICIT_CALLERS =
[
  {
    name_pattern: /^on_/,
    owner_ancestors: ['RuboCop::Cop::Base'],
    reason: 'RuboCop Commissioner dispatches on_* callbacks'
  }
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(graph:, reachability:, project:) ⇒ Scorer

Returns a new instance of Scorer.



24
25
26
27
28
29
# File 'lib/necropsy/confidence/scorer.rb', line 24

def initialize(graph:, reachability:, project:)
  @graph = graph
  @reachability = reachability
  @project = project
  @source_lines = {}
end

Instance Method Details

#findingsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/necropsy/confidence/scorer.rb', line 31

def findings
  graph.method_nodes.filter_map do |node|
    next if node.test

    classification = classification_for(node)
    next unless classification

    score, level, reasons, score_components = score_for(node, classification)
    Finding.new(
      node: node,
      classification: classification,
      confidence: level,
      score: score,
      score_components: score_components,
      reasons: reasons,
      evidences: graph.incoming_edges(node.id).flat_map(&:evidences) + graph.alive_evidences(node.id)
    )
  end
end