PMD v6.18.0 Release Notes

Release Date: 2019-09-15 // over 4 years ago
  • 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
    0๏ธโƒฃ 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
      0๏ธโƒฃ 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.

    External Contributions