Class: Necropsy::Report
- Inherits:
-
Object
- Object
- Necropsy::Report
- Defined in:
- lib/necropsy/report.rb
Instance Attribute Summary collapse
-
#findings ⇒ Object
readonly
Returns the value of attribute findings.
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #dead_methods(min_confidence: :low) ⇒ Object
-
#initialize(root:, graph:, findings:) ⇒ Report
constructor
A new instance of Report.
- #summary ⇒ Object
- #to_h ⇒ Object
- #to_json ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
Instance Attribute Details
#findings ⇒ Object (readonly)
Returns the value of attribute findings.
8 9 10 |
# File 'lib/necropsy/report.rb', line 8 def findings @findings end |
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
8 9 10 |
# File 'lib/necropsy/report.rb', line 8 def graph @graph end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
8 9 10 |
# File 'lib/necropsy/report.rb', line 8 def root @root end |
Instance Method Details
#dead_methods(min_confidence: :low) ⇒ Object
16 17 18 |
# File 'lib/necropsy/report.rb', line 16 def dead_methods(min_confidence: :low) findings.select { |finding| finding.at_least?(min_confidence) } end |
#summary ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/necropsy/report.rb', line 37 def summary grouped = findings.group_by(&:classification) { 'nodes' => graph.nodes.length, 'edges' => graph.edges.length, 'entry_points' => graph.entry_points.length, 'findings' => findings.length, 'unreachable' => grouped.fetch(:unreachable, []).length, 'unused' => grouped.fetch(:unused, []).length, 'test_only_reachable' => grouped.fetch(:test_only_reachable, []).length } end |
#to_h ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/necropsy/report.rb', line 20 def to_h { 'root' => root, 'summary' => summary, 'findings' => findings.map(&:to_h), 'graph' => graph.to_h } end |
#to_json ⇒ Object
29 30 31 |
# File 'lib/necropsy/report.rb', line 29 def to_json(*) JSON.pretty_generate(to_h, *) end |
#to_yaml ⇒ Object
33 34 35 |
# File 'lib/necropsy/report.rb', line 33 def to_yaml to_h.to_yaml end |