Allows you to run Java Static Analysis directly in vscode on java files.
Based on Charles Jonas's vscode-apex-pmd extension.
- Run analysis on file open
- Run analysis on file save
- Run analysis on file change
- Run analysis on entire workspace
- Run analysis on single file
- Ability to define your own ruleset
- Must have JRE >= 1.8 installed and in path
- See PMD System Requirements for more details
rulesets
(optional): set to override default ruleset (see "Defining your own ruleset" for more details)runOnFileOpen
: run every time a file is opened in vscoderunOnFileSave
: run every time a file is savedrunOnFileChange
: Run when a file is changed. NOTE: this is "debounced" to prevent performance issues. Delay can be adjusted viaonFileChangeDebounce
.priorityErrorThreshold
: Determines at what priority level 'errors' will be added. Anything less will be a warning or hintpriorityWarnThreshold
: Determines at what priority level 'warnings' will be added. Anything less will be a hintenableCache
: Creates a cache file for PMD to run faster. Will create a .pmdCache file in your workspacepmdBinPath
(prev.pmdPath
) (optional): set to override the default pmd binaries. This should point to the PMD folder which contains folderslib
andbin
. Most likely it is calledlibexec
.additionalClassPaths
(optional): set of paths to be appended to classpath. Used to find jar files containing custom rule definitions. Can be absolute or relative to workspace.commandBufferSize
Size of buffer used to collect PMD command output (MB), may need to be increased for very large projectsjrePath
(Optional) Path to JRE (Folder that contains which containsbin/java
)
I recommend you use the default ruleset as a starting point.
Set javaPMD.rulesets
string array to reference your custom rulesets. You can either use the absolute paths, or a relative paths from your workspace (EG my-java-rules.xml
).
You can also mention the default ruleset in javaPMD.rulesets
. To do this add default
value to the array.
If you want to use your own custom rules from a jar file, then the jar file must be on the classpath. By default, the PMD folder and the workspace root folder are included in the classpath. You can add further folders using the additionalClassPaths
setting. This "Hello world" example is a good starting place for beginners.
git clone
npm install
- debug -> "launch extension"
npm run update-pmd
Any pull request submitted with updates to PMD MUST BE "CHECKSUMED"!
Copyright (c) 2022 cracrayol, Charles Jonas and Contributors
Contains Distribution of PMD library.
Copyright (c) 2003-2009, InfoEther, LLC
All rights reserved.
This product includes software developed in part by support from
the Defense Advanced Research Project Agency (DARPA)
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The full license (BSD-style) can be found in the PMD repo