lib/pmd/plugin.rb in danger-pmd-0.1.0 vs lib/pmd/plugin.rb in danger-pmd-0.1.1

- old
+ new

@@ -7,17 +7,17 @@ # # @example Running PMD with its basic configuration # # pmd.report # - # @example Running PMD with a specific Gradle task or report file + # @example Running PMD with a specific Gradle task or report file (glob accepted) # # pmd.gradle_task = 'app:pmd' #defalut: pmd - # pmd.report_file = "app/build/reports/pmd/pmd.xml" + # pmd.report_file = "module/build/reports/pmd/pmd.xml" #defalut: app/build/reports/pmd/pmd.xml # pmd.report # - # @example Running PMD with an array of report files + # @example Running PMD with an array of report files (glob accepted) # # pmd.report_files = ["modules/**/build/reports/pmd/pmd.xml", "app/build/reports/pmd/pmd.xml"] # pmd.report # # @example Running PMD without running a Gradle task @@ -67,11 +67,11 @@ @report_file ||= "app/build/reports/pmd/pmd.xml" end # Location of report files. # If your pmd task outputs to a different location, you can specify it here. - # Defaults to "app/build/reports/pmd/pmd.xml". + # Defaults to ["app/build/reports/pmd/pmd.xml"]. # @return [Array[String]] attr_writer :report_files # A getter for `report_files`, returning ["app/build/reports/pmd/pmd.xml"] if value is nil. # @return [Array[String]] @@ -89,19 +89,13 @@ return fail("Could not find `gradlew` inside current directory") unless gradlew_exists? exec_gradle_task end - report_files_flatten = [] - report_files.each do |report_file| - Dir.glob(report_file).sort.each do |report_file_glob| - return fail("PMD report file not found #{report_file_glob}") unless report_file_exist?(report_file_glob) + report_files_expanded = Dir.glob(report_files).sort + return fail("Could not find matching PMD report files for #{report_files} inside current directory") if report_files_expanded.empty? - report_files_flatten.push(report_file_glob) - end - end - - report_and_send_inline_comment(report_files_flatten, inline_mode) + report_and_send_inline_comment(report_files_expanded, inline_mode) end private # Check gradlew file exists in current directory.