<commit_before># frozen_string_literal: true

namespace :coverband do
  # TODO: FixMe before releasing 4.2.1
  # This was previously needed when Coverband was generally require false
  # now this would double configure, which isn't a good thing
  # I think we need ot make it safe to call configure twice and no-op if it has been called
  # because removing this means if you have require: false on coverband or
  # COVERBAND_DISABLE_AUTO_START=true the rake tasks wouldn't work
  # Coverband.configure

  def environment
    Coverband.configuration.report_on_exit = false
    Rake.application['environment'].invoke if Rake::Task.task_defined?('environment')
  end

  desc 'report runtime Coverband code coverage'
  task :coverage do
    environment
    if Coverband.configuration.reporter == 'scov'
      Coverband::Reporters::HTMLReport.new(Coverband.configuration.store).report
    else
      Coverband::Reporters::ConsoleReport.report(Coverband.configuration.store)
    end
  end

  desc 'report runtime Coverband code coverage'
  task :coverage_server do
    environment
    Rack::Server.start app: Coverband::Reporters::Web.new, Port: ENV.fetch('COVERBAND_COVERAGE_PORT', 1022).to_i
  end

  ###
  # clear data helpful for development or after configuration issues
  ###
  desc 'reset Coverband coverage data, helpful for development, debugging, etc'<commit_msg>disable background thread as well<commit_after># frozen_string_literal: true

namespace :coverband do
  # TODO: FixMe before releasing 4.2.1
  # This was previously needed when Coverband was generally require false
  # now this would double configure, which isn't a good thing
  # I think we need ot make it safe to call configure twice and no-op if it has been called
  # because removing this means if you have require: false on coverband or
  # COVERBAND_DISABLE_AUTO_START=true the rake tasks wouldn't work
  # Coverband.configure

  def environment
    Coverband.configuration.report_on_exit = false
    Coverband.configuration.background_reporting_enabled = false
    Rake.application['environment'].invoke if Rake::Task.task_defined?('environment')
  end

  desc 'report runtime Coverband code coverage'
  task :coverage do
    environment
    if Coverband.configuration.reporter == 'scov'
      Coverband::Reporters::HTMLReport.new(Coverband.configuration.store).report
    else
      Coverband::Reporters::ConsoleReport.report(Coverband.configuration.store)
    end
  end

  desc 'report runtime Coverband code coverage'
  task :coverage_server do
    environment
    Rack::Server.start app: Coverband::Reporters::Web.new, Port: ENV.fetch('COVERBAND_COVERAGE_PORT', 1022).to_i
  end

  ###
  # clear data helpful for development or after configuration issues
  ###
  desc 'reset Coverband coverage data, helpful for development, debugging, etc'
{'fraction_non_alphanumeric': 0.07266926621765331, 'fraction_numerical': 0.004962779156327543, 'mean_word_length': 4.4689922480620154, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2985327', 'n_tokens_mistral': 790, 'n_tokens_neox': 766, 'n_words': 267}