Class: Danger::DangerPmd
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerPmd
- Defined in:
- lib/pmd/plugin.rb
Overview
Checks on your Gradle project’s Java source files. This is done using [PMD](pmd.github.io) Results are passed out as tables in markdown.
Instance Attribute Summary collapse
-
#gradle_task ⇒ String
A getter for ‘gradle_task`, returning ’pmd’ if value is nil.
-
#report_file ⇒ String
A getter for ‘report_file`, returning ’app/build/reports/pmd/pmd.xml’ if value is nil.
-
#report_files ⇒ Array[String]
A getter for ‘report_files`, returning [’app/build/reports/pmd/pmd.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 PMD task of your Gradle project.
Instance Attribute Details
#gradle_task ⇒ String
A getter for ‘gradle_task`, returning ’pmd’ if value is nil.
52 53 54 |
# File 'lib/pmd/plugin.rb', line 52 def gradle_task @gradle_task ||= 'pmd' end |
#report_file ⇒ String
A getter for ‘report_file`, returning ’app/build/reports/pmd/pmd.xml’ if value is nil.
94 95 96 |
# File 'lib/pmd/plugin.rb', line 94 def report_file @report_file ||= 'app/build/reports/pmd/pmd.xml' end |
#report_files ⇒ Array[String]
A getter for ‘report_files`, returning [’app/build/reports/pmd/pmd.xml’] if value is nil.
108 109 110 |
# File 'lib/pmd/plugin.rb', line 108 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.
80 81 82 |
# File 'lib/pmd/plugin.rb', line 80 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.
66 67 68 |
# File 'lib/pmd/plugin.rb', line 66 def skip_gradle_task @skip_gradle_task ||= false end |
Instance Method Details
#report(inline_mode: true) ⇒ Array[PmdFile]
Calls PMD 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.
120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/pmd/plugin.rb', line 120 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 PMD report files for #{report_files} inside current directory") if .empty? do_comment(, inline_mode) end |