<commit_before>require 'ruby_parser'
require 'sexp_processor'
require_relative 'util/project_scanner'
require_relative 'analyzer/project_elements/class.rb'
require_relative 'analyzer/project_elements/method.rb'

module Analyzer
  class Analyzer < MethodBasedSexpProcessor
    def initialize
      super()
      self.auto_shift_type = true
      @classes = []
      @methods = []
      @smells = []
      @current_class = :none
    end

    def analyze(dir)
      parser = RubyParser.new
      paths = ProjectScanner.scan(dir)
      paths.each do |path|
        ast = parser.process(File.binread(path), path)
        process ast
        @current_class = :none
      end

      return @classes, @methods, @smells
    end

    #########################################
    # Process methods:

    def process_class(exp)
      class_name = exp.shift.to_s
      @classes << Class.new(class_name)
      @current_class = class_name
      exp.shift
      exp.shift
      process_until_empty exp
      s()
    end

    def process_defn(exp)
      method_name = exp.shift.to_s
      @methods << Method.new(method_name, @current_class)
      exp.shift
      exp.shift
      process_until_empty exp
      s()
    end

    def process_if(exp)
      s()
    end

  end
end
<commit_msg>Fix problem with exp autoshift in Analyzer<commit_after>require 'ruby_parser'
require 'sexp_processor'
require_relative 'util/project_scanner'
require_relative 'analyzer/project_elements/class.rb'
require_relative 'analyzer/project_elements/method.rb'

module Analyzer
  class Analyzer < MethodBasedSexpProcessor
    def initialize
      super()
      self.auto_shift_type = false
      @classes = []
      @methods = []
      @smells = []
      @current_class = :none
    end

    def analyze(dir)
      parser = RubyParser.new
      paths = ProjectScanner.scan(dir)
      paths.each do |path|
        ast = parser.process(File.binread(path), path)
        process ast
        @current_class = :none
      end

      return @classes, @methods, @smells
    end

    #########################################
    # Process methods:

    def process_class(exp)
      class_name = exp.shift.to_s
      @classes << Class.new(class_name)
      @current_class = class_name
      exp.shift
      exp.shift
      process_until_empty exp
      s()
    end

    def process_defn(exp)
      method_name = exp.shift.to_s
      @methods << Method.new(method_name, @current_class)
      exp.shift
      exp.shift
      process_until_empty exp
      s()
    end

    def process_if(exp)
      s()
    end

  end
end

{'fraction_non_alphanumeric': 0.1150855365474339, 'fraction_numerical': 0.0, 'mean_word_length': 2.5392022008253097, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, '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': '771601', 'n_tokens_mistral': 805, 'n_tokens_neox': 779, 'n_words': 172}