PMD v6.21.0 Release Notes

Release Date: 2020-01-24 // about 4 years ago
  • 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
    0๏ธโƒฃ 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.

    JavaLanguageHandler

    ๐Ÿ“œ JavaLanguageParser

    JavaDataFlowHandler

    Implementations of RuleViolationFactory in each
    language module, eg JavaRuleViolationFactory.
    ๐Ÿ‘€ See javadoc of RuleViolationFactory.

    Implementations of RuleViolation in each language module,
    ๐Ÿ‘€ eg JavaRuleViolation. See javadoc of
    RuleViolation.

    RuleFactory

    RuleBuilder

    Constructors of RuleSetFactory, use factory methods from RulesetsFactoryUtils instead

    getRulesetFactory

    AbstractApexNode

    AbstractApexNodeBase, and the related visit
    ๐Ÿ“œ methods on ApexParserVisitor and its implementations.
    ๐Ÿ‘‰ Use ApexNode instead, now considers comments too.

    CharStream, JavaCharStream,
    SimpleCharStream: these are APIs used by our JavaCC
    ๐Ÿ”จ implementations and that will be moved/refactored for PMD 7.0.0. They should not
    be used, extended or implemented directly.

    ๐Ÿ“œ All classes generated by JavaCC, eg JJTJavaParserState.
    This includes token classes, which will be replaced with a single implementation, and
    ๐Ÿ‘€ subclasses of ParseException, whose usages will be replaced
    by just that superclass.

    For removal

    External Contributions