Sha256: 6fb359c91cb77a2a35d249764cdd0b3a4f5536150222b1cb831ed5b4f972b377

Contents?: true

Size: 521 Bytes

Versions: 6

Compression:

Stored size: 521 Bytes

Contents

# frozen_string_literal: true

module Attractor
  # makes suggestions for refactorings
  class Suggester
    def initialize(values)
      @values = values || []
    end

    def suggest(threshold = 95)
      products = @values.map { |val| val.churn * val.complexity }
      products.extend(DescriptiveStatistics)
      quantile = products.percentile(threshold.to_i)

      @values.select { |val| val.churn * val.complexity > quantile }
             .sort_by { |val| val.churn * val.complexity }.reverse
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
attractor-2.0.3 lib/attractor/suggester.rb
attractor-2.0.2 lib/attractor/suggester.rb
attractor-2.0.1 lib/attractor/suggester.rb
attractor-2.0.0 lib/attractor/suggester.rb
attractor-1.2.0 lib/attractor/suggester.rb
attractor-1.1.1 lib/attractor/suggester.rb