class Central::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
rubocop:disable MethodLength
@api private
# File lib/central/devtools/rake/flay.rb, line 24 def verify # Run flay first to ensure the max mass matches the threshold Central::Devtools.notify_metric_violation( BELOW_THRESHOLD % largest_mass ) if below_threshold? Central::Devtools.notify_metric_violation( TOTAL_MISMATCH % [total_mass, total_score] ) if total_mismatch? # Run flay a second time with the threshold set return unless above_threshold? restricted_flay_scale.flay_report Central::Devtools.notify_metric_violation( ABOVE_THRESHOLD % [restricted_mass_size, threshold] ) end
Private Instance Methods
Is there mass duplication which exceeds specified `threshold`
@return [Boolean] @api private
# File lib/central/devtools/rake/flay.rb, line 57 def above_threshold? restricted_mass_size.nonzero? end
Is the specified `threshold` greater than the largest flay mass
@return [Boolean] @api private
# File lib/central/devtools/rake/flay.rb, line 65 def below_threshold? threshold > largest_mass end
List of files flay will analyze
@return [Set<Pathname>] @api private
# File lib/central/devtools/rake/flay.rb, line 49 def files Central::Devtools::Flay::FileList.call(lib_dirs, excludes) end
All flay masses found in `files`
@return [Array<Rational>] @api private
# File lib/central/devtools/rake/flay.rb, line 114 def flay_masses Central::Devtools::Flay::Scale.call(minimum_mass: 0, files: files) end
Largest flay mass found
@return [Integer] @api private
# File lib/central/devtools/rake/flay.rb, line 97 def largest_mass flay_masses.max.to_i end
Flay
scale which only measures mass above `threshold`
@return [Flay::Scale] @api private
# File lib/central/devtools/rake/flay.rb, line 105 def restricted_flay_scale Central::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/central/devtools/rake/flay.rb, line 81 def restricted_mass_size restricted_flay_scale.measure.size end
Sum of all flay mass
@return [Integer] @api private
# File lib/central/devtools/rake/flay.rb, line 89 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/central/devtools/rake/flay.rb, line 73 def total_mismatch? !total_mass.equal?(total_score) end