<commit_before>require "set"

module JsonSchema
  class ReferenceExpander
    attr_accessor :errors

    def expand(schema, options = {})
      @errors = []
      @schema = schema
      @store  = options[:store] ||= DocumentStore.new
      last_unresolved_refs = nil

      @store.add_uri_reference("/", schema)

      loop do
        traverse_schema(schema)

        refs = unresolved_refs(schema).sort

        # nothing left unresolved, we're done!
        if refs.count == 0
          break
        end

        # a new traversal pass still hasn't managed to resolve anymore
        # references; we're out of luck
        if refs == last_unresolved_refs
          message = %{Couldn't resolve references: #{refs.to_a.join(", ")}.}
          @errors << SchemaError.new(schema, message)
          break
        end

        last_unresolved_refs = refs
      end

      @errors.count == 0
    end<commit_msg>A loop is no longer required for reference resolution<commit_after>require "set"

module JsonSchema
  class ReferenceExpander
    attr_accessor :errors

    def expand(schema, options = {})
      @errors = []
      @schema = schema
      @store  = options[:store] ||= DocumentStore.new

      @store.add_uri_reference("/", schema)

      traverse_schema(schema)

      refs = unresolved_refs(schema).sort
      if refs.count > 0
        message = %{Couldn't resolve references: #{refs.to_a.join(", ")}.}
        @errors << SchemaError.new(schema, message)
      end

      @errors.count == 0
    end
{'fraction_non_alphanumeric': 0.10337972166998012, 'fraction_numerical': 0.0026507620941020544, 'mean_word_length': 2.363028953229399, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '655534', 'n_tokens_mistral': 456, 'n_tokens_neox': 423, 'n_words': 114}