Allows you to run Apex Static Analysis directly in vscode.
- Run analysis on file open
- Run analysis on file save
- Run analysis on entire workspace
- Run analysis on single file
- Ability to define your own ruleset
- Must have
JDK >=1.4
installed and in path - Download a PMD "bin" release (
>= 5.6
) - unzip to location of choice
- In VScode, Open
Preferences: User Settings
and setapexPMD.pmdPath
to folder where pmd was unzipped in step 3
// absolute path to where PMD was installed
"apexPMD.pmdPath": "/Users/johndoe/pmd",
// 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"
I recommend you use the default ruleset as a starting point.
Set "apexPMD.useDefaultRuleset": "false"
and update apexPMD.rulesetPath
to reference your custom ruleset.