Skip to content

Instantly share code, notes, and snippets.

@emanuil
Created March 4, 2015 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emanuil/f8d955cc337696ee10f8 to your computer and use it in GitHub Desktop.
Save emanuil/f8d955cc337696ee10f8 to your computer and use it in GitHub Desktop.
#!/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