Class: Devtools::Rake::Flay

Inherits:
Object
  • Object
show all
Includes:
Adamantium
Defined in:
lib/devtools/rake/flay.rb

Overview

Flay metric runner

Constant Summary collapse

BELOW_THRESHOLD =
'Adjust flay threshold down to %d'.freeze
TOTAL_MISMATCH =
'Flay total is now %d, but expected %d'.freeze
ABOVE_THRESHOLD =
'%d chunks have a duplicate mass > %d'.freeze

Instance Method Summary collapse

Instance Method Details

#verifyundefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Verify code specified by ‘files` does not violate flay expectations

rubocop:disable MethodLength

Returns:

  • (undefined)

    otherwise

Raises:

  • (SystemExit)

    if a violation is found



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/devtools/rake/flay.rb', line 21

def verify
  # Run flay first to ensure the max mass matches the threshold
  if below_threshold?
    Devtools.notify_metric_violation(
      BELOW_THRESHOLD % largest_mass
    )
  end

  if total_mismatch?
    Devtools.notify_metric_violation(
      TOTAL_MISMATCH % [total_mass, total_score]
    )
  end

  # Run flay a second time with the threshold set
  return unless above_threshold?

  restricted_flay_scale.flay_report
  Devtools.notify_metric_violation(
    ABOVE_THRESHOLD % [restricted_mass_size, threshold]
  )
end