Sha256: baddd01074b434baf153a89d0ef9183f133f8c5c0a261a70d34a366ba86b7584

Contents?: true

Size: 543 Bytes

Versions: 3

Compression:

Stored size: 543 Bytes

Contents

# frozen_string_literal: true

module Attractor
  # makes suggestions for refactorings
  class Suggester
    attr_accessor :values

    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

3 entries across 3 versions & 1 rubygems

Version Path
attractor-2.3.0 lib/attractor/suggester.rb
attractor-2.2.0 lib/attractor/suggester.rb
attractor-2.1.0 lib/attractor/suggester.rb