#!/usr/bin/env ruby | |
require 'fileutils' | |
require 'json' | |
contents = JSON.parse(IO.read(ARGV[0])) | |
## There are error types that cause lots of false positives. HHVM is still not perfect for them and | |
## there is not much sense to mark the commit as failed because of the. As HHVM grows better, we need | |
## to reevaluate the detection of those errors again. | |
contents[1].delete('UnknownClass') | |
contents[1].delete('UseUndeclaredConstant') | |
contents[1].delete('PHPIncludeFileNotFound') | |
## These are the files to ignore errors reported on. Those reside in the external directory as those files | |
## are outside of our control. HHVM does not offer effective way to read declarations from them but to | |
## not look for errors in them. That's why they are manually removed from the results file | |
files_to_ignore = %w[libs/external] | |
## Remove entries from the external files | |
contents[1].each do |name_of_error, array_of_errors| | |
array_of_errors.delete_if {|error| files_to_ignore.any? { |w| error['c1'][0] =~ /#{w}/ }} | |
end | |
## Clear the empty error types | |
contents[1].delete_if {|name_of_error, array_of_errors| array_of_errors.empty?} | |
errors = 0 | |
puts "\n" | |
## Print the remaining errors | |
contents[1].each do |name_of_error, array_of_errors| | |
puts "#{name_of_error} in file:" | |
array_of_errors.each do |error| | |
# Temporary workaround until HHVM is fixed: https://github.com/facebook/hhvm/issues/2479 | |
next if error['d'].include? 'getTransitions' | |
puts "#{error['c1'][0]}, line: #{error['c1'][1]}, problem entry: #{error['d']}" | |
errors += 1 | |
end | |
puts "\n" | |
end | |
exit -1 unless errors == 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment