<commit_before>IE_SELECTOR_LIMIT = 4095

namespace :css_counter do
  task default: :check_selectors

  desc "Ensure no compiled CSS file has more than 4095 selectors"
  task check_selectors: [:environment] do
    sprockets = Rails.application.assets

    css_paths = %w{application.css}
    css_paths += Rails.application.config.assets.precompile.select { |item|
      item.is_a?(String) && item[-4,4] == ".css"
    }
    css_paths.each do |path|
      css = sprockets[path].body
      selector_count = CssCounter.new(css).selectors
      if selector_count > IE_SELECTOR_LIMIT
        $stderr.puts "#{path} has #{selector_count} CSS selectors, must not exceed #{IE_SELECTOR_LIMIT}"
        exit(1)
      end
    end
  end
end<commit_msg>print output for all CSS files<commit_after>IE_SELECTOR_LIMIT = 4095

namespace :css_counter do
  task default: :check_selectors

  desc "Ensure no compiled CSS file has more than 4095 selectors"
  task check_selectors: [:environment] do
    sprockets = Rails.application.assets

    css_paths = %w{application.css}
    css_paths += Rails.application.config.assets.precompile.select { |item|
      item.is_a?(String) && item[-4,4] == ".css"
    }
    exit_non_zero = false
    css_paths.each do |path|
      css = sprockets[path].body
      selector_count = CssCounter.new(css).selectors
      if selector_count > IE_SELECTOR_LIMIT
        $stderr.puts "#{path} has #{selector_count} CSS selectors, must not exceed #{IE_SELECTOR_LIMIT}"
        exit_non_zero = true
      else
        puts "#{path} has #{selector_count} CSS selectors"
      end
    end

    exit(1) if exit_non_zero
  end
end
{'fraction_non_alphanumeric': 0.09938650306748466, 'fraction_numerical': 0.013496932515337423, 'mean_word_length': 3.3609625668449197, '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': '4604140', 'n_tokens_mistral': 543, 'n_tokens_neox': 534, 'n_words': 133}