Sha256: f986fa3d1c7599195106946b176992bf1c8520c7ecc3def284b45e8acedc7556

Contents?: true

Size: 515 Bytes

Versions: 8

Compression:

Stored size: 515 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

8 entries across 8 versions & 1 rubygems

Version Path
attractor-1.1.0 lib/attractor/suggester.rb
attractor-1.0.2 lib/attractor/suggester.rb
attractor-1.0.1 lib/attractor/suggester.rb
attractor-1.0.0 lib/attractor/suggester.rb
attractor-0.6.1 lib/attractor/suggester.rb
attractor-0.6.0 lib/attractor/suggester.rb
attractor-0.5.1 lib/attractor/suggester.rb
attractor-0.5.0 lib/attractor/suggester.rb