class Entruby::Overview

Constants

COMPLEX_FUNCTION_PARAMS
HIGH_COUPLING_METRIC
HUGE_FUNCTION_COL

Attributes

metrics[R]

Public Class Methods

new(couplings) click to toggle source
# File lib/entruby.rb, line 108
def initialize(couplings)
  huge_functions = couplings.count { |c| c[:col] >= HUGE_FUNCTION_COL }
  complex_functions = couplings.count { |c| c[:params].size >= COMPLEX_FUNCTION_PARAMS }
  couplers = couplings.count { |c| c[:metric] >= HIGH_COUPLING_METRIC }
  @metrics = [
      OverviewMetric.new("Excessive Couplers", "(Metric >= 0.7)", couplers, 3),
      OverviewMetric.new("Complex Functions", "(Params >= 7)", complex_functions, 2),
      OverviewMetric.new("Huge Functions", "(CoL >= 50)", huge_functions, 1),
  ]
end

Public Instance Methods

index() click to toggle source
# File lib/entruby.rb, line 123
def index
  metrics.reduce(0.0) { |memo, metric| memo + metric.value * metric.weight }
end
report() click to toggle source
# File lib/entruby.rb, line 119
def report
  {index: index, metrics: metrics.map(&:as_json)}
end