<commit_before>module RealWorldRails
  module Inspectors

    class ConstantsInspector
      def run
        parser = ParserFactory.create
        # files = Dir.glob("apps/**/*.rb")
        files = Dir.glob("apps/24pullrequests/app/**/*.rb")
        processor = Processor.new
        files.each do |filename|
          buffer = Parser::Source::Buffer.new filename
          buffer.read
          ast = parser.reset.parse(buffer)
          processor.process(ast)
        end
      end
    end

    class Processor < Parser::AST::Processor
<commit_msg>ConstantsInspector now excludes troublesome files<commit_after>require_relative 'file_inspector'

module RealWorldRails
  module Inspectors

    class ConstantsInspector
      def run
        parser = ParserFactory.create
        files = Dir.glob("apps/**/**/*.rb")
        processor = Processor.new
        files.each do |filename|
          if inspectable?(filename)
            buffer = Parser::Source::Buffer.new filename
            buffer.read
            ast = parser.reset.parse(buffer)
            processor.process(ast)
          end
        end
      end

      def inspectable?(filename)
        !FileInspector.from_gem?(filename) && !FileInspector.test?(filename) && !FileInspector.from_generator?(filename)
      end
    end

    class Processor < Parser::AST::Processor

{'fraction_non_alphanumeric': 0.09662921348314607, 'fraction_numerical': 0.00149812734082397, 'mean_word_length': 2.3233830845771144, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3104113', 'n_tokens_mistral': 366, 'n_tokens_neox': 361, 'n_words': 77}