Class: Pinspec::Validate::PinScorer::Report

Inherits:
Data
  • Object
show all
Defined in:
lib/pinspec/validate/pin_scorer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#scoresObject (readonly)

Returns the value of attribute scores

Returns:

  • (Object)

    the current value of scores



20
21
22
# File 'lib/pinspec/validate/pin_scorer.rb', line 20

def scores
  @scores
end

#skippedObject (readonly)

Returns the value of attribute skipped

Returns:

  • (Object)

    the current value of skipped



20
21
22
# File 'lib/pinspec/validate/pin_scorer.rb', line 20

def skipped
  @skipped
end

#subjectObject (readonly)

Returns the value of attribute subject

Returns:

  • (Object)

    the current value of subject



20
21
22
# File 'lib/pinspec/validate/pin_scorer.rb', line 20

def subject
  @subject
end

Instance Method Details

#covered_by_another_aspectObject



39
40
41
42
43
44
45
# File 'lib/pinspec/validate/pin_scorer.rb', line 39

def covered_by_another_aspect
  all = scored.flat_map(&:survivors)
  gaps = surviving_all_aspects.map { |s| mutant_key(s) }

  all.reject { |s| gaps.include?(mutant_key(s)) }
     .uniq { |s| mutant_key(s) }
end

#mutant_key(survivor) ⇒ Object



47
48
49
# File 'lib/pinspec/validate/pin_scorer.rb', line 47

def mutant_key(survivor)
  [survivor["operator"], survivor["line"], survivor["token"]].join(":")
end

#scoredObject



21
22
23
# File 'lib/pinspec/validate/pin_scorer.rb', line 21

def scored
  scores.reject { |score| score.score.nil? }
end

#strong_ratioObject



25
26
27
28
29
# File 'lib/pinspec/validate/pin_scorer.rb', line 25

def strong_ratio
  return 0.0 if scored.empty?

  (scored.count(&:strong?).to_f / scored.size * 100).round(1)
end

#surviving_all_aspectsObject



31
32
33
34
35
36
37
# File 'lib/pinspec/validate/pin_scorer.rb', line 31

def surviving_all_aspects
  sets = scored.map { |score| score.survivors.map { |s| mutant_key(s) } }
  return [] if sets.empty? || sets.any?(&:empty?)

  shared = sets.reduce(:&)
  scored.first.survivors.select { |s| shared.include?(mutant_key(s)) }
end