VSCode Apex PMD
From Visual Studio MarketPlace
Install it from Visual Studio MarketPlace
VSCode Extension for PMD code scan for Salesforce Apex
Allows you to run Apex Static Code Analysis directly in VSCode.
ANT task based PMD
If you are looking for ANT task based PMD for Apex, here it is.
Features Demo
Current actions Supported
Run analysis on:
- file open
- file save
- entire workspace
- single file
Installation
- Must have
JDK >=1.4
installed and in path - Download a PMD "bin" release (
>= 5.6
) - unzip the zip file from step #2 to location of choice and make a note of that location. This is the value for :
apexPMD.pmdPath
- In VSCode, Open
Preferences: User Settings
and setapexPMD.pmdPath
to folder where pmd was unzipped in step 3 along with other config items as shown below:
Sample Configuration -> VSCode::Preferences: User Settings
{
// ...
// absolute path to where PMD was installed
// following example in my case
"apexPMD.pmdPath":"/Users/mchinnappan/code-scan-tools/pmd/pmd-bin-5.8.1",
// Set to false to use you own ruleset (set path)
"apexPMD.useDefaultRuleset": "true",
// Absolute path to ruleset xml file. Must also set `useDefaultRuleset:false`.
"apexPMD.rulesetPath": "",
// Will run static analysis every time a file is opened
"apexPMD.runOnFileOpen": "true",
// Will run static analysis every time a file is saved
"apexPMD.runOnFileSave": "true",
// Determines at what priority level 'errors' will be added. Anything less will be a warning or hint
"apexPMD.priorityErrorThreshold": "1",
// Determines at what priority level 'warnings' will be added. Anything less will be a hint
"apexPMD.priorityWarnThreshold": "3"
}
Ruleset
Here is the sample ruleset used in this extension