Sha256: 16e3b69a2666ef5bed3fd97d01e811b9c7862fd2377271ff3df023fa6b793ab0

Contents?: true

Size: 705 Bytes

Versions: 3

Compression:

Stored size: 705 Bytes

Contents

# frozen_string_literal: true

module Polariscope
  module Scanner
    class AdvisoriesHealthScore
      def initialize(dependency_context, calculation_context)
        @dependency_context = dependency_context
        @calculation_context = calculation_context
      end

      def health_score
        (1 + advisories_penalty)**-Math.log(calculation_context.advisory_severity)
      end

      private

      attr_reader :dependency_context
      attr_reader :calculation_context

      def advisories_penalty
        dependency_context
          .advisories
          .map(&:criticality)
          .sum { |criticality| calculation_context.advisory_penalty_for(criticality) }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
polariscope-0.6.0 lib/polariscope/scanner/advisories_health_score.rb
polariscope-0.5.0 lib/polariscope/scanner/advisories_health_score.rb
polariscope-0.4.0 lib/polariscope/scanner/advisories_health_score.rb