<commit_before>require 'fastlane_core/configuration/config_item'
require 'fastlane_core/configuration/commander_generator'
require 'fastlane_core/configuration/configuration_file'

module FastlaneCore
  class Configuration

    attr_accessor :available_options

    attr_accessor :values

    # @return [Array] An array of symbols which are all available keys
    attr_reader :all_keys

    # @return [String] The name of the configuration file (not the path). Optional!
    attr_accessor :config_file_name

    def self.create(available_options, values)
      Configuration.new(available_options, values)
    end

    #####################################################
    # @!group Setting up the configuration
    #####################################################

    def initialize(available_options, values)
      self.available_options = available_options || []
      self.values = values || {}

      verify_input_types
      verify_value_exists
      verify_no_duplicates
      verify_default_value_matches_verify_block
    end

    def verify_input_types
      raise "available_options parameter must be an array of ConfigItems but is #{@available_options.class}".red unless @available_options.kind_of? Array
      @available_options.each do |item|
        raise "available_options parameter must be an array of ConfigItems. Found #{item.class}.".red unless item.kind_of? ConfigItem
      end
      raise "values parameter must be a hash".red unless @values.kind_of? Hash
    end

    def verify_value_exists
      # Make sure the given value keys exist
      @values.each do |key, value|
        option = option_for_key(key)
        if option
          option.verify!(value) # Call the verify block for it too
        else
          raise "Could not find option '#{key}' in the list of available options: #{@available_options.collect(&:key).join(', ')}".red
        end
      end
    end

    def verify_no_duplicates
      # Make sure a key was not used multiple times
      @available_options.each do |current|
        count = @available_options.count { |option| option.key == current.key }
        raise "Multiple entries for configuration key '#{current.key}' found!".red if count > 1

        unless current.short_option.to_s.empty?
          count = @available_options.count { |option| option.short_option == current.short_option }
          raise "Multiple entries for short_option '#{current.short_option}' found!".red if count > 1
        end
      end
    end

    # Verifies the default value is also valid
    def verify_default_value_matches_verify_block
      @available_options.each do |item|
        next unless item.verify_block && item.default_value
<commit_msg>Skipped checking of :trace key in config manager<commit_after>require 'fastlane_core/configuration/config_item'
require 'fastlane_core/configuration/commander_generator'
require 'fastlane_core/configuration/configuration_file'

module FastlaneCore
  class Configuration

    attr_accessor :available_options

    attr_accessor :values

    # @return [Array] An array of symbols which are all available keys
    attr_reader :all_keys

    # @return [String] The name of the configuration file (not the path). Optional!
    attr_accessor :config_file_name

    def self.create(available_options, values)
      Configuration.new(available_options, values)
    end

    #####################################################
    # @!group Setting up the configuration
    #####################################################

    def initialize(available_options, values)
      self.available_options = available_options || []
      self.values = values || {}

      verify_input_types
      verify_value_exists
      verify_no_duplicates
      verify_default_value_matches_verify_block
    end

    def verify_input_types
      raise "available_options parameter must be an array of ConfigItems but is #{@available_options.class}".red unless @available_options.kind_of? Array
      @available_options.each do |item|
        raise "available_options parameter must be an array of ConfigItems. Found #{item.class}.".red unless item.kind_of? ConfigItem
      end
      raise "values parameter must be a hash".red unless @values.kind_of? Hash
    end

    def verify_value_exists
      # Make sure the given value keys exist
      @values.each do |key, value|
        next if key == :trace # special treatment

        option = option_for_key(key)
        if option
          option.verify!(value) # Call the verify block for it too
        else
          raise "Could not find option '#{key}' in the list of available options: #{@available_options.collect(&:key).join(', ')}".red
        end
      end
    end

    def verify_no_duplicates
      # Make sure a key was not used multiple times
      @available_options.each do |current|
        count = @available_options.count { |option| option.key == current.key }
        raise "Multiple entries for configuration key '#{current.key}' found!".red if count > 1

        unless current.short_option.to_s.empty?
          count = @available_options.count { |option| option.short_option == current.short_option }
          raise "Multiple entries for short_option '#{current.short_option}' found!".red if count > 1
        end
      end
    end

    # Verifies the default value is also valid
    def verify_default_value_matches_verify_block
      @available_options.each do |item|
        next unless item.verify_block && item.default_value

{'fraction_non_alphanumeric': 0.10853703028091938, 'fraction_numerical': 0.0007296607077708865, 'mean_word_length': 3.3481363996827915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6030855', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1411, 'n_words': 451}