<commit_before>class IdentityProvider
  include ActiveModel::Model

  attr_reader :simple_id, :entity_id, :levels_of_assurance, :authentication_enabled, :temporarily_unavailable
  validates_presence_of :simple_id, :entity_id, :levels_of_assurance

  def initialize(hash)
    @simple_id = hash['simpleId']
    @entity_id = hash['entityId']
    @levels_of_assurance = hash['levelsOfAssurance']
    @authentication_enabled = hash.has_key?('authenticationEnabled') ? hash['authenticationEnabled'] : true
    @temporarily_unavailable = hash.has_key?('temporarilyUnavailable') ? hash['temporarilyUnavailable'] : false
  end

  def ==(other)
    if other.is_a?(IdentityProvider)
      self.simple_id == other.simple_id &&
        self.entity_id == other.entity_id &&
        self.levels_of_assurance == other.levels_of_assurance &&
        self.authentication_enabled == other.authentication_enabled &&
        self.temporarily_unavailable == other.temporarily_unavailable
    else
      super
    end
  end

  alias_method :eql?, :==

  def hash
    simple_id.hash + entity_id.hash + levels_of_assurance.hash + authentication_enabled.hash + temporarily_unavailable.hash
  end

  def self.from_session(object)
    return object if object.is_a? IdentityProvider

    if object.is_a?(Hash) || (object.is_a?(SelectedProviderData) && object.is_selected_verify_idp?)
      new('simpleId' => object['simple_id'], 'entityId' => object['entity_id'], 'levelsOfAssurance' => object['levels_of_assurance'], 'authenticationEnabled' => object['authentication_enabled'], 'temporarilyUnavailable' => object['temporarily_unavailable'])
    end
  end
end<commit_msg>HUB-42: Placate codacy<commit_after>class IdentityProvider
  include ActiveModel::Model

  attr_reader :simple_id, :entity_id, :levels_of_assurance, :authentication_enabled, :temporarily_unavailable
  validates_presence_of :simple_id, :entity_id, :levels_of_assurance

  def initialize(hash)
    @simple_id = hash['simpleId']
    @entity_id = hash['entityId']
    @levels_of_assurance = hash['levelsOfAssurance']
    @authentication_enabled = hash.fetch('authenticationEnabled', true)
    @temporarily_unavailable = hash.fetch('temporarilyUnavailable', false)
  end

  def ==(other)
    if other.is_a?(IdentityProvider)
      simple_id == other.simple_id &&
        entity_id == other.entity_id &&
        levels_of_assurance == other.levels_of_assurance &&
        authentication_enabled == other.authentication_enabled &&
        temporarily_unavailable == other.temporarily_unavailable
    else
      super
    end
  end

  alias_method :eql?, :==

  def hash
    simple_id.hash + entity_id.hash + levels_of_assurance.hash + authentication_enabled.hash + temporarily_unavailable.hash
  end

  def self.from_session(object)
    return object if object.is_a? IdentityProvider

    if object.is_a?(Hash) || (object.is_a?(SelectedProviderData) && object.is_selected_verify_idp?)
      new('simpleId' => object['simple_id'],
          'entityId' => object['entity_id'],
          'levelsOfAssurance' => object['levels_of_assurance'],
          'authenticationEnabled' => object['authentication_enabled'],
          'temporarilyUnavailable' => object['temporarily_unavailable'])
    end
  end
end
{'fraction_non_alphanumeric': 0.10973724884080371, 'fraction_numerical': 0.0006182380216383308, 'mean_word_length': 4.768270944741533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6863890', 'n_tokens_mistral': 1009, 'n_tokens_neox': 987, 'n_words': 165}