class Devtools::Rake::Flay
Flay
metric runner
Constants
- ABOVE_THRESHOLD
- BELOW_THRESHOLD
- TOTAL_MISMATCH
Public Instance Methods
Verify code specified by `files` does not violate flay expectations
@raise [SystemExit] if a violation is found @return [undefined] otherwise
@api private
# File lib/devtools/rake/flay.rb, line 22 def verify # Run flay first to ensure the max mass matches the threshold below_threshold_message if below_threshold? total_mismatch_message if total_mismatch? # Run flay a second time with the threshold set return unless above_threshold? restricted_flay_scale.flay_report above_threshold_message end
Private Instance Methods
Is there mass duplication which exceeds specified `threshold`
@return [Boolean]
@api private
# File lib/devtools/rake/flay.rb, line 51 def above_threshold? restricted_mass_size.nonzero? end
Above threshold message
@return [String]
@api private
# File lib/devtools/rake/flay.rb, line 78 def above_threshold_message format_values = { mass: restricted_mass_size, threshold: threshold } Devtools.notify_metric_violation( format(ABOVE_THRESHOLD, format_values) ) end
Is the specified `threshold` greater than the largest flay mass
@return [Boolean]
@api private
# File lib/devtools/rake/flay.rb, line 60 def below_threshold? threshold > largest_mass end
Below threshold message
@return [String]
@api private
# File lib/devtools/rake/flay.rb, line 90 def below_threshold_message Devtools.notify_metric_violation( format(BELOW_THRESHOLD, mass: largest_mass) ) end
List of files flay will analyze
@return [Set<Pathname>]
@api private
# File lib/devtools/rake/flay.rb, line 42 def files Devtools::Flay::FileList.call(lib_dirs, excludes) end
All flay masses found in `files`
@return [Array<Rational>]
@api private
# File lib/devtools/rake/flay.rb, line 149 def flay_masses Devtools::Flay::Scale.call(minimum_mass: 0, files: files) end
Largest flay mass found
@return [Integer]
@api private
# File lib/devtools/rake/flay.rb, line 130 def largest_mass flay_masses.max.to_i end
Flay
scale which only measures mass above `threshold`
@return [Flay::Scale]
@api private
# File lib/devtools/rake/flay.rb, line 139 def restricted_flay_scale Devtools::Flay::Scale.new(minimum_mass: threshold.succ, files: files) end
Size of mass measured by `Flay::Scale` and filtered by `threshold`
@return [Integer]
@api private
# File lib/devtools/rake/flay.rb, line 112 def restricted_mass_size restricted_flay_scale.measure.size end
Sum of all flay mass
@return [Integer]
@api private
# File lib/devtools/rake/flay.rb, line 121 def total_mass flay_masses.reduce(:+).to_i end
Is the expected mass total different from the actual mass total
@return [Boolean]
@api private
# File lib/devtools/rake/flay.rb, line 69 def total_mismatch? !total_mass.equal?(total_score) end
Total mismatch message
@return [String]
@api private
# File lib/devtools/rake/flay.rb, line 101 def total_mismatch_message Devtools.notify_metric_violation( format(TOTAL_MISMATCH, mass: total_mass, expected: total_score) ) end