We’re excited to bring you the next major version of PMD! Here is a summary of what is planned for PMD 7.
To give us feedback or to suggest a new feature, drop us a line on Gitter!
Summary
New Logo
We decided it’s time to have a modernized logo and get rid of the gun. This allows to include the logo in anywhere without offense.
The current tasks are listed here: Integrate new PMD logo #1931
API
The API of PMD has been growing over the years and needs to be cleaned up. The goal is, to have a clear separation between a well-defined API and the implementation, which is internal. This should help us in future development. This however entails some incompatibilities and deprecations, see also the sections New API support guidelines and [Planned API removals](#planned-api-removals] below.
Full Antlr Support
PMD 6 only supports JavaCC based grammars, but with Antlr parsers can be generated as well. PMD 7 adds full support for grammars written in Antlr, which allows to leverage existing grammars.
The current tasks are listed here: Support for ANTLR based grammars with Swift as an example language #2499
Documentation
We have quite some ideas how we want to improve the documentation. The goal is, that the documentation is up to date and nearly complete. One big task is, how the built-in rules are presented, so that users can easier see, what exactly is available and decide, which rules are useful for the project at hand.
The current tasks are listed here: Documentations improvements tracker #1139
XPath
PMD 6 supports XPath 1.0 via the Jaxen library. This library is old and unmaintained creating some problems
(one of which is duplicated classes in the package org.w3c.dom which is a Java API actually).
Therefore XPath 1.0 support will be dropped and we upgrade our XPath 2.0 implementation with Saxon moving
on to Saxon HE. This will eventually add support in PMD for XPath 3.1.
The current tasks are listed here: XPath Improvements for PMD 7 #2523
Java
Like the main PMD API, the Java AST has been growing over time and the grammar doesn’t support all edge cases (e.g. annotation are not supported everywhere). The goal is to simplify the AST by reducing unnecessary nodes and abstractions and fix the parsing issues. This helps in the end to provide a better type resolution implementation, but changing the AST is a breaking API change.
Some first results of the Java AST changes are for now documented in the Wiki: Java clean changes.
Miscellaneous
There are also some small improvements, refactoring and internal tasks that are planned for PMD 7.
The current tasks are listed here: PMD 7 Miscellaneous Tasks #2524
New API support guidelines
What’s new
Until now, all released public members and types were implicitly considered part of PMD’s public API, including inheritance-specific members (protected members, abstract methods). We have maintained those APIs with the goal to preserve full binary compatibility between minor releases, only breaking those APIs infrequently, for major releases.
In order to allow PMD to move forward at a faster pace, this implicit contract will be invalidated with PMD 7.0.0. We now introduce more fine-grained distinctions between the type of compatibility support we guarantee for our libraries, and ways to make them explicit to clients of PMD.
.internal packages and @InternalApi annotation
Internal API is meant for use only by the main PMD codebase. Internal types and methods may be modified in any way, or even removed, at any time.
Any API in a package that contains an .internal segment is considered internal.
The @InternalApi annotation will be used for APIs that have to live outside of
these packages, e.g. methods of a public type that shouldn’t be used outside of PMD (again,
these can be removed anytime).
@ReservedSubclassing
Types marked with the @ReservedSubclassing annotation are only meant to be subclassed
by classes within PMD. As such, we may add new abstract methods, or remove protected methods,
at any time. All published public members remain supported. The annotation is not inherited, which
means a reserved interface doesn’t prevent its implementors to be subclassed.
@Experimental
APIs marked with the @Experimental annotation at the class or method level are subject to change.
They can be modified in any way, or even removed, at any time. You should not use or rely
on them in any production code. They are purely to allow broad testing and feedback.
@Deprecated
APIs marked with the @Deprecated annotation at the class or method level will remain supported
until the next major release but it is recommended to stop using them.
The transition
All currently supported APIs will remain so until 7.0.0. All APIs that are to be moved to
.internal packages or hidden will be tagged @InternalApi before that major release, and
the breaking API changes will be performed in 7.0.0.
Planned API removals
List of currently deprecated APIs
@Deprecated or not in the latest minor release. During the development of 7.0.0,
we may decide to remove some APIs that were not tagged as deprecated, though we’ll try to avoid it.6.45.0
Experimental APIs
- Report has two new methods which allow limited mutations of a given report:
Report#filterViolationscreates a new report with some violations removed with a given predicate based filter.Report#unioncan combine two reports into a single new Report.
net.sourceforge.pmd.util.Predicatewill be replaced in PMD7 with the standard Predicate interface from java8.- The module
pmd-htmlis entirely experimental right now. Anything in the packagenet.sourceforge.pmd.lang.htmlshould be used cautiously.
6.44.0
Deprecated API
- Several members of
PMDhave been newly deprecated, including:PMD#EOL: useSystem#lineSeparator()PMD#SUPPRESS_MARKER: useDEFAULT_SUPPRESS_MARKERPMD#processFiles: use the new programmatic APIPMD#getApplicableFiles: is internal
PMDConfiguration#prependClasspathis deprecated in favour ofprependAuxClasspath.PMDConfiguration#setRuleSetsandgetRuleSetsare deprecated. Use insteadsetRuleSets,addRuleSet, andgetRuleSetPaths.- Several members of
BaseCLITesthave been deprecated with replacements. -
Several members of
PMDCommandLineInterfacehave been explicitly deprecated. The whole class however was deprecated long ago already with 6.30.0. It is internal API and should not be used. - In modelica, the rule classes
AmbiguousResolutionRuleandConnectUsingNonConnectorhave been deprecated, since they didn’t comply to the usual rule class naming conventions yet. The replacements are in the subpackagebestpractices.
Experimental APIs
-
Together with the new programmatic API the interface
TextFilehas been added as experimental. It intends to replaceDataSourceandSourceCodein the long term.This interface will change in PMD 7 to support read/write operations and other things. You don’t need to use it in PMD 6, as
FileCollectordecouples you from this. A file collector is available throughPmdAnalysis#files.
6.43.0
Deprecated API
Some API deprecations were performed in core PMD classes, to improve compatibility with PMD 7.
Report: the constructor and other construction methods like addViolation or createReportRuleContext: all constructors, getters and setters. A new set of stable methods, matching those in PMD 7, was added to replace theaddViolationoverloads ofAbstractRule. In PMD 7,RuleContextwill be the API to report violations, and it can already be used as such in PMD 6.- The field
configurationis unused and will be removed.
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.
RuleSet: methods that serve to apply rules, includingapply,start,end,removeDysfunctionalRulesAbstractAccumulatingRenderer#renderFileReportis internal API and should not be overridden in own renderers.
Changed API
It is now forbidden to report a violation:
- With a
nullnode - With a
nullmessage - With a
nullset of format arguments (prefer a zero-length array)
Note that the message is set from the XML rule declaration, so this is only relevant if you instantiate rules manually.
RuleContext now requires setting the current rule before calling
apply. This is
done automatically by RuleSet#apply and such. Creating and configuring a
RuleContext manually is strongly advised against, as the lifecycle of RuleContext
will change drastically in PMD 7.
6.42.0
No changes.
6.41.0
Command Line Interface
The command line options for PMD and CPD now use GNU-syle long options format. E.g. instead of -rulesets the
preferred usage is now --rulesets. Alternatively one can still use the short option -R.
Some options also have been renamed to a more consistent casing pattern at the same time
(--fail-on-violation instead of -failOnViolation).
The old single-dash options are still supported but are deprecated and will be removed with PMD 7.
This change makes the command line interface more consistent within PMD and also less surprising
compared to other cli tools.
The changes in detail for PMD:
| old option | new option |
|---|---|
-rulesets |
--rulesets (or -R) |
-uri |
--uri |
-dir |
--dir (or -d) |
-filelist |
--file-list |
-ignorelist |
--ignore-list |
-format |
--format (or -f) |
-debug |
--debug |
-verbose |
--verbose |
-help |
--help |
-encoding |
--encoding |
-threads |
--threads |
-benchmark |
--benchmark |
-stress |
--stress |
-shortnames |
--short-names |
-showsuppressed |
--show-suppressed |
-suppressmarker |
--suppress-marker |
-minimumpriority |
--minimum-priority |
-property |
--property |
-reportfile |
--report-file |
-force-language |
--force-language |
-auxclasspath |
--aux-classpath |
-failOnViolation |
--fail-on-violation |
--failOnViolation |
--fail-on-violation |
-norulesetcompatibility |
--no-ruleset-compatibility |
-cache |
--cache |
-no-cache |
--no-cache |
The changes in detail for CPD:
| old option | new option |
|---|---|
--failOnViolation |
--fail-on-violation |
-failOnViolation |
--fail-on-violation |
--filelist |
--file-list |
6.40.0
Experimental APIs
- The interface
ASTCommentContainerhas been added to the Apex AST. It provides a way to check whether a node contains at least one comment. Currently this is only implemented forASTCatchBlockStatementand used by the ruleEmptyCatchBlock. This information is also available via XPath attribute@ContainsComment.
6.39.0
No changes.
6.38.0
No changes.
6.37.0
PMD CLI
-
PMD has a new CLI option
-force-language. With that a language can be forced to be used for all input files, irrespective of filenames. When using this option, the automatic language selection by extension is disabled and all files are tried to be parsed with the given language. Parsing errors are ignored and unparsable files are skipped.This option allows to use the xml language for files, that don’t use xml as extension. See also the examples on PMD CLI reference.
Experimental APIs
- The AST types and APIs around Sealed Classes are not experimental anymore:
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.
- The inner class
net.sourceforge.pmd.cpd.TokenEntry.Stateis considered to be internal API. It will probably be moved away with PMD 7.
6.36.0
No changes.
6.35.0
Deprecated API
PMD#doPMDis deprecated. UsePMD#runPMDinstead.PMD#runis deprecated. UsePMD#runPMDinstead.ThreadSafeReportListenerand the methods to use them inReport(addListener,getListeners,addListeners) are deprecated. This functionality will be replaced by another TBD mechanism in PMD 7.
6.34.0
No changes.
6.33.0
No changes.
6.32.0
Experimental APIs
- The experimental class
ASTTypeTestPatternhas been renamed toASTTypePatternin order to align the naming to the JLS. - The experimental class
ASTRecordConstructorDeclarationhas been renamed toASTCompactConstructorDeclarationin order to align the naming to the JLS. - The AST types and APIs around Pattern Matching and Records are not experimental anymore:
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.
- The protected or public member of the Java rule
AvoidUsingHardCodedIPRuleare deprecated and considered to be internal API. They will be removed with PMD 7.
6.31.0
Deprecated API
AbstractDomXmlRuleAbstractWsdlRule- A few methods of
AbstractXmlRule
Experimental APIs
- The method
GenericToken#getKindhas been added as experimental. This unifies the token interface for both JavaCC and Antlr. The already existing methodAntlrToken#getKindis therefore experimental as well. The returned constant depends on the actual language and might change whenever the grammar of the language is changed.
6.30.0
Deprecated API
Around RuleSet parsing
RuleSetFactoryandRulesetsFactoryUtilshave been deprecated in favor ofRuleSetLoader. This is easier to configure, and more maintainable than the multiple overloads ofRulesetsFactoryUtils.- Some static creation methods have been added to
RuleSetfor simple cases, egforSingleRule. These replace some counterparts inRuleSetFactory - Since
RuleSetsis also deprecated, many APIs that require a RuleSets instance now are deprecated, and have a counterpart that expects aList<RuleSet>. RuleSetReferenceId,RuleSetReference,RuleSetFactoryCompatibilityare deprecated. They are most likely not relevant outside of the implementation of pmd-core.
Around the PMD class
Many classes around PMD’s entry point (PMD) have been deprecated as internal, including:
- The contents of the packages
net.sourceforge.pmd.cli,net.sourceforge.pmd.processor SourceCodeProcessor- The constructors of
PMD(the class will be made a utility class)
Miscellaneous
ASTPackageDeclaration#getPackageNameImage,ASTTypeParameter#getParameterNameand the corresponding XPath attributes. In both cases they’re replaced with a new methodgetName, the attribute is@Name.ASTClassOrInterfaceBody#isAnonymousInnerClass, andASTClassOrInterfaceBody#isEnumChild, refs #905
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.
net.sourceforge.pmd.lang.ecmascript.Ecmascript3Handlernet.sourceforge.pmd.lang.ecmascript.Ecmascript3ParserEcmascriptParser#parserOptionsEcmascriptParser#getSuppressMapnet.sourceforge.pmd.lang.rule.ParametricRuleViolationParserOptions#suppressMarkernet.sourceforge.pmd.lang.modelica.rule.ModelicaRuleViolationFactory
6.29.0
No changes.
6.28.0
Deprecated API
For removal
net.sourceforge.pmd.RuleViolationComparator. UseRuleViolation#DEFAULT_COMPARATORinstead.net.sourceforge.pmd.cpd.AbstractTokenizer. Usenet.sourceforge.pmd.cpd.AnyTokenizerinstead.net.sourceforge.pmd.cpd.FortranTokenizer. Was replaced by anAnyTokenizer. UseFortranLanguage#getTokenizeranyway.net.sourceforge.pmd.cpd.PerlTokenizer. Was replaced by anAnyTokenizer. UsePerlLanguage#getTokenizeranyway.net.sourceforge.pmd.cpd.RubyTokenizer. Was replaced by anAnyTokenizer. UseRubyLanguage#getTokenizeranyway.RuleReference#getOverriddenLanguageandRuleReference#setLanguage- Antlr4 generated lexers:
net.sourceforge.pmd.lang.cs.antlr4.CSharpLexerwill be moved to packagenet.sourceforge.pmd.lang.cs.astwith PMD 7.net.sourceforge.pmd.lang.dart.antlr4.Dart2Lexerwill be renamed toDartLexerand moved to packagenet.sourceforge.pmd.lang.dart.astwith PMD 7. All other classes in the old package will be removed.net.sourceforge.pmd.lang.go.antlr4.GolangLexerwill be moved to packagenet.sourceforge.pmd.lang.go.astwith PMD 7. All other classes in the old package will be removed.net.sourceforge.pmd.lang.kotlin.antlr4.Kotlinwill be renamed toKotlinLexerand moved to packagenet.sourceforge.pmd.lang.kotlin.astwith PMD 7.net.sourceforge.pmd.lang.lua.antlr4.LuaLexerwill be moved to packagenet.sourceforge.pmd.lang.lua.astwith PMD 7. All other classes in the old package will be removed.
6.27.0
- XML rule definition in rulesets: In PMD 7, the
languageattribute will be required on allruleelements 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 missinglanguageattributes are now reported as a forward compatibility warning.
Deprecated API
For removal
Rule#getParserOptionsParser#getParserOptionsAbstractParserRuleContext#removeAttributeRuleContext#getAttributeRuleContext#setAttributeApexParserOptionsASTThrowStatement#getFirstClassOrInterfaceTypeImageEcmascriptParserOptionsEcmascriptXPathRuleXmlParserOptionsXmlXPathRule-
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) andisEmpty()are both replaced bygetViolations(). - The dataflow codebase is deprecated for removal in PMD 7. This includes all code in the following packages, and their subpackages:
ASTJspDeclarationsASTJspDocumentScalaParserVisitorAdapter#zeroScalaParserVisitorAdapter#combineApexParserVisitorReducedAdapterTypeHelperis deprecated in favor ofTypeTestUtil, which has the same functionality, but a slightly changed API.- Many of the classes in
net.sourceforge.pmd.lang.java.symboltableare deprecated as internal API.
6.26.0
Deprecated API
For removal
RuleChainVisitorand all implementations in language modulesAbstractRuleChainVisitorLanguage#getRuleChainVisitorClassBaseLanguageModule#<init>ImportWrapper
6.25.0
-
The maven module
net.sourceforge.pmd:pmd-scalais deprecated. Usenet.sourceforge.pmd:pmd-scala_2.13ornet.sourceforge.pmd:pmd-scala_2.12instead. -
Rule implementation classes are internal API and should not be used by clients directly. The rules should only be referenced via their entry in the corresponding category ruleset (e.g.
<rule ref="category/java/bestpractices.xml/AbstractClassWithoutAbstractMethod" />).While we definitely won’t move or rename the rule classes in PMD 6.x, we might consider changes in PMD 7.0.0 and onwards.
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.
AbstractIgnoredAnnotationRule(Java)AbstractInefficientZeroCheck(Java)AbstractJUnitRule(Java)AbstractJavaMetricsRule(Java)AbstractLombokAwareRule(Java)AbstractPoorMethodCall(Java)AbstractSunSecureRule(Java)AbstractNcssCountRule(Java)AbstractCommentRule(Java)AbstractOptimizationRule(Java)RegexHelper(Java)AbstractApexUnitTestRule(Apex)AbstractNcssCountRule(Apex)AbstractNcssCountRule(PLSQL)ApexParserApexHandlerRuleChainRuleSetsRulesetsFactoryUtils#getRuleSets
For removal
TokenEntry#TokenEntryAbstractTokenizerTest. Use CpdTextComparisonTest in module pmd-lang-test instead. For details see Testing your implementation in the developer documentation.ASTAnnotation#suppresses(Apex)ApexXPathRule(Apex)SymbolTableTestRule(Java)InefficientStringBufferingRule#isInStringBufferOperation
6.24.0
Deprecated APIs
BaseLanguageModule#addVersion(String, LanguageVersionHandler, boolean)- Some members of
TokenMgrError, in particular, a new constructor is available that should be preferred to the old ones AntlrTokenManager.ANTLRSyntaxError
Experimental APIs
Note: Experimental APIs are identified with the annotation Experimental,
see its javadoc for details
- The experimental methods in
BaseLanguageModulehave been replaced by a definitive API.
6.23.0
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.
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 Apex, Javascript, PL/SQL, Scala and Visualforce ASTs:
- 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 they 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. The base classes are internal API and will be hidden in version 7.0.0. You should not couple your code to them.
- 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.
- The implementation classes of
Parser(egVfParser) are deprecated and should not be used directly. UseLanguageVersionHandler#getParserinstead. - The implementation classes of
TokenManager(egVfTokenManager) are deprecated and should not be used outside of our implementation. This also affects CPD-only modules.
These deprecations are added to the following language modules in this release. Please look at the package documentation to find out the full list of deprecations.
- Apex:
net.sourceforge.pmd.lang.apex.ast - Javascript:
net.sourceforge.pmd.lang.ecmascript.ast - PL/SQL:
net.sourceforge.pmd.lang.plsql.ast - Scala:
net.sourceforge.pmd.lang.scala.ast - Visualforce:
net.sourceforge.pmd.lang.vf.ast
These deprecations have already been rolled out in a previous version for the following languages:
- Java:
net.sourceforge.pmd.lang.java.ast - Java Server Pages:
net.sourceforge.pmd.lang.jsp.ast - Velocity Template Language:
net.sourceforge.pmd.lang.vm.ast
Outside of these packages, these changes also concern the following TokenManager implementations, and their corresponding Parser if it exists (in the same package):
CppTokenManagerJavaTokenManagerEcmascript5TokenManagerJspTokenManagerMatlabTokenManagerModelicaTokenManagerObjectiveCTokenManagerPLSQLTokenManagerPythonTokenManagerVfTokenManagerVmTokenManager
In the Java AST the following attributes are deprecated and will issue a warning when used in XPath rules:
ASTAdditiveExpression#getImage- usegetOperator()insteadASTVariableDeclaratorId#getImage- usegetName()insteadASTVariableDeclaratorId#getVariableName- usegetName()instead
For removal
Parser#getTokenManagerTokenManager#setFileNameAbstractTokenManager#setFileNameAbstractTokenManager#getFileNameAntlrToken#getType- usegetKind()instead.ImmutableLanguageMockRuleNode#getFirstParentOfAnyTypeNode#getAsDocumentAbstractNode#hasDescendantOfAnyTypeASTRecordDeclaration#getComponentList- Multiple fields, constructors and methods in
XPathRule. See javadoc for details.
6.22.0
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.
JavaLanguageHandlerJavaLanguageParserJavaDataFlowHandler- Implementations of
RuleViolationFactoryin each language module, egJavaRuleViolationFactory. See javadoc ofRuleViolationFactory. -
Implementations of
RuleViolationin each language module, egJavaRuleViolation. See javadoc ofRuleViolation. RuleFactoryRuleBuilder- Constructors of
RuleSetFactory, use factory methods fromRulesetsFactoryUtilsinstead AbstractApexNodeAbstractApexNodeBase, and the relatedvisitmethods onApexParserVisitorand its implementations. UseApexNodeinstead, now considers comments too.
For removal
- pmd-core
DFAGraphRuleand its implementationsDFAGraphMethod- Many methods on the
Nodeinterface andAbstractNodebase class. See their javadoc for details. Node#isFindBoundaryis deprecated for XPath queries.- Many APIs of
net.sourceforge.pmd.lang.metrics, though most of them were internal and probably not used directly outside of PMD. UseMetricsUtilas a replacement for the language-specific façades too. QualifiableNode,QualifiedName
- pmd-java
AbstractJavaParserAbstractJavaHandlerASTAnyTypeDeclaration.TypeKindASTAnyTypeDeclaration#getKindJavaQualifiedNameASTCatchStatement#getBlockASTCompilationUnit#declarationsAreInDefaultPackageJavaQualifiableNodenet.sourceforge.pmd.lang.java.qnameand its contentsMethodLikeNode- Its methods will also be removed from its implementations,
ASTMethodOrConstructorDeclaration,ASTLambdaExpression.
- Its methods will also be removed from its implementations,
ASTAnyTypeDeclaration#getImagewill be removed. Please usegetSimpleName()instead. This affectsASTAnnotationTypeDeclaration#getImage,ASTClassOrInterfaceDeclaration#getImage, andASTEnumDeclaration#getImage.- Several methods of
ASTTryStatement, replacements with other names have been added. This includes the XPath attribute@Finally, replace it with a test forchild::FinallyStatement. - Several methods named
getGuardExpressionNodeare replaced withgetCondition. This affects the following nodes: WhileStatement, DoStatement, ForStatement, IfStatement, AssertStatement, ConditionalExpression. ASTYieldStatementwill not implementTypeNodeanymore come 7.0.0. Test the type of the expression nested within it.JavaMetrics,JavaMetricsComputerASTArguments#getArgumentCount. Usesizeinstead.ASTFormalParameters#getParameterCount. Usesizeinstead.
- pmd-apex
In ASTs (JSP)
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 JSP 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 they 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. The base classes are internal API and will be hidden in version 7.0.0. You should not couple your code to them.
- 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.
- The class
JspParseris deprecated and should not be used directly. UseLanguageVersionHandler#getParserinstead.
Please look at net.sourceforge.pmd.lang.jsp.ast to find out the full list of deprecations.
In ASTs (Velocity)
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 VM 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 they 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. The base classes are internal API and will be hidden in version 7.0.0. You should not couple your code to them.
- 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.
- The package
net.sourceforge.pmd.lang.vm.directiveas well as the classesDirectiveMapperandLogUtilare deprecated for removal. They were only used internally during parsing. - The class
VmParseris deprecated and should not be used directly. UseLanguageVersionHandler#getParserinstead.
Please look at net.sourceforge.pmd.lang.vm.ast to find out the full list of deprecations.
PLSQL AST
The production and node ASTCursorBody was unnecessary, not used and has been removed. Cursors have been already
parsed as ASTCursorSpecification.
6.21.0
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.
JavaLanguageHandlerJavaLanguageParserJavaDataFlowHandler- Implementations of
RuleViolationFactoryin each language module, egJavaRuleViolationFactory. See javadoc ofRuleViolationFactory. -
Implementations of
RuleViolationin each language module, egJavaRuleViolation. See javadoc ofRuleViolation. RuleFactoryRuleBuilder- Constructors of
RuleSetFactory, use factory methods fromRulesetsFactoryUtilsinstead AbstractApexNode-
AbstractApexNodeBase, and the relatedvisitmethods onApexParserVisitorand its implementations. UseApexNodeinstead, 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 ofParseException, whose usages will be replaced by just that superclass.
For removal
- pmd-core
- Many methods on the
Nodeinterface andAbstractNodebase class. See their javadoc for details. Node#isFindBoundaryis deprecated for XPath queries.
- Many methods on the
- pmd-java
AbstractJavaParserAbstractJavaHandlerASTAnyTypeDeclaration.TypeKindASTAnyTypeDeclaration#getKindJavaQualifiedNameASTCatchStatement#getBlockASTCompilationUnit#declarationsAreInDefaultPackageJavaQualifiableNodenet.sourceforge.pmd.lang.java.qnameand its contentsMethodLikeNode- Its methods will also be removed from its implementations,
ASTMethodOrConstructorDeclaration,ASTLambdaExpression.
- Its methods will also be removed from its implementations,
ASTAnyTypeDeclaration#getImagewill be removed. Please usegetSimpleName()instead. This affectsASTAnnotationTypeDeclaration#getImage,ASTClassOrInterfaceDeclaration#getImage, andASTEnumDeclaration#getImage.- Several methods of
ASTTryStatement, replacements with other names have been added. This includes the XPath attribute@Finally, replace it with a test forchild::FinallyStatement. - Several methods named
getGuardExpressionNodeare replaced withgetCondition. This affects the following nodes: WhileStatement, DoStatement, ForStatement, IfStatement, AssertStatement, ConditionalExpression. ASTYieldStatementwill not implementTypeNodeanymore come 7.0.0. Test the type of the expression nested within it.
6.20.0
No changes.
6.19.0
Deprecated APIs
For removal
- pmd-core
- All the package
net.sourceforge.pmd.dcdand its subpackages. SeeDCD. - In
LanguageRegistry: RuleSet#getExcludePatterns. Use the new methodgetFileExclusionsinstead.RuleSet#getIncludePatterns. Use the new methodgetFileInclusionsinstead.Parser#canParseParser#getSuppressMapRuleBuilder#RuleBuilder. Use the new constructor with the correct ResourceLoader instead.RuleFactory#RuleFactory. Use the new constructor with the correct ResourceLoader instead.
- All the package
- pmd-java
CanSuppressWarningsand its implementationsisSuppressedgetDeclaringType.isSupressedASTMethodDeclaratorgetMethodNamegetBlockgetParameterCount
- pmd-apex
CanSuppressWarningsand its implementationsisSupressed
Internal APIs
- pmd-core
- All the package
net.sourceforge.pmd.utiland its subpackages, exceptnet.sourceforge.pmd.util.datasourceandnet.sourceforge.pmd.util.database. GridBagHelperColumnDescriptor
- All the package
6.18.0
Changes to Renderer
-
Each renderer has now a new method
Renderer#setUseShortNameswhich 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 methodAbstractRenderer#determineFileNameshould 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
- The methods
getImportedNameNodeandgetPackagehave been deprecated and will be removed with PMD 7.0.0. - The method
RuleContext#setSourceCodeFilenamehas been deprecated and will be removed. The already existing methodRuleContext#setSourceCodeFileshould be used instead. The methodRuleContext#getSourceCodeFilenamestill exists and returns just the filename without the full path. - The method
AbstractPMDProcessor#filenameFromhas been deprecated. It was used to determine a “short name” of the file being analyzed, so that the report can use short names. However, this logic has been moved to the renderers. - The method
Report#metricsandReporthave been deprecated. They were leftovers from a previous deprecation round targetingStatisticalRule.
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.
- pmd-core
- pmd-java
net.sourceforge.pmd.lang.java.typeresolution: Everything, including subpackages, exceptTypeHelperandJavaTypeDefinition.ASTCompilationUnit#getClassTypeResolver
6.17.0
No changes.
6.16.0
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.
- 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 to find out the full list
of deprecations.
6.15.0
Deprecated APIs
For removal
- The
DumpFacadesin all languages, that could be used to transform a AST into a textual representation, will be removed with PMD 7. The rule designer is a better way to inspect nodes.net.sourceforge.pmd.lang.apex.ast.DumpFacadenet.sourceforge.pmd.lang.java.ast.DumpFacadenet.sourceforge.pmd.lang.ecmascript.ast.DumpFacadenet.sourceforge.pmd.lang.jsp.ast.DumpFacadenet.sourceforge.pmd.lang.plsql.ast.DumpFacadenet.sourceforge.pmd.lang.vf.ast.DumpFacadenet.sourceforge.pmd.lang.vm.ast.AbstractVmNode#dumpnet.sourceforge.pmd.lang.xml.ast.DumpFacade
- The method
LanguageVersionHandler#getDumpFacadewill be removed as well. It is deprecated, along with all its implementations in the subclasses ofLanguageVersionHandler.
6.14.0
No changes.
6.13.0
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
-
CodeClimateRuleis 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.xmlhas been deprecated and will be removed in 7.0.0. Please use the new quickstart rulesetrulesets/apex/quickstart.xmlinstead.
6.12.0
No changes.
6.11.0
StatisticalRuleand the related helper classes and base rule classes are deprecated for removal in 7.0.0. This includes all ofnet.sourceforge.pmd.statandnet.sourceforge.pmd.lang.rule.stat, and alsoAbstractStatisticalJavaRule,AbstractStatisticalApexRuleand the like. The methodsReport#addMetricandmetricAddedwill also be removed.setPropertyis deprecated, becauseMultiValuePropertyDescriptoris deprecated as well
6.10.0
Properties framework
The properties framework is about to get a lifting, and for that reason, we need to deprecate a lot of APIs to remove them in 7.0.0. The proposed changes to the API are described on the wiki
Changes to how you define properties
-
Construction of property descriptors has been possible through builders since 6.0.0. The 7.0.0 API will only allow construction through builders. The builder hierarchy, currently found in the package
net.sourceforge.pmd.properties.builders, is being replaced by the simplerPropertyBuilder. Their APIs enjoy a high degree of source compatibility. -
Concrete property classes like
IntegerPropertyandStringMultiPropertywill gradually all be deprecated until 7.0.0. Their usages should be replaced by direct usage of thePropertyDescriptorinterface, e.g.PropertyDescriptor<Integer>orPropertyDescriptor<List<String>>. -
Instead of spreading properties across countless classes, the utility class
PropertyFactorywill become from 7.0.0 on the only provider for property descriptor builders. Each current property type will be replaced by a corresponding method onPropertyFactory:IntegerPropertyis replaced byPropertyFactory#intPropertyIntegerMultiPropertyis replaced byPropertyFactory#intListProperty
FloatPropertyandDoublePropertyare both replaced byPropertyFactory#doubleProperty. Having a separate property for floats wasn’t that useful.- Similarly,
FloatMultiPropertyandDoubleMultiPropertyare replaced byPropertyFactory#doubleListProperty.
- Similarly,
StringPropertyis replaced byPropertyFactory#stringPropertyStringMultiPropertyis replaced byPropertyFactory#stringListProperty
-
RegexPropertyis replaced byPropertyFactory#regexProperty EnumeratedPropertyis replaced byPropertyFactory#enumPropertyEnumeratedPropertyis replaced byPropertyFactory#enumListProperty
BooleanPropertyis replaced byPropertyFactory#booleanProperty- Its multi-valued counterpart,
BooleanMultiProperty, is not replaced, because it doesn’t have a use case.
- Its multi-valued counterpart,
CharacterPropertyis replaced byPropertyFactory#charPropertyCharacterMultiPropertyis replaced byPropertyFactory#charListProperty
LongPropertyis replaced byPropertyFactory#longIntPropertyLongMultiPropertyis replaced byPropertyFactory#longIntListProperty
MethodProperty,FileProperty,TypePropertyand their multi-valued counterparts are discontinued for lack of a use-case, and have no planned replacement in 7.0.0 for now.
Here’s an example:
// Before 7.0.0, these are equivalent:
IntegerProperty myProperty = new IntegerProperty("score", "Top score value", 1, 100, 40, 3.0f);
IntegerProperty myProperty = IntegerProperty.named("score").desc("Top score value").range(1, 100).defaultValue(40).uiOrder(3.0f);
// They both map to the following in 7.0.0
PropertyDescriptor<Integer> myProperty = PropertyFactory.intProperty("score").desc("Top score value").require(inRange(1, 100)).defaultValue(40);
You’re highly encouraged to migrate to using this new API as soon as possible, to ease your migration to 7.0.0.
Architectural simplifications
-
EnumeratedPropertyDescriptor,NumericPropertyDescriptor,PackagedPropertyDescriptor, and the related builders (innet.sourceforge.pmd.properties.builders) will be removed. These specialized interfaces allowed additional constraints to be enforced on the value of a property, but made the property class hierarchy very large and impractical to maintain. Their functionality will be mapped uniformly toPropertyConstraints, which will allow virtually any constraint to be defined, and improve documentation and error reporting. The related methodsPropertyTypeId#isPropertyNumericandPropertyTypeId#isPropertyPackagedare also deprecated. -
MultiValuePropertyDescriptorandSingleValuePropertyDescriptorare deprecated. 7.0.0 will introduce a new XML syntax which will remove the need for such a divide between single- and multi-valued properties. The methodPropertyDescriptor#isMultiValuewill be removed accordingly.
Changes to the PropertyDescriptor interface
preferredRowCountis deprecated with no intended replacement. It was never implemented, and does not belong in this interface. The methodsuiOrderandcompareTo(PropertyDescriptor)are deprecated for the same reason. These methods mix presentation logic with business logic and are not necessary for PropertyDescriptors to work.PropertyDescriptorwill not extendComparable<PropertyDescriptor>anymore come 7.0.0.- The method
propertyErrorForis deprecated and will be removed with no intended replacement. It’s really just a shortcut forprop.errorFor(rule.getProperty(prop)). TvalueFrom(String)andStringasDelimitedString(T)are deprecated and will be removed. These were used to serialize and deserialize properties to/from a string, but 7.0.0 will introduce a more flexible XML syntax which will make them obsolete.isMultiValueandtypeare deprecated and won’t be replaced. The new XML syntax will remove the need for a divide between multi- and single-value properties, and will allow arbitrary types to be represented. Since arbitrary types may be represented,typewill become obsolete as it can’t represent generic types, which will nevertheless be representable with the XML syntax. It was only used for documentation, but a new way to document these properties exhaustively will be added with 7.0.0.errorForis deprecated as its return type will be changed toOptional<String>with the shift to Java 8.
Deprecated APIs
For internalization
-
The implementation of the adapters for the XPath engines Saxon and Jaxen (package
net.sourceforge.pmd.lang.ast.xpath) are now deprecated. They’ll be moved to an internal package come 7.0.0. OnlyAttributeremains public API. -
The classes
PropertyDescriptorField,PropertyDescriptorBuilderConversionWrapper, and the methodsPropertyDescriptor#attributeValuesById,PropertyDescriptor#isDefinedExternallyandPropertyTypeId#getFactory. These were used to read and write properties to and from XML, but were not intended as public API. -
The class
ValueParserConstantsand the interfaceValueParser. -
All classes from
net.sourceforge.pmd.lang.java.metrics.impl.visitorsare now considered internal API. They’re deprecated and will be moved into an internal package with 7.0.0. To implement your own metrics visitors,JavaParserVisitorAdaptershould be directly subclassed. -
LanguageVersionHandler#getDataFlowHandler(),LanguageVersionHandler#getDFAGraphRule()
For removal
-
All classes from
net.sourceforge.pmd.properties.moduleswill be removed. -
The interface
Dimensionablehas been deprecated. It gets in the way of a grammar change for 7.0.0 and won’t be needed anymore (see #997). -
Several methods from
ASTLocalVariableDeclarationandASTFieldDeclarationhave also been deprecated:-
ASTFieldDeclarationwon’t be aTypeNodecome 7.0.0, sogetTypeandgetTypeDefinitionare deprecated. -
The method
getVariableNameon those two nodes will be removed, too.
All these are deprecated because those nodes may declare several variables at once, possibly with different types (and obviously with different names). They both implement
Iterator<ASTVariableDeclaratorId>though, so you should iterate on each declared variable. See #910. -
-
Visitor decorators are now deprecated and will be removed in PMD 7.0.0. They were originally a way to write composable visitors, used in the metrics framework, but they didn’t prove cost-effective.
- In
net.sourceforge.pmd.lang.java.ast:JavaParserDecoratedVisitor,JavaParserControllessVisitor,JavaParserControllessVisitorAdapter, andJavaParserVisitorDecoratorare deprecated with no intended replacement.
- In
-
The LanguageModules of several languages, that only support CPD execution, have been deprecated. These languages are not fully supported by PMD, so having a language module does not make sense. The functionality of CPD is not affected by this change. The following classes have been deprecated and will be removed with PMD 7.0.0:
CppHandlerCppLanguageModuleCppParserCsLanguageModuleFortranLanguageModuleGroovyLanguageModuleMatlabHandlerMatlabLanguageModuleMatlabParserObjectiveCHandlerObjectiveCLanguageModuleObjectiveCParserPhpLanguageModulePythonHandlerPythonLanguageModulePythonParserRubyLanguageModuleScalaLanguageModuleSwiftLanguageModule
-
Optional AST processing stages like symbol table, type resolution or data-flow analysis will be reified in 7.0.0 to factorise common logic and make them extensible. Further explanations about this change can be found on #1426. Consequently, the following APIs are deprecated for removal:
- In
Rule:isDfa(),isTypeResolution(),isMultifile()and their respective setters. - In
RuleSet:usesDFA(Language),usesTypeResolution(Language),usesMultifile(Language) - In
RuleSets:usesDFA(Language),usesTypeResolution(Language),usesMultifile(Language) - In
LanguageVersionHandler:getDataFlowFacade(),getSymbolFacade(),getSymbolFacade(ClassLoader),getTypeResolutionFacade(ClassLoader),getQualifiedNameResolutionFacade(ClassLoader)
- In
6.9.0
No changes.
6.8.0
-
A couple of methods and fields in
net.sourceforge.pmd.properties.AbstractPropertySourcehave been deprecated, as they are replaced by already existing functionality or expose internal implementation details:propertyDescriptors,propertyValuesByDescriptor,copyPropertyDescriptors(),copyPropertyValues(),ignoredProperties(),usesDefaultValues(),useDefaultValueFor(). -
Some methods in
net.sourceforge.pmd.properties.PropertySourcehave been deprecated as well:usesDefaultValues(),useDefaultValueFor(),ignoredProperties(). -
The class
net.sourceforge.pmd.lang.rule.AbstractDelegateRulehas been deprecated and will be removed with PMD 7.0.0. It is internally only in use by RuleReference. -
The default constructor of
net.sourceforge.pmd.lang.rule.RuleReferencehas been deprecated and will be removed with PMD 7.0.0. RuleReferences should only be created by providing a Rule and a RuleSetReference. Furthermore the following methods are deprecated:setRuleReference(),hasOverriddenProperty(),usesDefaultValues(),useDefaultValueFor().
6.7.0
-
All classes in the package
net.sourceforge.pmd.lang.dfa.reporthave been deprecated and will be removed with PMD 7.0.0. This includes the classnet.sourceforge.pmd.lang.dfa.report.ReportTree. The reason is, that this class is very specific to Java and not suitable for other languages. It has only been used forYAHTMLRenderer, which has been rewritten to work without these classes. -
The nodes RUNSIGNEDSHIFT and RSIGNEDSHIFT are deprecated and will be removed from the AST with PMD 7.0.0. These represented the operator of ShiftExpression in two cases out of three, but they’re not needed and make ShiftExpression inconsistent. The operator of a ShiftExpression is now accessible through ShiftExpression#getOperator.
6.5.0
-
The utility class
net.sourceforge.pmd.lang.java.ast.CommentUtilhas been deprecated and will be removed with PMD 7.0.0. Its methods have been intended to parse javadoc tags. A more useful solution will be added around the AST nodeFormalComment, which contains as childrenJavadocElementnodes, which in turn provide access to theJavadocTag.All comment AST nodes (
FormalComment,MultiLineComment,SingleLineComment) have a new methodgetFilteredComment()which provide access to the comment text without the leading/*markers. -
The method
AbstractCommentRule.tagsIndicesIn()has been deprecated and will be removed with PMD 7.0.0. It is not very useful, since it doesn’t extract the information in a useful way. You would still need check, which tags have been found, and with which data they might be accompanied.
6.4.0
- The following classes in package
net.sourceforge.pmd.benchmarkhave been deprecated:Benchmark,Benchmarker,BenchmarkReport,BenchmarkResult,RuleDuration,StringBuilderCRandTextReport. Their API is not supported anymore and is disconnected from the internals of PMD. Use the newer API based aroundTimeTrackerinstead, which can be found in the same package. - The class
net.sourceforge.pmd.lang.java.xpath.TypeOfFunctionhas been deprecated. Use the newerTypeIsFunctionin the same package. - The
typeofmethods innet.sourceforge.pmd.lang.java.xpath.JavaFunctionshave been deprecated. Use the newertypeIsmethod in the same class instead.. - The methods
isA,isEitherandisNeitherofnet.sourceforge.pmd.lang.java.typeresolution.TypeHelper. Use the newisExactlyAnyandisExactlyNonemethods in the same class instead.
6.2.0
-
The static method
PMDParameters.transformParametersIntoConfiguration(PMDParameters)is now deprecated, for removal in 7.0.0. The new instance methodPMDParameters.toConfiguration()replaces it. -
The method
ASTConstructorDeclaration.getParameters()has been deprecated in favor of the new methodgetFormalParameters(). This method is available for bothASTConstructorDeclarationandASTMethodDeclaration.
6.1.0
- The method
getXPathNodeNameis added to theNodeinterface, which removes the use of thetoStringof a node to get its XPath element name (see #569).- The default implementation provided in
AbstractNode, will be removed with 7.0.0 - With 7.0.0, the
Node.toStringmethod will not necessarily provide its XPath node name anymore.
- The default implementation provided in
-
The interface
net.sourceforge.pmd.cpd.Rendererhas been deprecated. A new interfacenet.sourceforge.pmd.cpd.renderer.CPDRendererhas been introduced to replace it. The main difference is that the new interface is meant to render directly to ajava.io.Writerrather than to a String. This allows to greatly reduce the memory footprint of CPD, as on large projects, with many duplications, it was causingOutOfMemoryErrors (see #795).net.sourceforge.pmd.cpd.FileReporterhas also been deprecated as part of this change, as it’s no longer needed.
6.0.1
- The constant
net.sourceforge.pmd.PMD.VERSIONhas been deprecated and will be removed with PMD 7.0.0. Please usenet.sourceforge.pmd.PMDVersion.VERSIONinstead.
List of currently deprecated rules
-
The Java rules
VariableNamingConventions,MIsLeadingVariableName,SuspiciousConstantFieldName, andAvoidPrefixingMethodParametersare now deprecated, and will be removed with version 7.0.0. They are replaced by the more generalFieldNamingConventions,FormalParameterNamingConventions, andLocalVariableNamingConventions. -
The Java rule
AbstractNamingis deprecated in favour ofClassNamingConventions. -
The Java rules
WhileLoopsMustUseBraces,ForLoopsMustUseBraces,IfStmtsMustUseBraces, andIfElseStmtsMustUseBracesare deprecated. They will be replaced by the new ruleControlStatementBraces. -
The Java rules
NcssConstructorCount,NcssMethodCount, andNcssTypeCounthave been deprecated. They will be replaced by the new ruleNcssCountin the categorydesign. -
The Java rule
LooseCouplingin rulesetjava-typeresolutionis deprecated. Use the rule with the same name from categorybestpracticesinstead. -
The Java rule
CloneMethodMustImplementCloneablein rulesetjava-typeresolutionis deprecated. Use the rule with the same name from categoryerrorproneinstead. -
The Java rule
UnusedImportsin rulesetjava-typeresolutionis deprecated. Use the rule with the same name from categorybestpracticesinstead. -
The Java rule
SignatureDeclareThrowsExceptionin rulesetjava-typeresolutionis deprecated. Use the rule with the same name from categorydesigninstead. -
The Java rule
EmptyStaticInitializerin rulesetjava-emptyis deprecated. Use the ruleEmptyInitializer, which covers both static and non-static empty initializers.` -
The Java rules
GuardDebugLogging(rulesetjava-logging-jakarta-commons) andGuardLogStatementJavaUtil(rulesetjava-logging-java) have been deprecated. Use the ruleGuardLogStatement, which covers all cases regardless of the logging framework. -
The Java rule
UnsynchronizedStaticDateFormatterhas been deprecated and will be removed with PMD 7.0.0. The rule is replaced by the more generalUnsynchronizedStaticFormatter. -
The two Java rules
PositionLiteralsFirstInComparisonsandPositionLiteralsFirstInCaseInsensitiveComparisons(rulesetjava-bestpractices) have been deprecated in favor of the new ruleLiteralsFirstInComparisons. -
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 asLocalVariableCouldBeFinal. If the goal is to avoid defining constants in a scope smaller than the class, then the ruleAvoidDuplicateLiteralsshould be used instead. -
The Apex rule
VariableNamingConventions(apex-codestyle) has been deprecated and will be removed with PMD 7.0.0. The rule is replaced by the more general rulesFieldNamingConventions,FormalParameterNamingConventions,LocalVariableNamingConventions, andPropertyNamingConventions. -
The Java rule
LoggerIsNotStaticFinal(java-errorprone) has been deprecated and will be removed with PMD 7.0.0. The rule is replaced byProperLogger. -
The Java rule
DataflowAnomalyAnalysis(java-errorprone) is deprecated in favour ofUnusedAssignment(java-bestpractices), which was introduced in PMD 6.26.0. -
The java rule
DefaultPackagehas been deprecated in favor ofCommentDefaultAccessModifier. -
The Java rule
CloneThrowsCloneNotSupportedExceptionhas been deprecated without replacement. - The following Java rules are deprecated and removed from the quickstart ruleset,
as the new rule
SimplifiableTestAssertionmerges their functionality: -
The Java rule
ReturnEmptyArrayRatherThanNullis deprecated and removed from the quickstart ruleset, as the new ruleReturnEmptyCollectionRatherThanNullsupersedes it. - The following Java rules are deprecated and removed from the quickstart ruleset,
as the new rule
PrimitiveWrapperInstantiationmerges their functionality: - The Java rule
UnnecessaryWrapperObjectCreationis deprecated with no planned replacement before PMD 7. In it’s current state, the rule is not useful as it finds only contrived cases of creating a primitive wrapper and unboxing it explicitly in the same expression. In PMD 7 this and more cases will be covered by a new ruleUnnecessaryBoxing.