<commit_before>#!/usr/bin/ruby
# This software is in the public domain, furnished "as is", without technical
# support, and with no warranty, express or implied, as to its usefulness for
# any purpose.

$:.push(File.expand_path(__FILE__+'/../..'))
require 'test/unit'
require 'global'
require 'formula'
require 'utils'


class WellKnownCodeIssues <Test::Unit::TestCase
  def test_formula_names
    # Formula names should be valid
    nostdout do
      Dir["#{HOMEBREW_PREFIX}/Library/Formula/*.rb"].each do |f|
        assert_nothing_raised do
          Formula.factory f
        end
      end
    end
  end

  def test_for_commented_out_cmake
    # Formulas shouldn't contain commented-out cmake code from the default template
    Formulary.paths.each do |f|
      result = `grep "# depends_on 'cmake'" "#{f}"`.strip
      assert_equal('', result, "Commented template code still in #{f}")
    end
  end
  
  def test_for_misquoted_prefix
    # Prefix should not have single quotes if the system args are already separated
    target_string = "[\\\"]--prefix=[\\']"
    
    Formulary.paths.each do |f|
      result = `grep -e "#{target_string}" "#{f}"`.strip
      assert_equal('', result, "--prefix is incorrectly single-quoted in #{f}")
    end
  end
end
<commit_msg>Add formula check for crufy SourceForge URLs.<commit_after>#!/usr/bin/ruby
# This software is in the public domain, furnished "as is", without technical
# support, and with no warranty, express or implied, as to its usefulness for
# any purpose.

$:.push(File.expand_path(__FILE__+'/../..'))
require 'test/unit'
require 'global'
require 'formula'
require 'utils'


class WellKnownCodeIssues <Test::Unit::TestCase
  def test_formula_names
    # Formula names should be valid
    nostdout do
      Dir["#{HOMEBREW_PREFIX}/Library/Formula/*.rb"].each do |f|
        assert_nothing_raised do
          Formula.factory f
        end
      end
    end
  end

  def test_for_commented_out_cmake
    # Formulas shouldn't contain commented-out cmake code from the default template
    Formulary.paths.each do |f|
      result = `grep "# depends_on 'cmake'" "#{f}"`.strip
      assert_equal('', result, "Commented template code still in #{f}")
    end
  end
  
  def test_for_misquoted_prefix
    # Prefix should not have single quotes if the system args are already separated
    target_string = "[\\\"]--prefix=[\\']"
    
    Formulary.paths.each do |f|
      result = `grep -e "#{target_string}" "#{f}"`.strip
      assert_equal('', result, "--prefix is incorrectly single-quoted in #{f}")
    end
  end
  
  def test_for_crufy_sourceforge_url
    # Don't specify mirror for SourceForge downloads
    Formulary.paths.each do |f|
      result = `grep "\?use_mirror=" "#{f}"`.strip
      assert_equal('', result, "Remove 'use_mirror' from url for #{f}")
    end
  end
end

{'fraction_non_alphanumeric': 0.11785462244177841, 'fraction_numerical': 0.0, 'mean_word_length': 3.2440119760479043, 'pattern_counts': {'":': 0, '<': 5, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5883784', 'n_tokens_mistral': 907, 'n_tokens_neox': 873, 'n_words': 283}