<commit_before># encoding: utf-8

namespace :metrics do
  begin
    require 'backports'
    require 'flog'
    require 'flog_cli'

    project = Devtools.project
    config  = project.flog

    if config.enabled?
      # original code by <NAME>:
      # http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html
      desc 'Analyze for code complexity'
      task :flog do
        threshold = config.threshold.to_f.round(1)
        flog      = Flog.new
        flog.flog(*FlogCLI.expand_dirs_to_files(project.lib_dir))

        totals = flog.totals.select  { |name, score| name[-5, 5] != '#none' }
                            .map     { |name, score| [name, score.round(1)] }
                            .sort_by { |name, score| score }

        if totals.any?
          max = totals.last[1]
          unless max >= threshold<commit_msg>Change flog task to only run under ruby 2.0<commit_after># encoding: utf-8

namespace :metrics do
  begin
    require 'backports'
    require 'flog'
    require 'flog_cli'

    project = Devtools.project
    config  = project.flog

    compatible_scores = %w(mri-2.0.0)

    if ! compatible_scores.include?(Devtools.rvm)
      task :flog do
        $stderr.puts "Flog is disabled under #{Devtools.rvm}"
      end
    elsif config.enabled?
      # original code by <NAME>:
      # http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html
      desc 'Analyze for code complexity'
      task :flog do
        threshold = config.threshold.to_f.round(1)
        flog      = Flog.new
        flog.flog(*FlogCLI.expand_dirs_to_files(project.lib_dir))

        totals = flog.totals.select  { |name, score| name[-5, 5] != '#none' }
                            .map     { |name, score| [name, score.round(1)] }
                            .sort_by { |name, score| score }

        if totals.any?
          max = totals.last[1]
          unless max >= threshold
{'fraction_non_alphanumeric': 0.1145397489539749, 'fraction_numerical': 0.015167364016736401, 'mean_word_length': 2.007861635220126, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4085771', 'n_tokens_mistral': 646, 'n_tokens_neox': 619, 'n_words': 141}