Class: Danger::DangerSpotbugs
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerSpotbugs
- Defined in:
- lib/spotbugs/plugin.rb
Overview
Checks on your Gradle project’s Java source files. This is done using [SpotBugs](spotbugs.github.io) Results are passed out as tables in markdown.
Instance Attribute Summary collapse
-
#gradle_task ⇒ String
A getter for ‘gradle_task`, returning ’spotbugsRelease’ if value is nil.
-
#report_file ⇒ String
A getter for ‘report_file`, returning ’app/build/reports/spotbugs/release.xml’ if value is nil.
-
#report_files ⇒ Array[String]
A getter for ‘report_files`, returning [’app/build/reports/spotbugs/release.xml’] if value is nil.
-
#root_path ⇒ String
A getter for ‘root_path`, returning result of `git rev-parse –show-toplevel` if value is nil.
-
#skip_gradle_task ⇒ Boolean
A getter for ‘skip_gradle_task`, returning false if value is nil.
Instance Method Summary collapse
-
#report(inline_mode: true) ⇒ Array[PmdFile]
Calls SpotBugs task of your Gradle project.
Instance Attribute Details
#gradle_task ⇒ String
A getter for ‘gradle_task`, returning ’spotbugsRelease’ if value is nil.
53 54 55 |
# File 'lib/spotbugs/plugin.rb', line 53 def gradle_task @gradle_task ||= 'spotbugsRelease' end |
#report_file ⇒ String
A getter for ‘report_file`, returning ’app/build/reports/spotbugs/release.xml’ if value is nil.
95 96 97 |
# File 'lib/spotbugs/plugin.rb', line 95 def report_file @report_file ||= 'app/build/reports/spotbugs/release.xml' end |
#report_files ⇒ Array[String]
A getter for ‘report_files`, returning [’app/build/reports/spotbugs/release.xml’] if value is nil.
109 110 111 |
# File 'lib/spotbugs/plugin.rb', line 109 def report_files @report_files ||= [report_file] end |
#root_path ⇒ String
A getter for ‘root_path`, returning result of `git rev-parse –show-toplevel` if value is nil.
81 82 83 |
# File 'lib/spotbugs/plugin.rb', line 81 def root_path @root_path ||= `git rev-parse --show-toplevel`.chomp end |
#skip_gradle_task ⇒ Boolean
A getter for ‘skip_gradle_task`, returning false if value is nil.
67 68 69 |
# File 'lib/spotbugs/plugin.rb', line 67 def skip_gradle_task @skip_gradle_task ||= false end |
Instance Method Details
#report(inline_mode: true) ⇒ Array[PmdFile]
Calls SpotBugs task of your Gradle project. It fails if ‘gradlew` cannot be found inside current directory. It fails if `report_file` cannot be found inside current directory. It fails if `report_files` is empty.
121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/spotbugs/plugin.rb', line 121 def report(inline_mode: true) unless skip_gradle_task raise('Could not find `gradlew` inside current directory') unless gradlew_exists? exec_gradle_task end = Dir.glob(report_files).sort raise("Could not find matching SpotBugs report files for #{report_files} inside current directory") if .empty? do_comment(, inline_mode) end |