Class: Mutineer::AggregateResult
- Inherits:
-
Object
- Object
- Mutineer::AggregateResult
- Defined in:
- lib/mutineer/result.rb
Overview
Aggregates a flat list of Results into counts, the mutation score, and the surviving-mutant list. The score denominator is killed + survived ONLY: no-coverage, uncapturable, unplaceable, ran-at-load, skipped (invalid), errored, timeout, and ignored (equivalent-mutant suppression) are each excluded and surfaced separately, so suppressing every survivor reaches 100%. An empty denominator yields a nil score (rendered "N/A"), never 0.0, distinguishing "no testable mutants" from "0% killed".
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#by_source ⇒ Hash<String, Mutineer::AggregateResult>
Groups results by source file so the Reporter (per-source breakdown) and baseline diff can reuse the same aggregate math.
-
#count(status) ⇒ Integer
private
Counts results for a status.
-
#covered_count ⇒ Integer
The score denominator (also shown to the reader).
-
#errored_count ⇒ Integer
Errored count.
-
#ignored_count ⇒ Integer
Ignored count.
-
#initialize(results) ⇒ AggregateResult
constructor
Builds an aggregate from results.
-
#killed_count ⇒ Integer
Killed count.
-
#meets_threshold?(threshold) ⇒ Boolean
Checks the unrounded score against a threshold.
-
#mutation_score ⇒ Float?
Computes the mutation score.
-
#no_coverage_count ⇒ Integer
No-coverage count.
-
#ran_at_load_count ⇒ Integer
Ran-at-load count.
-
#skipped_invalid_count ⇒ Integer
Skipped-invalid count.
-
#survived_count ⇒ Integer
Survived count.
-
#surviving_mutants ⇒ Array<Mutineer::Result>
Returns the surviving mutants.
-
#timeout_count ⇒ Integer
Timeout count.
-
#total ⇒ Integer
Every generated, classified mutation.
-
#uncapturable_count ⇒ Integer
Uncapturable count.
-
#unplaceable_count ⇒ Integer
Unplaceable count.
-
#unrun_count ⇒ Integer
Mutants that exist but did not run: unplaceable plus skipped invalid.
Constructor Details
#initialize(results) ⇒ AggregateResult
Builds an aggregate from results.
187 188 189 190 |
# File 'lib/mutineer/result.rb', line 187 def initialize(results) @results = results @by_status = results.group_by(&:status) end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
182 183 184 |
# File 'lib/mutineer/result.rb', line 182 def results @results end |
Instance Method Details
#by_source ⇒ Hash<String, Mutineer::AggregateResult>
Groups results by source file so the Reporter (per-source breakdown) and baseline diff can reuse the same aggregate math.
262 263 264 265 266 |
# File 'lib/mutineer/result.rb', line 262 def by_source @results.select { |r| r.subject } .group_by { |r| r.subject.file } .transform_values { |rs| AggregateResult.new(rs) } end |
#count(status) ⇒ Integer (private)
Counts results for a status.
274 |
# File 'lib/mutineer/result.rb', line 274 def count(status) = (@by_status[status] || []).size |
#covered_count ⇒ Integer
The score denominator (also shown to the reader).
227 |
# File 'lib/mutineer/result.rb', line 227 def covered_count = killed_count + survived_count |
#errored_count ⇒ Integer
Returns errored count.
207 208 |
# File 'lib/mutineer/result.rb', line 207 def errored_count = count(:error) # @return [Integer] timeout count. |
#ignored_count ⇒ Integer
Returns ignored count.
211 212 213 214 215 216 |
# File 'lib/mutineer/result.rb', line 211 def ignored_count = count(:ignored) # Mutants that exist but did not run: unplaceable plus skipped invalid. # Neither is in the score. The reporter adds unpaired mutants to the # unrun share unless `--fail-fast` is set. `unrun_count` excludes them. # # @return [Integer] unplaceable plus skipped-invalid count. |
#killed_count ⇒ Integer
Returns killed count.
193 194 |
# File 'lib/mutineer/result.rb', line 193 def killed_count = count(:killed) # @return [Integer] survived count. |
#meets_threshold?(threshold) ⇒ Boolean
Checks the unrounded score against a threshold. mutation_score is
rounded for display, so 1999 of 2000 killed reads 100.0; a gate that
compared it would pass --threshold 100 with a survivor. The comparison
is exact: integer counts against the threshold as the decimal it prints
as, so a float product such as 64.4 * 250 cannot tip a run at the
boundary. to_s.to_r keeps that decimal; rationalize could round a
long threshold such as 66.66666666666667 down to 200/3.
249 250 251 |
# File 'lib/mutineer/result.rb', line 249 def meets_threshold?(threshold) covered_count.positive? && killed_count * 100 >= threshold.to_s.to_r * covered_count end |
#mutation_score ⇒ Float?
Computes the mutation score.
232 233 234 235 236 |
# File 'lib/mutineer/result.rb', line 232 def mutation_score return nil if covered_count.zero? (killed_count.to_f / covered_count * 100).round(1) end |
#no_coverage_count ⇒ Integer
Returns no-coverage count.
197 198 |
# File 'lib/mutineer/result.rb', line 197 def no_coverage_count = count(:no_coverage) # @return [Integer] uncapturable count. |
#ran_at_load_count ⇒ Integer
Returns ran-at-load count.
203 204 |
# File 'lib/mutineer/result.rb', line 203 def ran_at_load_count = count(:ran_at_load) # @return [Integer] skipped-invalid count. |
#skipped_invalid_count ⇒ Integer
Returns skipped-invalid count.
205 206 |
# File 'lib/mutineer/result.rb', line 205 def skipped_invalid_count = count(:skipped) # @return [Integer] errored count. |
#survived_count ⇒ Integer
Returns survived count.
195 196 |
# File 'lib/mutineer/result.rb', line 195 def survived_count = count(:survived) # @return [Integer] no-coverage count. |
#surviving_mutants ⇒ Array<Mutineer::Result>
Returns the surviving mutants.
256 |
# File 'lib/mutineer/result.rb', line 256 def surviving_mutants = @results.select(&:survived?) |
#timeout_count ⇒ Integer
Returns timeout count.
209 210 |
# File 'lib/mutineer/result.rb', line 209 def timeout_count = count(:timeout) # @return [Integer] ignored count. |
#total ⇒ Integer
Every generated, classified mutation. NOT the score denominator.
222 |
# File 'lib/mutineer/result.rb', line 222 def total = @results.size |
#uncapturable_count ⇒ Integer
Returns uncapturable count.
199 200 |
# File 'lib/mutineer/result.rb', line 199 def uncapturable_count = count(:uncapturable) # @return [Integer] unplaceable count. |
#unplaceable_count ⇒ Integer
Returns unplaceable count.
201 202 |
# File 'lib/mutineer/result.rb', line 201 def unplaceable_count = count(:unplaceable) # @return [Integer] ran-at-load count. |
#unrun_count ⇒ Integer
Mutants that exist but did not run: unplaceable plus skipped invalid.
Neither is in the score. The reporter adds unpaired mutants to the
unrun share unless --fail-fast is set. unrun_count excludes them.
217 |
# File 'lib/mutineer/result.rb', line 217 def unrun_count = unplaceable_count + skipped_invalid_count |