Skip to content

Releases: pmd/pmd

6.21.0 (with designer)

24 Jan 19:00
Compare
Choose a tag to compare

This release is identical to the 6.21.0 release, but it includes the newest version of the rule designer. Technically it's a prerelease of 6.22.0 (you'll find that the jar versions reflect this).

PMD release notes

Please refer to the 6.21.0 PMD release

Designer release notes

Please refer to the 6.21.0 designer release

PMD 6.21.0 (24-January-2020)

24 Jan 17:51
Compare
Choose a tag to compare

24-January-2020 - 6.21.0

The PMD team is pleased to announce PMD 6.21.0.

This is a minor release.

Table Of Contents

New and noteworthy

Modelica support

Thanks to Anatoly Trosinenko PMD supports now a new language:
Modelica is a language to model complex physical systems.
Both PMD and CPD are supported and there are already 3 rules available.
The PMD Designer supports syntax highlighting for Modelica.

While the language implementation is quite complete, Modelica support is considered experimental
for now. This is to allow us to change the rule API (e.g. the AST classes) slightly and improve
the implementation based on your feedback.

Simple XML dump of AST

We added a experimental feature to dump the AST of a source file into XML. The XML format
is of course PMD specific and language dependent. That XML file can be used to execute
(XPath) queries against without PMD. It can also be used as a textual visualization of the AST
if you don't want to use the Designer.

This feature is experimental and might change or even be removed in the future, if it is not
useful. A short description how to use it is available under Creating XML dump of the AST.

Any feedback about it, especially about your use cases, is highly appreciated.

Updated Apex Support

  • The Apex language support has been bumped to version 48 (Spring '20). All new language features are now properly
    parsed and processed.

CPD XML format

The CPD XML output format has been enhanced to also report column information for found duplications
in addition to the line information. This allows to display the exact tokens, that are considered
duplicate.

If a CPD language doesn't provide these exact information, then these additional attributes are omitted.

Each <file> element in the XML format now has 3 new attributes:

  • attribute endline
  • attribute column (if there is column information available)
  • attribute endcolumn (if there is column information available)

Modified Rules

  • The Java rule AvoidLiteralsInIfCondition (java-errorprone) has a new property
    ignoreExpressions. This property is set by default to true in order to maintain compatibility. If this
    property is set to false, then literals in more complex expressions are considered as well.

  • The Apex rule ApexCSRF (apex-errorprone) has been moved from category
    "Security" to "Error Prone". The Apex runtime already prevents DML statements from being executed, but only
    at runtime. So, if you try to do this, you'll get an error at runtime, hence this is error prone. See also
    the discussion on #2064.

  • The Java rule CommentRequired (java-documentation) has a new property
    classCommentRequirement. This replaces the now deprecated property headerCommentRequirement, since
    the name was misleading. (File) header comments are not checked, but class comments are.

Fixed Issues

  • apex
    • #2208: [apex] ASTFormalComment should implement ApexNode<T>
  • core
    • #1984: [java] Cyclomatic complexity is misreported (lack of clearing metrics cache)
    • #2006: [core] PMD should warn about multiple instances of the same rule in a ruleset
    • #2161: [core] ResourceLoader is deprecated and marked as internal but is exposed
    • #2170: [core] DocumentFile doesn't preserve newlines
  • doc
    • #2214: [doc] Link broken in pmd documentation for writing Xpath rules
  • java
    • #2212: [java] JavaRuleViolation reports wrong class name
  • java-bestpractices
    • #2149: [java] JUnitAssertionsShouldIncludeMessage - False positive with assertEquals and JUnit5
  • java-codestyle
    • #2167: [java] UnnecessaryLocalBeforeReturn false positive with variable captured by method reference
  • java-documentation
    • #1683: [java] CommentRequired property names are inconsistent
  • java-errorprone
    • #2140: [java] AvoidLiteralsInIfCondition: false negative for expressions
    • #2196: [java] InvalidLogMessageFormat does not detect extra parameters when no placeholders
  • java-performance
    • #2141: [java] StringInstatiation: False negative with String-array access
  • plsql
    • #2008: [plsql] In StringLiteral using alternative quoting mechanism single quotes cause parsing errors
    • #2009: [plsql] Multiple DDL commands are skipped during parsing

API Changes

Deprecated APIs

Internal API

Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0.
You can identify them with the @InternalApi annotation. You'll also get a deprecation warning.

Read more

PMD 6.20.0 (29-November-2019)

29 Nov 19:21
Compare
Choose a tag to compare

29-November-2019 - 6.20.0

The PMD team is pleased to announce PMD 6.20.0.

This is a minor release.

Table Of Contents

Fixed Issues

  • apex
    • #2092: [apex] ApexLexer logs visible when Apex is the selected language upon starting the designer
    • #2136: [apex] Provide access to underlying query of SoqlExpression
  • core
    • #2002: [doc] Issue with http://pmdapplied.com/ linking to a gambling Web site
    • #2062: [core] Shortnames parameter does not work with Ant
    • #2090: [ci] Release notes and draft releases
    • #2096: [core] Referencing category errorprone.xml produces deprecation warnings for InvalidSlf4jMessageFormat
  • java
    • #1861: [java] Be more lenient with version numbers
    • #2105: [java] Wrong name for inner classes in violations
  • java-bestpractices
    • #2016: [java] UnusedImports: False positive if wildcard is used and only static methods
  • java-codestyle
    • #1362: [java] LinguisticNaming flags Predicates with boolean-style names
    • #2029: [java] UnnecessaryFullyQualifiedName false-positive for non-static nested classes
    • #2098: [java] UnnecessaryFullyQualifiedName: regression / false positive
  • java-design
    • #2075: [java] ImmutableField false positive with inner class
    • #2125: [java] ImmutableField: False positive when variable is updated in conditional loop
  • java-errorprone
    • #2102: [java] False positive MissingStaticMethodInNonInstantiatableClass when inheritors are instantiable

External Contributions

PMD 6.19.0 (31-October-2019)

31 Oct 18:09
Compare
Choose a tag to compare

31-October-2019 - 6.19.0

The PMD team is pleased to announce PMD 6.19.0.

This is a minor release.

Table Of Contents

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

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

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
Read more

PMD 6.18.0 (15-September-2019)

15 Sep 08:18
Compare
Choose a tag to compare

15-September-2019 - 6.18.0

The PMD team is pleased to announce PMD 6.18.0.

This is a minor release.

Table Of Contents

New and noteworthy

Java 13 Support

This release of PMD brings support for Java 13. PMD can parse Switch Expressions
with the new yield statement and resolve the type of such an expression.

PMD also parses Text Blocks as String literals.

Note: The Switch Expressions and Text Blocks are a preview language feature of OpenJDK 13
and are not enabled by default. In order to
analyze a project with PMD that uses these language features, you'll need to enable it via the environment
variable PMD_JAVA_OPTS and select the new language version 13-preview:

export PMD_JAVA_OPTS=--enable-preview
./run.sh pmd -language java -version 13-preview ...

Note: Support for the extended break statement introduced in Java 12 as a preview language feature
will be removed with the next PMD version 6.19.0.

Full support for Scala

Thanks to Chris Smith PMD now fully supports Scala. Now rules for analyzing Scala
code can be developed in addition to the Copy-Paste-Detection (CPD) functionality. There are no rules yet, so
contributions are welcome.

Additionally Scala support has been upgraded from 2.12.4 to 2.13.

New rule designer documentation

The documentation for the rule designer is now available on the main PMD documentation page:
Rule Designer Reference. Check it out to learn
about the usage and features of the rule designer.

New rules

  • The Java rule AvoidMessageDigestField (java-bestpractices) detects fields
    of the type java.security.MessageDigest. Using a message digest instance as a field would need to be
    synchronized, as it can easily be used by multiple threads. Without synchronization the calculated hash could
    be entirely wrong. Instead of declaring this as a field and synchronize access to use it from multiple threads,
    a new instance should be created when needed. This rule is also active when using java's quickstart ruleset.

  • The Apex rule DebugsShouldUseLoggingLevel (apex-bestpractices) detects
    usages of System.debug() method calls that are used without specifying the log level. Having the log
    level specified provides a cleaner log, and improves readability of it.

Modified Rules

  • The Java rule CloseResource (java-errorprone) now ignores by default instances
    of java.util.stream.Stream. These streams are AutoCloseable, but most streams are backed by collections,
    arrays, or generating functions, which require no special resource management. However, there are some exceptions:
    The stream returned by Files::lines(Path) is backed by a actual file and needs to be closed. These instances
    won't be found by default by the rule anymore.

Fixed Issues

  • all
    • #1465: [core] Stylesheet pmd-report.xslt fails to display filepath if 'java' in path
    • #1923: [core] Incremental analysis does not work with shortnames
    • #1983: [core] Avoid crashes with analysis cache when classpath references non-existing directories
    • #1990: [core] Incremental analysis mixes XPath rule violations
  • apex
    • #1901: [apex] Expose super type name of UserClass
    • #1942: [apex] Add best practice rule for debug statements in Apex
  • java
    • #1930: [java] Add Java 13 support
  • java-bestpractices
    • #1227: [java] UnusedFormalParameter should explain checkAll better
    • #1862: [java] New rule for MessageDigest.getInstance
    • #1952: [java] UnusedPrivateField not triggering if @value annotation present
  • java-codestyle
    • #1951: [java] UnnecessaryFullyQualifiedName rule triggered when variable name clashes with package name
  • java-errorprone
    • #1922: [java] CloseResource possible false positive with Streams
    • #1966: [java] CloseResource false positive if Stream is passed as method parameter
    • #1967: [java] CloseResource false positive with late assignment of variable
  • plsql
    • #1933: [plsql] ParseException with cursor declared in anonymous block
    • #1935: [plsql] ParseException with SELECT INTO record defined as global variable
    • #1936: [plslq] ParseException with cursor inside procedure declaration
    • #1946: [plsql] ParseException with using TRIM inside IF statements condition
    • #1947: [plsql] ParseError - SELECT with FOR UPDATE OF
    • #1948: [plsql] ParseException with INSERT INTO using package global variables
    • #1950: [plsql] ParseException with UPDATE and package record variable
    • #1953: [plsql] ParseException with WITH in CURSOR

API Changes

Changes to Renderer

  • Each renderer has now a new method Renderer#setUseShortNames which
    is used for implementing the "shortnames" CLI option. The method is automatically called by PMD, if this
    CLI option is in use. When rendering filenames to the report, the new helper method
    AbstractRenderer#determineFileName should be used. This will change
    the filename to a short name, if the CLI option "shortnames" is used.

    Not adjusting custom renderers will make them render always the full file names and not honoring the
    CLI option "shortnames".

Deprecated APIs

For removal
Internal APIs

Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. You can identify them with the @InternalApi annotation. You'll also get a deprecation warning.

Read more

PMD 6.17.0 (28-July-2019)

28 Jul 08:28
Compare
Choose a tag to compare

28-July-2019 - 6.17.0

The PMD team is pleased to announce PMD 6.17.0.

This is a minor release.

Table Of Contents

New and noteworthy

Updated PMD Designer

This PMD release ships a new version of the pmd-designer.
For the changes, see PMD Designer Changelog.
It contains a new feature to edit test cases directly within the designer. Any feedback is highly appreciated.

Lua support

Thanks to the contribution from Maikel Steneker, and built on top of the ongoing efforts to fully support Antlr-based languages,
PMD now has CPD support for Lua.

Being based on a proper Antlr grammar, CPD can:

Modified Rules

  • The Java rule CloseResource (java-errorprone) ignores now by default
    java.io.ByteArrayInputStream and java.io.CharArrayWriter. Such streams/writers do not need to be closed.

  • The Java rule MissingStaticMethodInNonInstantiatableClass (java-errorprone) has now
    the new property annotations.
    When one of the private constructors is annotated with one of the annotations, then the class is not considered
    non-instantiatable anymore and no violation will be reported. By default, Spring's @Autowired and
    Java EE's @Inject annotations are recognized.

Fixed Issues

  • core
    • #1913: [core] "-help" CLI option ends with status code != 0
  • doc
    • #1896: [doc] Error in changelog 6.16.0 due to not properly closed rule tag
    • #1898: [doc] Incorrect code example for DoubleBraceInitialization in documentation on website
    • #1906: [doc] Broken link for adding own CPD languages
    • #1909: [doc] Sample usage example refers to deprecated ruleset "basic.xml" instead of "quickstart.xml"
  • java
    • #1910: [java] ATFD calculation problem
  • java-errorprone
    • #1749: [java] DD False Positive in DataflowAnomalyAnalysis
    • #1832: [java] False positives for MissingStaticMethodInNonInstantiatableClass when DI is used
    • #1921: [java] CloseResource false positive with ByteArrayInputStream
  • java-multithreading
    • #1903: [java] UnsynchronizedStaticFormatter doesn't allow block-level synchronization when using allowMethodLevelSynchronization=true
  • plsql
    • #1902: [pslql] ParseException when parsing (+)
  • xml
    • #1666: [xml] wrong cdata rule description and examples

External Contributions

  • #1869: [xml] fix #1666 wrong cdata rule description and examples - Artem
  • #1892: [lua] [cpd] Added CPD support for Lua - Maikel Steneker
  • #1905: [java] DataflowAnomalyAnalysis Rule in right order - YoonhoChoi96
  • #1908: [doc] Update ruleset filename from deprecated basic.xml to quickstart.xml - crunsk
  • #1916: [java] Exclude Autowired and Inject for MissingStaticMethodInNonInstantiatableClass - AnthonyKot
  • #1917: [core] Add 'no error' return option, and assign it to the cli when the help command is invoked - Renato Oliveira

PMD 6.16.0 (30-June-2019)

30 Jun 08:35
Compare
Choose a tag to compare

30-June-2019 - 6.16.0

The PMD team is pleased to announce PMD 6.16.0.

This is a minor release.

Table Of Contents

New and noteworthy

Updated PMD Designer

This PMD release ships a new version of the pmd-designer.
For the changes, see PMD Designer Changelog.

PLSQL Grammar Updates

The grammar has been updated to support inline constraints in CREATE TABLE statements. Additionally, the
CREATE TABLE statement may now be followed by physical properties and table properties. However, these
properties are skipped over during parsing.

The CREATE VIEW statement now supports subquery views.

The EXTRACT function can now be parsed correctly. It is used to extract values from a specified
datetime field. Also date time literals are parsed now correctly.

The CASE expression can now be properly used within SELECT statements.

Table aliases are now supported when specifying columns in INSERT INTO clauses.

New Rules

  • The Java rule DoubleBraceInitialization (java-bestpractices)
    detects non static initializers in anonymous classes also known as "double brace initialization".
    This can be problematic, since a new class file is generated and object holds a strong reference
    to the surrounding class.

    Note: This rule is also part of the Java quickstart ruleset (rulesets/java/quickstart.xml).

Modified Rules

  • The Java rule UnusedPrivateField (java-bestpractices) now ignores by
    default fields, that are annotated with the Lombok experimental annotation @Delegate. This can be
    customized with the property ignoredAnnotations.

  • The Java rule SingularField (java-design) now ignores by
    default fields, that are annotated with the Lombok experimental annotation @Delegate. This can be
    customized with the property ignoredAnnotations.

  • The Java rules UnsynchronizedStaticFormatter and
    UnsynchronizedStaticDateFormatter (java-multithreading)
    now prefer synchronized blocks by default. They will raise a violation, if the synchronization is implemented
    on the method level. To allow the old behavior, the new property allowMethodLevelSynchronization can
    be enabled.

  • The Java rule UseUtilityClass (java-design) has a new property ignoredAnnotations.
    By default, classes that are annotated with Lombok's @UtilityClass are ignored now.

  • The Java rule NonStaticInitializer (java-errorprone) does not report
    non static initializers in anonymous classes anymore. For this use case, there is a new rule now:
    DoubleBraceInitialization (java-bestpractices).

  • The Java rule CommentDefaultAccessModifier (java-codestyle) was enhanced
    in the last version 6.15.0 to check also top-level types by default. This created many new violations.
    Missing the access modifier for top-level types is not so critical, since it only decreases the visibility
    of the type.

    The default behaviour has been restored. If you want to enable the check for top-level types, you can
    use the new property checkTopLevelTypes.

  • The Java rule CloseResource (java-errorprone) now by default searches
    for any unclosed java.lang.AutoCloseable resource. This includes now the standard java.io.*Stream classes.
    Previously only SQL-related resources were considered by this rule. The types can still be configured
    via the types property. Some resources do not need to be closed (e.g. ByteArrayOutputStream). These
    exceptions can be configured via the new property allowedResourceTypes.
    In order to restore the old behaviour, just remove the type java.lang.AutoCloseable from the types
    property and keep the remaining SQL-related classes.

Deprecated Rules

  • The Java rule AvoidFinalLocalVariable (java-codestyle) has been deprecated
    and will be removed with PMD 7.0.0. The rule is controversial and also contradicts other existing
    rules such as LocalVariableCouldBeFinal. If the goal is to avoid defining
    constants in a scope smaller than the class, then the rule AvoidDuplicateLiterals
    should be used instead.

Fixed Issues

  • apex
    • #1664: [apex] False positive ApexSharingViolationsRule, unsupported Apex feature
  • java
    • #1848: [java] Local classes should preserve their modifiers
  • java-bestpractices
    • #1703: [java] UnusedPrivateField on member annotated with lombok @DeleGate
    • #1845: [java] Regression in MethodReturnsInternalArray not handling enums
    • #1854: [java] Rule to check for double brace initialisation
  • java-codestyle
    • #1612: [java] Deprecate AvoidFinalLocalVariable
    • #1880: [java] CommentDefaultAccessModifier should be configurable for top-level classes
  • java-design
    • #1094: [java] UseUtilityClass should be LombokAware
  • java-errorprone
    • #1000: [java] The rule CloseResource should deal with IO stream as default
    • #1853: [java] False positive for NonStaticInitializer in anonymous class
  • java-multithreading
    • #1814: [java] UnsynchronizedStaticFormatter documentation and implementation wrong
    • #1815: [java] False negative in UnsynchronizedStaticFormatter
  • plsql
    • #1828: [plsql] Parentheses stopped working
    • #1850: [plsql] Parsing errors with INSERT using returning or records and TRIM expression
    • #1873: [plsql] Expression list not working
    • #1878: [pslql] ParseException when parsing USING
    • #1879: [pslql] ParseException when parsing LEFT JOIN

API Changes

Deprecated APIs

Reminder: Please don't use members marked with the annotation InternalApi, as they will likely be removed, hidden, or otherwise intentionally broken with 7.0.0.

In ASTs

As part of the changes we'd like to do to AST classes for 7.0.0, we would like to
hide some methods and constructors that rule writers should not have access to.
The following usages are now deprecated in the Java AST (with other languages to come):

  • Manual instantiation of nodes. Constructors of node classes are deprecated and marked InternalApi. Nodes should only be obtained from the parser, which for rules, means that never need to instantiate node themselves. Those constructors will be made package private with 7.0.0.
  • Subclassing of abstract node classes, or usage of their type. Version 7.0.0 will bring a new set of abstractions that will be public API, but the base classes are and will stay internal. You should not couple your code to them.
    • In the meantime you should use interfaces like JavaNode or Node, or the other published interfaces in this package, to refer to nodes generically.
    • Concrete node classes will be made final with 7.0.0.
  • Setters found in any node class or interface. Rules should consider the AST immutable. We will make those setters package private with 7.0.0.

Please look at [net.sourceforge.pmd.lang.java.ast](https://javadoc.io/page/net.sourceforge....

Read more

PMD 6.15.0 (26-May-2019)

26 May 09:05
Compare
Choose a tag to compare

26-May-2019 - 6.15.0

The PMD team is pleased to announce PMD 6.15.0.

This is a minor release.

Table Of Contents

New and noteworthy

Enhanced Matlab support

Thanks to the contributions from Maikel Steneker CPD for Matlab can
now parse Matlab programs which use the question mark operator to specify access to
class members:

classdef Class1
properties (SetAccess = ?Class2)

CPD also understands now double quoted strings, which are supported since version R2017a of Matlab:

str = "This is a string"

Enhanced C++ support

CPD now supports digit separators in C++ (language module "cpp"). This is a C++14 feature.

Example: auto integer_literal = 1'000'000;

The single quotes can be used to add some structure to large numbers.

CPD also parses raw string literals now correctly (see #1784).

New Rules

  • The new Apex rule FieldNamingConventions (apex-codestyle) checks the naming
    conventions for field declarations. By default this rule uses the standard Apex naming convention (Camel case),
    but it can be configured through properties.

  • The new Apex rule FormalParameterNamingConventions (apex-codestyle) checks the
    naming conventions for formal parameters of methods. By default this rule uses the standard Apex naming
    convention (Camel case), but it can be configured through properties.

  • The new Apex rule LocalVariableNamingConventions (apex-codestyle) checks the
    naming conventions for local variable declarations. By default this rule uses the standard Apex naming
    convention (Camel case), but it can be configured through properties.

  • The new Apex rule PropertyNamingConventions (apex-codestyle) checks the naming
    conventions for property declarations. By default this rule uses the standard Apex naming convention (Camel case),
    but it can be configured through properties.

  • The new Java rule UseShortArrayInitializer (java-codestyle) searches for
    array initialization expressions, which can be written shorter.

Modified Rules

  • The Apex rule ClassNamingConventions (apex-codestyle) can now be configured
    using various properties for the specific kind of type declarations (e.g. class, interface, enum).
    As before, this rule uses by default the standard Apex naming convention (Pascal case).

  • The Apex rule MethodNamingConventions (apex-codestyle) can now be configured
    using various properties to differenciate e.g. static methods and test methods.
    As before, this rule uses by default the standard Apex naming convention (Camel case).

  • The Java rule FieldNamingConventions (java-codestyle) now by default ignores
    the field serialPersistentFields. Since this is a field which needs to have this special name, no
    field naming conventions can be applied here. It is excluded the same way like serialVersionUID via the
    property exclusions.

  • The Java rule CommentRequired (java-documentation) has a new property
    serialPersistentFieldsCommentRequired with the default value "Ignored". This means that from now
    on comments for the field serialPersistentFields are not required anymore. You can change the property
    to restore the old behavior.

  • The Java rule ProperLogger (java-errorprone) has two new properties
    to configure the logger class (e.g. "org.slf4j.Logger") and the logger name of the special case,
    when the logger is not static. The name of the static logger variable was already configurable.
    The new property "loggerClass" allows to use this rule for different logging frameworks.
    This rule covers all the cases of the now deprecated rule LoggerIsNotStaticFinal.

  • The Java rule CommentDefaultAccessModifier (java-codestyle) now reports also
    missing comments for top-level classes and annotations, that are package-private.

Deprecated Rules

Fixed Issues

  • apex
    • #1321: [apex] Should VariableNamingConventions require properties to start with a lowercase letter?
    • #1783: [apex] comments on constructor not recognized when the Class has inner class
  • cpp
    • #1784: [cpp] Improve support for raw string literals
  • dart
    • #1809: [dart] [cpd] Parse error with escape sequences
  • java
    • #1842: [java] Annotated module declarations cause parse error
  • java-bestpractices
    • #1738: [java] MethodReturnsInternalArray does not work in inner classes
  • java-codestyle
    • #1495: [java] Rule to detect overly verbose array initializiation
    • #1684: [java] Properly whitelist serialPersistentFields
    • #1804: [java] NPE in UnnecessaryLocalBeforeReturnRule
  • python
    • #1810: [python] [cpd] Parse error when using Python 2 backticks
  • matlab
    • #1830: [matlab] [cpd] Parse error with comments
    • #1793: [java] CommentDefaultAccessModifier not working for classes

API Changes

Deprecated APIs

For removal
Read more

PMD 6.14.0 (28-April-2019)

28 Apr 08:39
Compare
Choose a tag to compare

28-April-2019 - 6.14.0

The PMD team is pleased to announce PMD 6.14.0.

This is a minor release.

Table Of Contents

New and noteworthy

Dart support

Thanks to the contribution from Maikel Steneker, and built on top of the ongoing efforts to fully support Antlr-based languages,
PMD now has CPD support for Dart.

Being based on a proper Antlr grammar, CPD can:

Updated PMD Designer

This PMD release ships a new version of the pmd-designer.
For the changes, see PMD Designer Changelog.

Modified Rules

  • The Java rule AssignmentToNonFinalStatic (java-errorprone) will now report on each
    assignment made within a constructor rather than on the field declaration. This makes it easier for developers to
    find the offending statements.

  • The Java rule NoPackage (java-codestyle) will now report additionally enums
    and annotations that do not have a package declaration.

Fixed Issues

  • all
    • #1515: [core] Module pmd-lang-test is missing javadoc artifact
    • #1788: [cpd] [core] Use better ClassLoader for ServiceLoader in LanguageFactory
    • #1794: [core] Ruleset Compatibility fails with excluding rules
  • go
    • #1751: [go] Parsing errors encountered with escaped backslash
  • java
    • #1532: [java] NPE with incomplete auxclasspath
    • #1691: [java] Possible Data Race in JavaTypeDefinitionSimple.getGenericType
    • #1729: [java] JavaRuleViolation loses information in className field when class has package-private access level
  • java-bestpractices
    • #1190: [java] UnusedLocalVariable/UnusedPrivateField false-positive
    • #1720: [java] UnusedImports false positive for Javadoc link with array type
  • java-codestyle
    • #1755: [java] False negative in UnnecessaryLocalBeforeReturn when splitting statements across multiple lines
    • #1782: [java] NoPackage: False Negative for enums
  • java-design
    • #1760: [java] UseObjectForClearerAPI flags private methods

API Changes

No changes.

External Contributions

PMD 6.13.0 (31-March-2019)

31 Mar 10:11
Compare
Choose a tag to compare

31-March-2019 - 6.13.0

The PMD team is pleased to announce PMD 6.13.0.

This is a minor release.

Table Of Contents

New and noteworthy

Call For Logo

We are still searching for a new logo for PMD for the next major release.

Learn more about how to participate on github issue 1663.

Java 12 Support

This release of PMD brings support for Java 12. PMD can parse the new Switch Expressions
and resolve the type of such an expression.

Note: The Switch Expressions are a preview language feature of OpenJDK 12 and are not enabled by default. In order to
analyze a project with PMD that uses these language features, you'll need to enable it via the new environment
variable PMD_JAVA_OPTS:

export PMD_JAVA_OPTS=--enable-preview
./run.sh pmd ...

Quickstart Ruleset for Apex

PMD provides now a quickstart ruleset for Salesforce.com Apex, which you can use as a base ruleset to
get your custom ruleset started. You can reference it with rulesets/apex/quickstart.xml.
You are strongly encouraged to create your own ruleset
though.

The quickstart ruleset has the intention, to be useful out-of-the-box for many projects. Therefore it
references only rules, that are most likely to apply everywhere.

Any feedback would be greatly appreciated.

PMD Designer

The rule designer's codebase has been moved out of the main repository and
will be developed at pmd/pmd-designer
from now on. The maven coordinates will stay the same for the time being.
The designer will still be shipped with PMD's binaries.

Improved Apex Support

  • Many AST nodes now expose more information which makes it easier to write XPath-based rules for Apex. Here are
    some examples:
    • Annotation[@Resolved = false()] finds unsupported annotations.
    • AnnotationParameter[@Name='RestResource'][@Value='/myurl'] gives access to
      annotation parameters.
    • CatchBlockStatement[@ExceptionType='Exception'][@VariableName='e'] finds catch
      block for specific exception types.
    • Field[@Type='String'] find all String fields, Field[string-length(@Name) < 5]
      finds all fields with short names and Field[@Value='a'] find alls fields, that are
      initialized with a specific value.
    • LiteralExpression[@String = true()] finds all String literals. There are attributes
      for each type: @Boolean, @Integer, @Double, @Long, @Decimal, @Null.
    • Method[@Constructor = true()] selects all constructors. Method[@ReturnType = 'String']
      selects all methods that return a String.
    • The ModifierNode node has a couple of attributes to check for the existence of specific
      modifiers: @Test, @TestOrTestSetup, @WithSharing, @WithoutSharing, @InheritedSharing,
      @WebService, @Global, @Override.
    • Many nodes now expose their type. E.g. with Parameter[@Type='Integer'] you can find all
      method parameters of type Integer. The same attribute Type exists as well for:
      NewObjectExpression, Property, VariableDeclaration.
    • VariableExpression[@Image='i'] finds all variable usages of the variable "i".

New Rules

  • The new Java rule AvoidUncheckedExceptionsInSignatures (java-design) finds methods or constructors
    that declare unchecked exceptions in their throws clause. This forces the caller to handle the exception,
    even though it is a runtime exception.

  • The new Java rule DetachedTestCase (java-errorprone) searches for public
    methods in test classes, which are not annotated with @Test. These methods might be test cases where
    the annotation has been forgotten. Because of that those test cases are never executed.

  • The new Java rule WhileLoopWithLiteralBoolean (java-bestpractices) finds
    Do-While-Loops and While-Loops that can be simplified since they use simply true or false as their
    loop condition.

  • The new Apex rule ApexAssertionsShouldIncludeMessage (apex-bestpractices)
    searches for assertions in unit tests and checks, whether they use a message argument.

  • The new Apex rule ApexUnitTestMethodShouldHaveIsTestAnnotation (apex-bestpractices)
    searches for methods in test classes, which are missing the @IsTest annotation.

  • The new PLSQL rule AvoidTabCharacter (plsql-codestyle) checks, that there are
    no tab characters ("\t") in the source file.

  • The new PLSQL rule LineLength (plsql-codestyle) helps to enforce a maximum
    line length.

Fixed Issues

  • doc
    • #1721: [doc] Documentation provides an invalid property configuration example
  • java
    • #1537: [java] Java 12 support
  • java-bestpractices
    • #1701: [java] UseTryWithResources does not handle multiple argument close methods
  • java-codestyle
    • #1527: [java] UseUnderscoresInNumericLiterals false positive on floating point numbers
    • #1674: [java] documentation of CommentDefaultAccessModifier is wrong
  • java-errorprone
    • #1570: [java] AvoidDuplicateLiterals warning about deprecated separator property when not used
  • plsql
    • #1510: [plsql] Support XMLTABLE functions
    • #1716: [plsql] Support access to whole plsql code
    • #1731: [pslql] ParseException when parsing ELSIF
    • #1733: [plsql] % not supported in "TestSearch%notfound"
    • #1734: [plsql] TooManyMethods false-negative
    • #1735: [plsql] False-negatives for TO_DATE_TO_CHAR, TO_DATEWithoutDateFormat, TO_TIMESTAMPWithoutDateFormat

API Changes

Command Line Interface

The start scripts run.sh, pmd.bat and cpd.bat support the new environment variable PMD_JAVA_OPTS.
This can be used to set arbitrary JVM options for running PMD, such as memory settings (e.g. PMD_JAVA_OPTS=-Xmx512m)
or enable preview language features (e.g. PMD_JAVA_OPTS=--enable-preview).

The previously available variables such as OPTS or HEAPSIZE are deprecated and will be removed with PMD 7.0.0.

Deprecated API

  • CodeClimateRule is deprecated in 7.0.0 because it was unused for 2 years and
    created an unwanted dependency.
    Properties "cc_categories", "cc_remediation_points_multiplier", "cc_block_highlighting" will also be removed.
    See #1702 for more.

  • The Apex ruleset rulesets/apex/ruleset.xml has been deprecated and will be removed in 7.0.0. Please use the new
    quickstart ruleset rulesets/apex/quickstart.xml instead.

External Contributions