<commit_before>module RubyLint
  module Analyze
    class Definitions < Iterator
      ##
      # Array of variable types that should be exported to the outer scope of a
      # method definition.
      #
      # @return [Array]
      #
      EXPORT_VARIABLES = [:instance_variable, :class_variable, :constant]

      ##
      # Hash containing the definition types to copy when including/extending a
      # module.
      #
      # @return [Hash]
      #
      INCLUDE_CALLS = {
        'include' => {
          :constant        => :constant,
          :instance_method => :instance_method
        },
        'extend' => {
          :constant        => :constant,
          :instance_method => :method
        }
      }

      ##
      # Called at the root node of a Ruby script.
      #
      # @param [RubyLint::Node] node
      #
      def on_root(node)
        object = RubyLint::Importer.import(
          'Object',
          Object,
          :ancestors => true
        )

        # No need to store all the child nodes as those are processed
        # individually.
        @options[:definitions] = Definition::RubyObject.new(
          node.updated(nil, []),
          :kernel  => true,
          :lazy    => true,
          :parents => [object]
        )
      end

      ##
      # Creates a new module definition and updates the scope accordingly. If
      # the module already exists the existing set of definitions is used
      # instead of creating a new one.
      #
      # @param [RubyLint::Node] node
      #
      def on_module(node)
        scope    = definitions
        mod_def  = Definition::RubyVariable.new(node, nil, :parents => [scope])
        existing = scope.lookup(:constant, mod_def.name)

        # Use the existing definition list.
        if existing
          existing.parents << scope unless existing.parents.include?(scope)
          @definitions     << existing

          return
        end

        scope.add(:constant, mod_def.name, mod_def)

        @definitions << mod_def
      end
<commit_msg>Fix for loading Kernel by default.<commit_after>module RubyLint
  module Analyze
    class Definitions < Iterator
      ##
      # Array of variable types that should be exported to the outer scope of a
      # method definition.
      #
      # @return [Array]
      #
      EXPORT_VARIABLES = [:instance_variable, :class_variable, :constant]

      ##
      # Hash containing the definition types to copy when including/extending a
      # module.
      #
      # @return [Hash]
      #
      INCLUDE_CALLS = {
        'include' => {
          :constant        => :constant,
          :instance_method => :instance_method
        },
        'extend' => {
          :constant        => :constant,
          :instance_method => :method
        }
      }

      ##
      # Called at the root node of a Ruby script.
      #
      # @param [RubyLint::Node] node
      #
      def on_root(node)
        object = RubyLint::Importer.import(
          'Object',
          Object,
          :ancestors => true
        )

        # No need to store all the child nodes as those are processed
        # individually.
        @options[:definitions] = Definition::RubyObject.new(
          node.updated(nil, []),
          :default_constants => ['Kernel'],
          :lazy              => true,
          :parents           => [object]
        )
      end

      ##
      # Creates a new module definition and updates the scope accordingly. If
      # the module already exists the existing set of definitions is used
      # instead of creating a new one.
      #
      # @param [RubyLint::Node] node
      #
      def on_module(node)
        scope    = definitions
        mod_def  = Definition::RubyVariable.new(node, nil, :parents => [scope])
        existing = scope.lookup(:constant, mod_def.name)

        # Use the existing definition list.
        if existing
          existing.parents << scope unless existing.parents.include?(scope)
          @definitions     << existing

          return
        end

        scope.add(:constant, mod_def.name, mod_def)

        @definitions << mod_def
      end

{'fraction_non_alphanumeric': 0.09301763711041314, 'fraction_numerical': 0.0, 'mean_word_length': 1.7236842105263157, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, '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': '5883158', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1090, 'n_words': 325}