# frozen_string_literal: true

module Gitlab
  module Ci
    module Reports
      module DependencyList
        class Vulnerability
          attr_reader :name, :severity

          def initialize(params)
            @name = params.fetch(:name)
            @severity = params.fetch(:severity)
          end

          def ==(other)
            self.to_hash == other.to_hash
          end

          def hash
            name.hash ^ severity.hash
          end

          def to_hash
            {
              name: self.name,
              severity: self.severity
            }
          end

          alias_method :eql?, :==
        end
      end
    end
  end
end
