spotbugs-up.rb 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ## Script originally from https://github.com/tir38/android-lint-entropy-reducer at 07.05.2017
  2. # heavily modified since then
  3. Encoding.default_external = Encoding::UTF_8
  4. Encoding.default_internal = Encoding::UTF_8
  5. puts "=================== starting Android Spotbugs Entropy Reducer ===================="
  6. # get args
  7. base_branch = ARGV[0]
  8. require 'fileutils'
  9. require 'pathname'
  10. require 'open3'
  11. # run Spotbugs
  12. puts "running Spotbugs..."
  13. system './gradlew spotbugsGplayDebug 1>/dev/null 2>&1'
  14. # find number of warnings
  15. current_warning_count = `./scripts/analysis/spotbugsSummary.py --total`.to_i
  16. puts "found warnings: " + current_warning_count.to_s
  17. # get warning counts from target branch
  18. previous_xml = "/tmp/#{base_branch}.xml"
  19. previous_results = File.file?(previous_xml)
  20. if previous_results == true
  21. previous_warning_count = `./scripts/analysis/spotbugsSummary.py --total --file #{previous_xml}`.to_i
  22. puts "previous warnings: " + previous_warning_count.to_s
  23. end
  24. # compare previous warning count with current warning count
  25. if previous_results == true && current_warning_count > previous_warning_count
  26. puts "FAIL: warning count increased"
  27. exit 1
  28. end
  29. # check if warning and error count stayed the same
  30. if previous_results == true && current_warning_count == previous_warning_count
  31. puts "SUCCESS: count stayed the same"
  32. exit 0
  33. end
  34. # warning count DECREASED
  35. if previous_results == true && current_warning_count < previous_warning_count
  36. puts "SUCCESS: count decreased from " + previous_warning_count.to_s + " to " + current_warning_count.to_s
  37. end