Skip to content

mathroule/danger-pmd

Repository files navigation

Danger PMD

Latest release License: MIT Deploy codecov

Checks on your Gradle project's Java source files. This is done using PMD Results are passed out as tables in markdown.

This plugin is inspired from https://github.com/kazy1991/danger-findbugs.

Installation

$ gem install danger-pmd

Usage

Methods and attributes from this plugin are available in
your `Dangerfile` under the `pmd` namespace.
Running PMD with its basic configuration
pmd.report
  
Running PMD with a specific Gradle task or report file (glob accepted)
pmd.gradle_task = 'module:pmd' # default: 'pmd'
pmd.report_file = 'module/build/reports/pmd/pmd.xml' # default: 'app/build/reports/pmd/pmd.xml'
pmd.report
  
Running PMD with a specific root path
pmd.root_path = '/Users/developer/project' # default: result of `git rev-parse --show-toplevel`
pmd.report
  
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
  
Running PMD without running a Gradle task
pmd.skip_gradle_task = true # default: false
pmd.report
  
Running PMD without inline comment
pmd.report(inline_mode: false) # default: true
  

Attributes

gradle_task - Custom Gradle task to run. This is useful when your project has different flavors. Defaults to "pmd".

skip_gradle_task - Skip Gradle task. If you skip Gradle task, for example project does not manage Gradle. Defaults to false.

root_path - An absolute path to a root. To comment errors to VCS, this needs to know relative path of files from the root. Defaults to result of "git rev-parse --show-toplevel".

report_file - Location of report file. If your pmd task outputs to a different location, you can specify it here. Defaults to "app/build/reports/pmd/pmd.xml".

report_files - 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'].

Methods

report - 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.

gradle_task - A getter for gradle_task, returning Gradle task report.

skip_gradle_task - A getter for skip_gradle_task.

root_path - A getter for root_path.

report_file - A getter for report_file.

report_files - A getter for report_files.

Development

  1. Clone this repo
  2. Run bundle install to setup dependencies.
  3. Run bundle exec rake spec to run the tests.
  4. Use bundle exec guard to automatically have tests run as you make changes.
  5. Make your changes.