spotbugs-up.rb 1.8 KB

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