Class: Uniword::Lint::Result
- Inherits:
-
Object
- Object
- Uniword::Lint::Result
- Defined in:
- lib/uniword/lint/result.rb
Overview
Aggregated lint result with severity counts.
Constant Summary collapse
- SEVERITY_ORDER =
%i[error warning info].freeze
Instance Attribute Summary collapse
-
#findings ⇒ Object
readonly
Returns the value of attribute findings.
Instance Method Summary collapse
- #add(finding) ⇒ void
-
#by_rule ⇒ Hash{Symbol => Integer}
Count by rule name.
-
#by_severity ⇒ Hash{Symbol => Integer}
Count by severity.
-
#count ⇒ Integer
Total finding count.
-
#empty? ⇒ Boolean
True when zero findings.
-
#errors? ⇒ Boolean
True when at least one :error severity finding exists.
-
#initialize ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize ⇒ Result
Returns a new instance of Result.
11 12 13 |
# File 'lib/uniword/lint/result.rb', line 11 def initialize @findings = [] end |
Instance Attribute Details
#findings ⇒ Object (readonly)
Returns the value of attribute findings.
9 10 11 |
# File 'lib/uniword/lint/result.rb', line 9 def findings @findings end |
Instance Method Details
#add(finding) ⇒ void
This method returns an undefined value.
17 18 19 |
# File 'lib/uniword/lint/result.rb', line 17 def add(finding) @findings << finding end |
#by_rule ⇒ Hash{Symbol => Integer}
Count by rule name.
39 40 41 42 |
# File 'lib/uniword/lint/result.rb', line 39 def by_rule @findings.group_by { |f| f[:rule] } .transform_values(&:count) end |
#by_severity ⇒ Hash{Symbol => Integer}
Count by severity.
31 32 33 34 |
# File 'lib/uniword/lint/result.rb', line 31 def by_severity @findings.group_by { |f| f[:severity] } .transform_values(&:count) end |
#count ⇒ Integer
Total finding count.
47 48 49 |
# File 'lib/uniword/lint/result.rb', line 47 def count @findings.length end |
#empty? ⇒ Boolean
True when zero findings.
54 55 56 |
# File 'lib/uniword/lint/result.rb', line 54 def empty? @findings.empty? end |
#errors? ⇒ Boolean
True when at least one :error severity finding exists.
24 25 26 |
# File 'lib/uniword/lint/result.rb', line 24 def errors? @findings.any? { |f| f[:severity] == :error } end |