<commit_before>module FakeWebTestHelper
  def self.start_simplecov
    return unless RUBY_VERSION >= "1.9.0"
    return if !ENV['AUTOTEST'].nil?

    require 'simplecov'
    require 'simplecov-console'

    SimpleCov.start do
      add_filter "/test/"

      minimum_coverage 100 if FakeWebTestHelper.running_all_tests?

      if defined?(SIMPLECOV_COMMAND_NAME)
        command_name SIMPLECOV_COMMAND_NAME
      end

      if !ENV["COVERAGE_REPORT"].nil?
        formatter SimpleCov::Formatter::MultiFormatter[
          SimpleCov::Formatter::HTMLFormatter,
          SimpleCov::Formatter::Console
        ]
      else
        formatter SimpleCov::Formatter::Console
      end
    end
  end

  def self.running_all_tests?
    ENV['TEST'].nil?
  end
end

FakeWebTestHelper.start_simplecov<commit_msg>Refactor: move test code into a module<commit_after>module FakeWebTestHelper
  module CodeCoverage
    def start_simplecov
      return unless RUBY_VERSION >= "1.9.0"
      return if !ENV['AUTOTEST'].nil?

      require 'simplecov'
      require 'simplecov-console'

      SimpleCov.start do
        add_filter "/test/"

        minimum_coverage 100 if running_all_tests?

        if defined?(SIMPLECOV_COMMAND_NAME)
          command_name SIMPLECOV_COMMAND_NAME
        end

        if !ENV["COVERAGE_REPORT"].nil?
          formatter SimpleCov::Formatter::MultiFormatter[
            SimpleCov::Formatter::HTMLFormatter,
            SimpleCov::Formatter::Console
          ]
        else
          formatter SimpleCov::Formatter::Console
        end
      end
    end

    def running_all_tests?
      ENV['TEST'].nil?
    end

    extend self
  end
end

FakeWebTestHelper::CodeCoverage.start_simplecov
{'fraction_non_alphanumeric': 0.07863849765258216, 'fraction_numerical': 0.007042253521126761, 'mean_word_length': 2.7065217391304346, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2207958', 'n_tokens_mistral': 531, 'n_tokens_neox': 503, 'n_words': 102}