Class: Moult::DuplicationReport
- Inherits:
-
Object
- Object
- Moult::DuplicationReport
- Defined in:
- lib/moult/duplication_report.rb
Overview
The serialized result model for moult duplication (schema/duplication.schema.json),
sibling to DeadCodeReport and CoverageReport. It owns the JSON envelope and
leaves the other protected contracts untouched. Each Finding is a confidence-
graded clone group carrying its Reasons and Occurrences; nothing here asserts
that duplication is certainly removable.
Defined Under Namespace
Classes: Finding, Occurrence
Constant Summary collapse
- SCHEMA_VERSION =
Bump only on a breaking change to the serialized shape.
1
Instance Attribute Summary collapse
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
-
#backend_version ⇒ Object
readonly
Returns the value of attribute backend_version.
-
#findings ⇒ Object
readonly
Returns the value of attribute findings.
-
#fuzzy ⇒ Object
readonly
Returns the value of attribute fuzzy.
-
#generated_at ⇒ Object
readonly
Returns the value of attribute generated_at.
-
#git_ref ⇒ Object
readonly
Returns the value of attribute git_ref.
-
#min_mass ⇒ Object
readonly
Returns the value of attribute min_mass.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(root:, findings:, git_ref: nil, generated_at: nil, backend: "flay", backend_version: nil, min_mass: nil, fuzzy: false) ⇒ DuplicationReport
constructor
A new instance of DuplicationReport.
-
#summary ⇒ Hash
Aggregate counts across all clone groups.
- #to_h ⇒ Object
Constructor Details
#initialize(root:, findings:, git_ref: nil, generated_at: nil, backend: "flay", backend_version: nil, min_mass: nil, fuzzy: false) ⇒ DuplicationReport
Returns a new instance of DuplicationReport.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/moult/duplication_report.rb', line 48 def initialize(root:, findings:, git_ref: nil, generated_at: nil, backend: "flay", backend_version: nil, min_mass: nil, fuzzy: false) @root = root @findings = findings @git_ref = git_ref @generated_at = generated_at @backend = backend @backend_version = backend_version @min_mass = min_mass @fuzzy = fuzzy end |
Instance Attribute Details
#backend ⇒ Object (readonly)
Returns the value of attribute backend.
39 40 41 |
# File 'lib/moult/duplication_report.rb', line 39 def backend @backend end |
#backend_version ⇒ Object (readonly)
Returns the value of attribute backend_version.
39 40 41 |
# File 'lib/moult/duplication_report.rb', line 39 def backend_version @backend_version end |
#findings ⇒ Object (readonly)
Returns the value of attribute findings.
39 40 41 |
# File 'lib/moult/duplication_report.rb', line 39 def findings @findings end |
#fuzzy ⇒ Object (readonly)
Returns the value of attribute fuzzy.
39 40 41 |
# File 'lib/moult/duplication_report.rb', line 39 def fuzzy @fuzzy end |
#generated_at ⇒ Object (readonly)
Returns the value of attribute generated_at.
39 40 41 |
# File 'lib/moult/duplication_report.rb', line 39 def generated_at @generated_at end |
#git_ref ⇒ Object (readonly)
Returns the value of attribute git_ref.
39 40 41 |
# File 'lib/moult/duplication_report.rb', line 39 def git_ref @git_ref end |
#min_mass ⇒ Object (readonly)
Returns the value of attribute min_mass.
39 40 41 |
# File 'lib/moult/duplication_report.rb', line 39 def min_mass @min_mass end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
39 40 41 |
# File 'lib/moult/duplication_report.rb', line 39 def root @root end |
Instance Method Details
#summary ⇒ Hash
Returns aggregate counts across all clone groups.
61 62 63 64 65 66 67 |
# File 'lib/moult/duplication_report.rb', line 61 def summary { sets: findings.size, occurrences: findings.sum { |f| f.occurrences.size }, total_mass: findings.sum(&:mass) } end |
#to_h ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/moult/duplication_report.rb', line 69 def to_h { schema_version: SCHEMA_VERSION, tool: {name: "moult", version: Moult::VERSION}, analysis: { root: root, git_ref: git_ref, generated_at: generated_at, detector: { backend: backend, backend_version: backend_version, min_mass: min_mass, fuzzy: fuzzy } }, summary: summary, findings: findings.map(&:to_h) } end |