Table of Contents

27-November-2026 - 7.30.0-SNAPSHOT

The PMD team is pleased to announce PMD 7.30.0-SNAPSHOT.

This is a minor release.

🚀️ New and noteworthy

🌟️ New and Changed Rules

New Rules

  • The new Java rule ControlFlowInTest reports control flow in test methods that can obscure which assertions are executed. It checks conditionals, switch statements and expressions, explicit throw statements, try statements with catch clauses, and plain try-finally statements. Loops are allowed by default and can be reported by setting allowLoops to false.

Changed Rules

  • The Apex rule ApexUnitTestShouldNotUseSeeAllDataTrue has a new property reportConnectApi. It defaults to true. Set it to false, and the rule does not report seeAllData=true on a test class or test method that calls a ConnectApi method, since most ConnectApi methods require seeAllData=true in tests. A call to a setTest... method does not stop the rule from reporting, because it only registers test data. Nor does a call to the regular method whose test data a setTest... call in the same test registers (see #7236).

Deprecated Rules

  • The Java rule AddEmptyString is deprecated without replacement and will be removed with PMD 8.0.0. Its performance claim is not valid on modern JDKs: constant string concatenations are evaluated at compile time, and replacing concatenation with toString() or String.valueOf() does not generally improve performance. The rule is excluded when referencing the whole Performance category, but explicit rule references continue to work during the deprecation period.

🐛️ Fixed Issues

  • apex
    • #7108: [apex] Expose DML AccessMode (as user / as system) for XPath rules
    • #7182: [apex] Expose the referenced type name on ClassRefExpression for XPath rules
  • apex-bestpractices
    • #5669: [apex] ApexUnitTestMethodShouldHaveIsTestAnnotation: Violation range should only cover the method name
    • #7236: [apex] ApexUnitTestShouldNotUseSeeAllDataTrue: False positive for test classes that call ConnectApi
  • apex-design
    • #4863: [apex] CyclomaticComplexity: False negative with switch statements
  • apex-errorprone
    • #5906: [apex] MethodWithSameNameAsEnclosingClass: Violation range should only cover the method name
  • core
    • #5760: [core] SarifRenderer does not respect relativizeRoots
  • java
    • #7144: [java] Lambda block body that cannot complete normally is not treated as value-compatible
    • #7240: [java] “Not a Java binary name” when importing a class with non-ASCII (e.g. Japanese) letters in its name; the whole file is skipped
    • #7313: [java] Casts to boolean and boolean equality are not folded as constant expressions
  • java-bestpractices
    • #5016: [java] UnusedAssignment: False positive boolean flag for execution and reset in finally
    • #7070: [java] CheckResultSet: False negative caused by unrelated if/while
    • #7116: [java] New rule: ControlFlowInTest
    • #7216: [java] GuardLogStatement: False positive on SLF4J parameterised calls whose arguments are wrapped with logstash value(…)
  • java-codestyle
    • #6731: [java] UnnecessaryFullyQualifiedName: False positive for lombok.Builder annotation
    • #7215: [java] UnnecessaryImport: False positive for on-demand imports with incomplete aux-classpath
  • java-design
    • #5798: [java] NPathComplexity: Short-circuit operators outside of conditions counted as branches
    • #7277: [java] AvoidRethrowingException: False negative if rethrow is wrapped in a block, ExceptionAsFlowControl false positive instead
    • #7279: [java] InternalApiUsage: False positive when static field is used in constructor
  • java-errorprone
    • #4531: [java] MissingStaticMethodInNonInstantiatableClass: False positive with multiple top-level classes
    • #7275: [java] AvoidBranchingStatementAsLastInLoop: False negative when the statement is in a bare block
  • java-multithreading
    • #2786: [java] False positive for UseConcurrentHashMap on ConcurrentSkipListMap
  • java-performance
    • #6327: [java] AddEmptyString: Deprecate rule because performance claim is not valid anymore
    • #7327: [java] AvoidArrayLoops: a copy loop whose body has no braces is not reported
  • jsp
    • #5092: [jsp] Parse error when <!DOCTYPE> or <?xml?> follows other content
  • kotlin
    • #7168: [kotlin] Add @TypeName to VariableDeclaration, fix destructuring type leak
    • #7171: [kotlin] Support the ..< range operator (Kotlin 1.9)
  • misc
    • #6655: Deprecate ANTLR generated lexer implementation classes

🚨️ API Changes and Deprecations

  • apex
    • DML statement nodes now expose @AccessMode. The attribute is always present. Its value is IMPLICIT, USER_MODE, or SYSTEM_MODE. //DmlInsertStatement[@AccessMode='IMPLICIT'] and //DmlInsertStatement[@AccessMode='SYSTEM_MODE'] select those statements.

Experimental API

  • kotlin
    • KtVariableDeclarationAttributes now implements HasTypeName, so VariableDeclaration nodes have a @TypeName attribute. This covers property and for-loop variables, lambda parameters, and each component of a destructuring declaration (val (a, b) = ..., for ((a, b) in ...), { (a, b) -> ... }). The XPath functions pmd-kotlin:typeIs, pmd-kotlin:typeIsExactly and pmd-kotlin:isNullable support VariableDeclaration nodes as well.
    • A destructuring PropertyDeclaration (e.g. val (a, b) = Pair(1, "x")) no longer has a @TypeName. Before, it wrongly got the type of the first component. To find destructured variables by type, query the component nodes instead: //VariableDeclaration[pmd-kotlin:typeIs('kotlin.Int')].

Deprecations

  • apex
  • coco
    • CocoLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • css
    • CssLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • csharp
    • CSharpLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • dart
    • DartLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • gherkin
    • GherkinLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • go
    • GolangLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • javascript
    • TypeScriptLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • julia
    • JuliaLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • kotlin
    • KotlinBaseListener has been deprecated. The class is an implementation detail and should have never been part of the public API.
    • KotlinLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
    • KotlinListener has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • lua
    • LuaLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • rust
    • RustLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • swift
    • SwiftBaseListener has been deprecated. The class is an implementation detail and should have never been part of the public API.
    • SwiftLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
    • SwiftListener has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • tsql
    • TSqlLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • xml
    • XMLLexer has been deprecated. The class is an implementation detail and should have never been part of the public API.
  • The generated KotlinParser and SwiftParser classes and their nested AST node classes are intentionally not deprecated yet. These classes still contain the public AST node types, which have no replacement API yet. They will be deprecated once we have decided how to handle the inner classes.

Other API changes

  • xml
    • The new class XmlRootNode is the root node of the XML AST. It replaces the class XmlParserImpl.RootXmlNode, which was in an internal package. XmlNode#getRoot now returns XmlRootNode.
    • XmlParser is now public and has moved from package net.sourceforge.pmd.lang.xml into net.sourceforge.pmd.lang.xml.ast, like the parsers of other languages.
    • The internal package net.sourceforge.pmd.lang.xml.ast.internal has been removed. Its classes are now package-private in net.sourceforge.pmd.lang.xml.ast.

✨️ Merged pull requests

📦️ Dependency updates

📈️ Stats