PMD v6.27.0 Release Notes

Release Date: 2020-08-31 // over 3 years ago
  • 31-August-2020 - 6.27.0

    The PMD team is pleased to announce PMD 6.27.0.

    ๐Ÿš€ This is a minor release.

    Table Of Contents

    ๐Ÿ†• New and noteworthy

    ๐Ÿ‘ Java 15 Support

    ๐Ÿš€ This release of PMD brings support for Java 15. PMD can parse Text Blocks
    which have been promoted to be a standard language feature of Java.

    ๐Ÿ‘ PMD also supports Pattern Matching for instanceof,
    Records, and Sealed Classes.

    Note: The Pattern Matching for instanceof, Records, and Sealed Classes are all preview language features of OpenJDK 15
    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 15-preview:

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

    ๐Ÿšš Note: Support for Java 13 preview language features have been removed. The version "13-preview" is no longer available.

    ๐Ÿ”„ Changes in how tab characters are handled

    In the past, tab characters in source files has been handled differently in different languages by PMD.
    For instance in Java, tab characters had a width of 8 columns, while C# used only 1 column. Visualforce instead
    ๐Ÿ‘‰ used 4 columns.

    This has been unified now so that tab characters are consistently now always 1 column wide.

    This however might be a incompatible change, if you're using the properties "BeginColumn" or "EndColumn"
    โž• additionally to "BeginLine" and "EndLine" of a Token/AST node in order to highlight
    where a rule violation occurred in the source file. If you have logic there that deals with tab characters,
    ๐Ÿšš you most likely can remove this logic now, since tab characters are now just "normal" characters
    in terms of string processing.

    ๐Ÿ‘€ See also [all] Ensure PMD/CPD uses tab width of 1 for tabs consistently #2656.

    โšก๏ธ Updated PMD Designer

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

    ๐Ÿ†• New Rules

    • The new Java rule AvoidReassigningCatchVariables (java-bestpractices) finds
      ๐Ÿ‘ป cases where the variable of the caught exception is reassigned. This practice is surprising and prevents
      further evolution of the code like multi-catch.

    Modified Rules

    The Java rule CloseResource (java-errorprone) has a new property
    closeNotInFinally. With this property set to true the rule will also find calls to close a
    resource, which are not in a finally-block of a try-statement. If a resource is not closed within a
    finally block, it might not be closed at all in case of exceptions.

    0๏ธโƒฃ As this new detection would yield many new violations, it is disabled by default. It might be
    enabled in a later version of PMD.

    ๐Ÿ—„ Deprecated Rules

    ๐Ÿ›  Fixed Issues

    • core
      • #724: [core] Avoid parsing rulesets multiple times
      • #1962: [core] Simplify Report API
      • #2653: [lang-test] Upgrade kotlintest to Kotest
      • #2656: [all] Ensure PMD/CPD uses tab width of 1 for tabs consistently
      • #2690: [core] Fix java7 compatibility
    • java
      • #2646: [java] Support JDK 15
    • java-bestpractices
      • #2471: [java] New Rule: AvoidReassigningCatchVariables
      • #2663: [java] NoClassDefFoundError on upgrade from 6.25.0 to 6.26.0
      • #2668: [java] UnusedAssignment false positives
      • #2673: [java] UnusedPrivateField and SingularField false positive with lombok annotation EqualsAndHashCode
      • #2684: [java] UnusedAssignment FP in try/catch
      • #2686: [java] UnusedAssignment must not flag abstract method parameters in interfaces and abstract classes
    • java-design
      • #2108: [java] [doc] ImmutableField rule: Description should clarify shallow immutability
      • #2461: [java] ExcessiveParameterListRule must ignore a private constructor
    • java-errorprone
      • #2264: [java] SuspiciousEqualsMethodName: Improve description about error-prone overloading of equals()
      • #2410: [java] ProperCloneImplementation not valid for final class
      • #2431: [java] InvalidLogMessageFormatRule throws IndexOutOfBoundsException when only logging exception message
      • #2439: [java] AvoidCatchingThrowable can not detect the case: catch (java.lang.Throwable t)
      • #2470: [java] CloseResource false positive when resource included in return value
      • #2531: [java] UnnecessaryCaseChange can not detect the case like: foo.equals(bar.toLowerCase())
      • #2647: [java] Deprecate rule DataFlowAnomalyAnalysis
    • ๐ŸŽ java-performance
      • #1868: [java] false-positive for SimplifyStartsWith if string is empty
      • #2441: [java] RedundantFieldInitializer can not detect a special case for char initialize: char foo = '\0';
      • #2530: [java] StringToString can not detect the case: getStringMethod().toString()
    • dart
      • #2750: [dart] [cpd] Cpd Dart escaped dollar

    API Changes

    • XML rule definition in rulesets: In PMD 7, the language attribute will be required on all rule
      elements that declare a new rule. Some base rule classes set the language implicitly in their
      constructor, and so this is not required in all cases for the rule to work. But this
      behavior will be discontinued in PMD 7, so missing language attributes are now
      โš  reported as a forward compatibility warning.

    ๐Ÿ—„ Deprecated API

    For removal

    ๐Ÿ“œ Rule#getParserOptions

    ๐Ÿ“œ Parser#getParserOptions

    ๐Ÿ“œ AbstractParser

    ๐Ÿšš RuleContext#removeAttribute

    ๐Ÿ“„ RuleContext#getAttribute

    ๐Ÿ“„ RuleContext#setAttribute

    ๐Ÿ“œ ApexParserOptions

    ๐Ÿ“„ ASTThrowStatement#getFirstClassOrInterfaceTypeImage

    ๐Ÿ“œ EcmascriptParserOptions

    ๐Ÿ“„ EcmascriptXPathRule

    ๐Ÿ“œ XmlParserOptions

    ๐Ÿ“„ XmlXPathRule

    ๐Ÿ“„ Properties of AbstractXmlRule

    ๐Ÿ“„ net.sourceforge.pmd.Report.ReadableDuration

    ๐Ÿ“„ Many methods of net.sourceforge.pmd.Report. They are replaced by accessors
    ๐Ÿ“„ that produce a List. For example, iterator()
    ๐Ÿ“„ (and implementing Iterable) and isEmpty() are both
    ๐Ÿ“„ replaced by getViolations().

    ๐Ÿ—„ The dataflow codebase is deprecated for removal in PMD 7. This
    ๐Ÿ“ฆ includes all code in the following packages, and their subpackages:

    - and the class PLSQLDataFlowHandler

    ๐Ÿ“„ VfSimpleCharStream

    ๐Ÿ“„ ASTJspDeclarations

    ๐Ÿ“„ ASTJspDocument

    ๐Ÿ“œ ScalaParserVisitorAdapter#zero

    ๐Ÿ“œ ScalaParserVisitorAdapter#combine

    ๐Ÿ“œ ApexParserVisitorReducedAdapter

    ๐Ÿ“œ JavaParserVisitorReducedAdapter

    ๐Ÿ—„ TypeHelper is deprecated in
    โœ… favor of TypeTestUtil, which has the
    same functionality, but a slightly changed API.

    ๐Ÿ“ฆ Many of the classes in net.sourceforge.pmd.lang.java.symboltable
    ๐Ÿ—„ are deprecated as internal API.

    External Contributions

    Stats

    • 189 commits
    • 68 closed tickets & PRs
    • ๐Ÿš€ Days since last release: 37