<commit_before>require "todo_lint/options"

module TodoLint
  # Here we bring together all the pieces and see if it comes together
  class Cli
    # Startup the thing that actually checks the files for todos!
    # @example
    #   Cli.new(["-i", ".rb,.js"])
    # @api public
    def initialize(args) # rubocop:disable Metrics/AbcSize
      @options = Options.new.parse(args)
      if @options[:config_file]
        @options.merge!(ConfigFile.new.read_config_file(@options[:config_file]))
      elsif File.exist?("./.todo_lint.yml")
        @options.merge!(ConfigFile.new.read_config_file("./.todo_lint.yml"))
      end
      @path = File.expand_path(".")
      add_default_extensions unless @options.fetch(:files, []).any?
    end

    # @example
    #   Cli.new(["-i", ".rb"]).run!
    # @return exit code 0 for success, 1 for failure
    # @api public
    # rubocop:disable Metrics/AbcSize
    def run! # rubocop:disable Metrics/MethodLength
      finder = FileFinder.new(path, options)
      files = load_files(finder)
      files_count = files.count
      reports = files.map do |file|
        Todo.within(File.open(file)).map do |todo|
          reporter = Reporter.new(todo,
                                  :path => file,
                                  :judge => Judge.new(todo))
          reporter.report.tap do |report|
            print Rainbow(".").public_send(report.nil? ? :green : :red)
          end
        end
      end.flatten.compact
      if reports.any?
        reports.each do |report|
          puts report
        end
        puts "\nFound #{pluralize('problematic todo', reports.count)} in " \
          "#{pluralize('file', files_count)}"
        exit 1<commit_msg>Fix an awkwrd missing space after the dots<commit_after>require "todo_lint/options"

module TodoLint
  # Here we bring together all the pieces and see if it comes together
  class Cli
    # Startup the thing that actually checks the files for todos!
    # @example
    #   Cli.new(["-i", ".rb,.js"])
    # @api public
    def initialize(args) # rubocop:disable Metrics/AbcSize
      @options = Options.new.parse(args)
      if @options[:config_file]
        @options.merge!(ConfigFile.new.read_config_file(@options[:config_file]))
      elsif File.exist?("./.todo_lint.yml")
        @options.merge!(ConfigFile.new.read_config_file("./.todo_lint.yml"))
      end
      @path = File.expand_path(".")
      add_default_extensions unless @options.fetch(:files, []).any?
    end

    # @example
    #   Cli.new(["-i", ".rb"]).run!
    # @return exit code 0 for success, 1 for failure
    # @api public
    # rubocop:disable Metrics/AbcSize
    def run! # rubocop:disable Metrics/MethodLength
      finder = FileFinder.new(path, options)
      files = load_files(finder)
      files_count = files.count
      reports = files.map do |file|
        Todo.within(File.open(file)).map do |todo|
          reporter = Reporter.new(todo,
                                  :path => file,
                                  :judge => Judge.new(todo))
          reporter.report.tap do |report|
            print Rainbow(".").public_send(report.nil? ? :green : :red)
          end
        end
      end.flatten.compact
      if reports.any?
        puts
        reports.each do |report|
          puts report
        end
        puts "\nFound #{pluralize('problematic todo', reports.count)} in " \
          "#{pluralize('file', files_count)}"
        exit 1
{'fraction_non_alphanumeric': 0.12456344586728754, 'fraction_numerical': 0.0017462165308498253, 'mean_word_length': 2.233301975540922, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3352810', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1045, 'n_words': 251}