• Review
  • Changelog

Computer programs are developed to provide information which is utilized by the computer to perform various tasks which includes solving some technical problems to make life easier for people. The programmer identifies a problem and develops an algorithm with the potential to yield a solution. The source code is subsequently written and the program design gets documented.

Computer programs are expected to accurately collect, analyze and manage data on a system. The source code of these programs may contain bugs or errors that could hinder its smooth operation. PMD provides a means of identifying these errors and debugging your code to ensure that it is running optimally.

How Can PMD Help You

PMD is a handy tool that is ideal for all programmers regardless of their various skill levels. It facilitates debugging and code analysis to enable you to eliminate all flaws that may prevent the program from running seamlessly. 

An efficient programming code should not contain unused classes instances or variables, empty catch blocks and a host of other unnecessary objects. The program can be used in analyzing code written in various languages like Java, PLSQL, JavaScript, JSP, XSL, Python, PHP, XML and lots more. It can also find sources of syntax complexity and eliminate them to optimize the execution time of your code.

Some of these complexities can be accidental and not essential which could affect the way the code works. PMD enables its user to set custom rules that can be implemented when analyzing source code to detect every related error in the code. You can also write XPath rules for querying the Abstract Syntax Tree (AST), define custom rule properties and test it using a positive and negative test case to ensure that it is viable.

PMD can also identify duplicate code and eliminate them. You can also create support for a new programming language. All you need to do is to implement a new parser for the language, create node classes, token manager, and version handler. The custom rule for the language would also have to be created and tested.

PMD can be integrated into several IDEs like Netbeans and Eclipse with the help of a plugin which has the required rulesets in it. Code analysis can be automated with the help of third-party tools like Codacy.

PMD Key Features Include:

  • Automation of code analysis;
  • Easy integration into several IDEs;
  • Supports custom rule creation for new languages;
  • Supports XPath rules for querying the Abstract Syntax Tree (AST);
  • Analyze code in various languages like Python, JavaScript, and XML;
  • Locate duplicate codes;
  • Suppress warnings.

Summary

Efficient time management and accuracy is key to developing cost-effective programs. Mistakes are inevitable and debugging source code manually can be exhausting because you would have to browse through several lines of code to find errors. PMD enables you to write efficient code to save time and resources.

What's new in 6.19.0 version?

New and noteworthy:

Updated PMD Designer:

  • This PMD release ships a new version of the pmd-designer. For the changes, see PMD Designer Changelog.
  • Java Metrics
  • The new metric “Class Fan Out Complexity” has been added. See Java Metrics Documentation for details.

Modified Rules:

  • The Java rules InvalidLogMessageFormat and MoreThanOneLogger (java-errorprone) now both support Log4j2. Note that the rule “InvalidSlf4jMessageFormat” has been renamed to “InvalidLogMessageFormat” to reflect the fact, that it now supports more than slf4j.
  • The Java rule LawOfDemeter (java-design) ignores now also Builders, that are not assigned to a local variable, but just directly used within a method call chain. The method, that creates the builder needs to end with “Builder”, e.g. newBuilder() or initBuilder() works. This change fixes a couple of false positives.
  • The Java rule DataflowAnomalyAnalysis (java-errorprone) doesn’t check for UR anomalies (undefined and then referenced) anymore. These checks were all false-positives, since actual UR occurrences would lead to compile errors.
  • The java rule DoNotUseThreads (java-multithreading) has been changed to not report usages of java.lang.Runnable anymore. Just using Runnable does not automatically create a new thread. While the check for Runnable has been removed, the rule now additionally checks for usages of Executors and ExecutorService. Both create new threads, which are not managed by a J2EE server.

Renamed Rules:

  • The Java rule InvalidSlf4jMessageFormat has been renamed to InvalidLogMessageFormat since it supports now both slf4j and log4j2 message formats.

Fixed Issues:

Core:

  • #1978: [core] PMD fails on excluding unknown rules
  • #2014: [core] Making add(SourceCode sourceCode) public for alternative file systems
  • #2020: [core] Wrong deprecation warnings for unused XPath attributes
  • #2036: [core] Wrong include/exclude patterns are silently ignored
  • #2048: [core] Enable type resolution by default for XPath rules
  • #2067: [core] Build issue on Windows
  • #2068: [core] Rule loader should use the same resources loader for the ruleset
  • #2071: [ci] Add travis build on windows
  • #2072: [test][core] Not enough info in “test setup error” when numbers of lines do not match
  • #2082: [core] Incorrect logging of deprecated/renamed rules

Java:

  • #2042: [java] PMD crashes with ClassFormatError: Absent Code attribute…

Java-bestpractices:

  • #1531: [java] UnusedPrivateMethod false-positive with method result
  • #2025: [java] UnusedImports when @see / @link pattern includes a FQCN

Java-codestyle:

  • #2017: [java] UnnecessaryFullyQualifiedName triggered for inner class

Java-design:

  • #1912: [java] Metrics not computed correctly with annotations

Java-errorprone:

  • #336: [java] InvalidSlf4jMessageFormat applies to log4j2
  • #1636: [java] Stop checking UR anomalies for DataflowAnomalyAnalysis

Java-multithreading:

  • #1627: [java] DoNotUseThreads should not warn on Runnable

Doc:

  • #2058: [doc] CLI reference for -norulesetcompatibility shows a boolean default value

API Changes:

Deprecated APIs:

For removal:

Pmd-core:

  • All the package net.sourceforge.pmd.dcd and its subpackages. See DCD.

In LanguageRegistry:

  • commaSeparatedTerseNamesForLanguageVersion
  • commaSeparatedTerseNamesForLanguage
  • findAllVersions
  • findLanguageVersionByTerseName
  • getInstance
  • RuleSet#getExcludePatterns. Use the new method getFileExclusions instead.
  • RuleSet#getIncludePatterns. Use the new method getFileInclusions instead.
  • Parser#canParse
  • Parser#getSuppressMap
  • RuleBuilder#RuleBuilder. Use the new constructor with the correct ResourceLoader instead.
  • RuleFactory#RuleFactory. Use the new constructor with the correct ResourceLoader instead.

Pmd-java:

  • CanSuppressWarnings and its implementations
  • isSuppressed
  • getDeclaringType.
  • isSupressed
  • ASTMethodDeclarator
  • getMethodName
  • getBlock
  • getParameterCount

Pmd-apex:

  • CanSuppressWarnings and its implementations
  • isSupressed

Internal APIs:

Pmd-core:

  • All the package net.sourceforge.pmd.util and its subpackages, except net.sourceforge.pmd.util.datasource and net.sourceforge.pmd.util.database.
  • GridBagHelper
  • ColumnDescriptor

Screenshots

More info

  • Last Updated: 2019-11-04
  • Developer: PMD
  • Homepage: github.com/pmd
  • Version: 6.19.0
  • File size: 58.03 MB
  • Downloads: 2,655
  • Operating system: Windows 10, Windows 8/8.1, Windows 7, Windows Vista, Windows XP
  • Filename: pmd-bin-6.19.0.zip
  • MD5 Checksum: 375dd4a3d5aa53e7a509496ac4175384

Comments