<commit_before>class JSONCompareTests < Test::Unit::TestCase
  include BrakemanTester::DiffHelper

  def setup
    @path = File.expand_path "#{TEST_PATH}/apps/rails3.2"
    @json_path = File.join @path, "report.json"
    File.delete @json_path if File.exist? @json_path
    Brakeman.run :app_path => @path, :output_files => [@json_path]
    @report = MultiJson.load File.read(@json_path)
  end

  def update_json
    File.open @json_path, "w" do |f|
      f.puts @report.to_json
    end
  end

  def diff
    @diff = Brakeman.compare :app_path => @path, :previous_results_json => @json_path
  end

  def test_sanity
    diff
<commit_msg>Clean up JSON file from tests<commit_after>class JSONCompareTests < Test::Unit::TestCase
  include BrakemanTester::DiffHelper

  def setup
    @path = File.expand_path "#{TEST_PATH}/apps/rails3.2"
    @json_path = File.join @path, "report.json"
    File.delete @json_path if File.exist? @json_path
    Brakeman.run :app_path => @path, :output_files => [@json_path]
    @report = MultiJson.load File.read(@json_path)
  end

  def teardown
    File.delete @json_path if File.exist? @json_path
  end

  def update_json
    File.open @json_path, "w" do |f|
      f.puts @report.to_json
    end
  end

  def diff
    @diff = Brakeman.compare :app_path => @path, :previous_results_json => @json_path
  end

  def test_sanity
    diff

{'fraction_non_alphanumeric': 0.11355311355311355, 'fraction_numerical': 0.0029304029304029304, 'mean_word_length': 3.568561872909699, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5301963', 'n_tokens_mistral': 496, 'n_tokens_neox': 482, 'n_words': 115}