<commit_before>module ReportCard
  class Grader
    attr_reader :project, :config, :scores, :old_scores

    def initialize(project, config)
      @project = project
      @config = config
    end

    def grade
      return unless ready?
      STDERR.puts ">> Building metrics for #{project.name}"
      configure
      generate
      wrapup if success?
    end

    def wrapup
      score
      notify if score_changed?
    end

    def ready?
      dir = Integrity::ProjectBuilder.new(project).send(:export_directory)
      if File.exist?(dir)
        Dir.chdir dir
      else
        STDERR.puts ">> Skipping, directory does not exist: #{dir}"
      end
    end

    def configure
      ENV['CC_BUILD_ARTIFACTS'] = self.output_path
      MetricFu::Configuration.run do |config|
        config.reset
        config.data_directory = self.archive_path
        config.template_class = AwesomeTemplate
        config.metrics = config.graphs = [:flog, :flay, :rcov, :reek, :roodi]
        config.rcov     = { :test_files => ['test/**/*_test.rb', 'spec/**/*_spec.rb'],
                            :rcov_opts  => ["--sort coverage",
                            "--no-html",
                            "--text-coverage",
                            "--no-color",
                            "--profile",
                            "--rails",
                            "--include test",
                            "--exclude /gems/,/usr/local/lib/site_ruby/1.8/,spec"]}
      end
      MetricFu.report.instance_variable_set(:@report_hash, {})<commit_msg>Moving the build message into #ready? so #grade is clean<commit_after>module ReportCard
  class Grader
    attr_reader :project, :config, :scores, :old_scores

    def initialize(project, config)
      @project = project
      @config = config
    end

    def grade
      return unless ready?
      configure
      generate
      wrapup if success?
    end

    def wrapup
      score
      notify if score_changed?
    end

    def ready?
      dir = Integrity::ProjectBuilder.new(project).send(:export_directory)
      if File.exist?(dir)
        STDERR.puts ">> Building metrics for #{project.name}"
        Dir.chdir dir
      else
        STDERR.puts ">> Skipping, directory does not exist: #{dir}"
      end
    end

    def configure
      ENV['CC_BUILD_ARTIFACTS'] = self.output_path
      MetricFu::Configuration.run do |config|
        config.reset
        config.data_directory = self.archive_path
        config.template_class = AwesomeTemplate
        config.metrics = config.graphs = [:flog, :flay, :rcov, :reek, :roodi]
        config.rcov     = { :test_files => ['test/**/*_test.rb', 'spec/**/*_spec.rb'],
                            :rcov_opts  => ["--sort coverage",
                            "--no-html",
                            "--text-coverage",
                            "--no-color",
                            "--profile",
                            "--rails",
                            "--include test",
                            "--exclude /gems/,/usr/local/lib/site_ruby/1.8/,spec"]}
      end
      MetricFu.report.instance_variable_set(:@report_hash, {})
{'fraction_non_alphanumeric': 0.11583624246271025, 'fraction_numerical': 0.0012694382735639479, 'mean_word_length': 1.622296173044925, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6855133', 'n_tokens_mistral': 900, 'n_tokens_neox': 860, 'n_words': 199}