module Metrics

  class Licenses < Metric

    attr_reader :analysis

    def initialize(path=nil)
      path = 'app/assets/resources/licenses.json' if path.nil?
      @licenses = JSON.parse(File.read(path))
      @analysis = Hash.new(0)
    end

    def license_open?(id)
      return false if @licenses[id].nil?
      @licenses[id]['is_okd_compliant'] || @licenses[id]['is_osi_compliant']
    end

    def compute(record)
      license = record['license_id'].gsub('.', "\uff0e")
      @analysis[license] += 1

      return 1.0, license if license_open?(license)
      return 0.0, license
    end

  end

end

module Metrics

  class Licenses < Metric

    attr_reader :analysis

    def initialize(path=nil)
      path = 'app/assets/resources/licenses.json' if path.nil?
      @licenses = JSON.parse(File.read(path))
      @analysis = Hash.new(0)
    end

    def license_open?(id)
      return false if @licenses[id].nil?
      @licenses[id]['is_okd_compliant'] || @licenses[id]['is_osi_compliant']
    end

    def compute(record)
      license = record['license_id'].maybe.gsub('.', "\uff0e")
      @analysis[license] += 1

      return 1.0, license if license_open?(license)
      return 0.0, license
    end

  end

end

Add a maybe statement to the license substitution
Add a maybe statement to the license substitution

The license identifier might be null, hence I have added a maybe
statement.

Signed-off-by: Konrad Reiche <4ff0213f56e2082fcd8c882d04c546881c579ce4@gmail.com>
