Linter Plugin

Linter Plugin

Overview

The Linter plugin runs static analysis tools on your project’s source code. Currently, it supports PMD for Java projects.

LATEST VERSION: 0.3.0

Loading the plugin

Here is how you load this plugin:

linter = loadPlugin(id: "org.lattejava.plugin:linter:0.3.0")

Settings

The Linter plugin has one setting for the report output directory:

Report directory

The directory where analysis reports are written. This defaults to build/linter-reports:

linter.settings.reportDirectory = Paths.get("build/linter-reports")

Running PMD

The pmd method executes PMD analysis on your source code. At minimum, you must specify the rule sets to use:

linter.pmd(ruleSets: ["config/pmd-rules.xml"])

You can configure the analysis with additional attributes:

linter.pmd(
  ruleSets: ["config/pmd-rules.xml"],
  reportFormat: "html",
  reportFileName: "pmd-report",
  languageVersion: "17",
  inputPath: "src/main/java",
  minimumPriority: "MEDIUM",
  failOnViolations: true
)

PMD attributes

namedescriptiontyperequireddefault
ruleSetsArray of ruleset file paths (required)List<String>true-
reportFormatOutput format: xml, html, or textStringfalsexml
reportFileNameOutput report filenameStringfalsepmd-report
languageVersionJava language versionStringfalse17
inputPathSource path to analyzeStringfalsesrc/main/java
sourceClassesPathCompiled classes pathStringfalsebuild/classes/main
testClassesPathTest classes pathStringfalsebuild/classes/test
cachePathPMD cache file pathStringfalsebuild/pmd.cache
minimumPriorityMinimum violation priorityStringfalseMEDIUM
failOnViolationsWhether to fail build on violationsbooleanfalsetrue
reportSuppressedViolationsInclude suppressed violations in reportbooleanfalsefalse
customRuleDependencySpecsCustom rule JAR dependency specsList<String>false[]