These are the detailed release notes for PMD 7.
Table of Contents ð Major Features and Enhancements New official logoMany of you probably have already seen the new logo, but now itâs time to actually ship it. The new logo was long ago decided (see #1663).
We decided itâs time to have a modernized logo and get rid of the gun. This allows to include the logo anywhere without offense.
The official logo is also without a tagline (such as âCode Quality Matters!â) as the tagline created some controversies. Without a tagline, we are not limited in the direction of future development of PMD.
The new logo is available from the Logo Project Page.
Revamped JavaThe Java grammar has been refactored substantially in order to make it easier to maintain and more correct regarding the Java Language Specification. It supports now also the edge-cases where PMD 6 was failing (e.g. annotations were not supported everywhere). Changing the grammar entails a changed AST and therefore changed rules. The PMD built-in rules have all been upgraded and many bugs have been fixed on the way. Unfortunately, if you are using custom rules, you will most probably need to accommodate these changes yourself.
The type resolution framework has been rewritten from scratch and should now cover the entire Java spec correctly. The same is true for the symbol table. PMD 6 on the other hand has always had problems with advanced type inference, e.g. with lambdas and call chains. Since it was built on the core reflection API, it also was prone to linkage errors and classloader leaks for instance. PMD 7 does not need to load classes, and does not have these problems.
The AST exposes much more semantic information now. For instance, you can jump from a method call to the declaration of the method being called, or from a field access to the field declaration. These improvements allow interesting rules to be written that need precise knowledge of the types in the program, for instance to detect UnnecessaryBoxing
or UseDiamondOperator
. These are just a small preview of the new rules we will be adding in the PMD 7 release cycle.
Overall, the changes to the parser, AST, type resolution and symbol table code has made PMD for Java significantly faster. On average, we have seen ~2-3X faster analysis, but as usual, this may change depending on your workload, configuration and ruleset.
Contributors: Clément Fournier (@oowekyala), Andreas Dangel (@adangel), Juan MartÃn Sotuyo Dodero (@jsotuyod)
Note: The full detailed documentation of the changes to the Java AST are available in the Migration Guide for PMD 7
Revamped Command Line InterfacePMD now ships with a unified Command Line Interface for both Linux/Unix and Windows. Instead of having a collection of scripts for the different utilities shipped with PMD, a single script pmd
(pmd.bat
for Windows) can now launch all utilities using subcommands, e.g. pmd check
, pmd designer
. All commands and options are thoroughly documented in the help, with full color support where available. Moreover, efforts were made to provide consistency in the usage of all PMD utilities.
$ Usage: pmd [-hV] [COMMAND]
-h, --help Show this help message and exit.
-V, --version Print version information and exit.
Commands:
check The PMD standard source code analyzer
cpd Copy/Paste Detector - find duplicate code
designer The PMD visual rule designer
cpd-gui GUI for the Copy/Paste Detector
Warning: May not support the full CPD feature set
ast-dump Experimental: dumps the AST of parsing source code
Exit Codes:
0 Successful analysis, no violations found
1 An unexpected error occurred during execution
2 Usage error, please refer to the command help
4 Successful analysis, at least 1 violation found
For instance, where you previously would have run
run.sh pmd -d src -R ruleset.xml
you should now use
pmd check -d src -R ruleset.xml
or even better, omit using -d
/ --dir
and simply pass the sources at the end of the parameter list
pmd check -R ruleset.xml src
Multiple source directories can be passed, such as:
pmd check -R ruleset.xml src/main/java src/test/java
And the exact same applies to CPD:
pmd cpd --minimum-tokens 100 src/main/java
Additionally, the CLI for the check
command has been enhanced with a progress bar, which interactively displays the current progress of the analysis.
This can be disabled with the --no-progress
flag.
Finally, we now provide a completion script for Bash/Zsh to further help daily usage. To use it, edit your ~/.bashrc
/ ~/.zshrc
file and add the following line:
source <(pmd generate-completion)
Contributors: Juan MartÃn Sotuyo Dodero (@jsotuyod)
Full Antlr supportPMD 6 only supported JavaCC based grammars, but with Antlr parsers can be generated as well. Languages backed by an Antlr grammar are now fully supported. This means, itâs now possible not only to use Antlr grammars for CPD, but we can actually build full-fledged PMD rules for them as well. Both the traditional Java visitor rules, and the simpler XPath rules are available to users. This allows to leverage existing grammars.
We expect this to enable both our dev team and external contributors to largely extend PMD usage for more languages.
Two languages (Swift and Kotlin) already use this new possibility.
See the documentation page Adding a new language with ANTLR for instructions on how to use this new feature.
Contributors: Lucas Soncini (@lsoncini), MatÃas Fraga (@matifraga), Tomás De Lucca (@tomidelucca)
Updated PMD DesignerThis PMD release ships a new version of the pmd-designer. The designer artifact has been renamed from âpmd-uiâ to âpmd-designerâ. While the designer still works with Java 8, the recommended Java Runtime is Java 11 (or later) with OpenJFX 17 (or later).
For the detailed changes, see
Thanks to @mohan-chinnappan-n a new CPD report format has been added which features a data table. It uses an XSLT stylesheet to convert CPDâs XML format into HTML.
See the example report.
Contributors: Mohan Chinnappan (@mohan-chinnappan-n)
New: CPD support for Apache Velocity Template Language (VTL)PMD supported Apache Velocity for a very long time, but the CPD integration never got finished. This is now done and CPD supports Apache Velocity Template language for detecting copy and paste. It is shipped in the module pmd-velocity
.
Thanks to a contribution, CPD now supports Coco, a modern programming language designed specifically for building event-driven software. It is shipped in the new module pmd-coco
.
Contributors: Wener (@wener-tiobe)
New: CPD support for JuliaThanks to a contribution, CPD now supports the Julia language. It is shipped in the new module pmd-julia
.
Contributors: Wener (@wener-tiobe)
New: CPD support for TypeScriptThanks to a contribution, CPD now supports the TypeScript language. It is shipped with the rest of the JavaScript support in the module pmd-javascript
.
Contributors: Paul Guyot (@pguyot)
New: Java 21 and 22 SupportThis release of PMD brings support for Java 21 and 22. There are the following new standard language features, that are supported now:
PMD also supports the following preview language features:
In order to analyze a project with PMD that uses these preview language features, youâll need to enable it via the environment variable PMD_JAVA_OPTS
and select the new language version 22-preview
:
export PMD_JAVA_OPTS=--enable-preview
pmd check --use-version java-22-preview ...
Note: Support for Java 19 and Java 20 preview language features have been removed. The versions â19-previewâ and â20-previewâ are no longer available.
New: Kotlin supportPMD now supports Kotlin as an additional language for analyzing source code. It is based on the official kotlin Antlr grammar for Kotlin 1.8. Java-based rules and XPath-based rules are supported.
We are shipping the following rules:
FunctionNameTooShort
finds functions with a too short name.OverrideBothEqualsAndHashcode
finds classes with only either equals
or hashCode
overridden, but not both. This leads to unexpected behavior once instances of such classes are used in collections (Lists, HashMaps, â¦).Contributors: Jeroen Borgers (@jborgers), Peter Paul Bakker (@stokpop)
New: Swift supportGiven the full Antlr support, PMD now fully supports Swift for creating rules. Previously only CPD was supported.
Note: There is only limited support for newer Swift language features in the parser, e.g. Swift 5.9 (Macro Expansions) are supported, but other features are not.
We are pleased to announce we are shipping a number of rules starting with PMD 7.
ForceCast
flags all force casts, making sure you are defensively considering all types. Having the application crash shouldnât be an option.ForceTry
flags all force tries, making sure you are defensively handling exceptions. Having the application crash shouldnât be an option.ProhibitedInterfaceBuilder
flags any usage of interface builder. Interface builder files are prone to merge conflicts, and are impossible to code review, so larger teams usually try to avoid it or reduce its usage.UnavailableFunction
flags any function throwing a fatalError
not marked as @available(*, unavailable)
to ensure no calls are actually performed in the codebase.Contributors: Lucas Soncini (@lsoncini), MatÃas Fraga (@matifraga), Tomás De Lucca (@tomidelucca)
Changed: Apex Support: Replaced Jorje with fully open source front-endWhen PMD added Apex support with version 5.5.0, it utilized the Apex Jorje library to parse Apex source and generate an AST. This library is however a binary-blob provided as part of the Salesforce Extensions for VS Code, and it is closed-source.
This causes problems, if binary blobs are not allowed by e.g. a company-wide policy. In that case, the Jorje library prevented that PMD Apex could be used at all.
Also having access to the source code, enhancements and modifications are easier to do.
Under the hood, we use two open source libraries instead:
Although the parsers is completely switched, there are only little known changes to the AST. These are documented in the Migration Guide for PMD 7: Apex AST. With the new Apex parser, the new language constructs like User Mode Database Operations and the new Null Coalescing Operator ??
can be parsed now. PMD should be able to parse Apex code up to version 60.0 (Spring â24).
See #3766 for details.
Contributors: Aaron Hurst (@aaronhurst-google), Edward Klimoshenko (@eklimo)
Changed: CPP can now ignore identifiers in sequences (CPD)--ignore-sequences
.--ignore-literal-sequences
, only literals were ignored. The new option additionally ignores identifiers as well in sequences.CPD-ON
/CPD-OFF
comment pairs.Support for HTML was introduced in PMD 6.55.0 as an experimental feature. With PMD 7.0.0 this is now considered stable.
Changed: JavaScript supportThe JS specific parser options have been removed. The parser now always retains comments and uses version ES6. The language module registers a couple of different versions. The latest version, which supports ES6 and also some new constructs (see Rhino), is the default. This should be fine for most use cases.
Changed: Language versionsWe revisited the versions that were defined by each language module. Now many more versions are defined for each language. In general, you can expect that PMD can parse all these different versions. There might be situations where this fails and this can be considered a bug. Usually the latest version is selected as the default language version.
The language versions can be used to mark rules to be useful only for a specific language version via the minimumLanguageVersion
and maximumLanguageVersion
attributes. While this feature is currently only used by the Java module, listing all possible versions enables other languages as well to use this feature.
Related issue: [core] Explicitly name all language versions (#4120)
Changed: Rule propertiesIntProperty
and StringProperty
have been removed. Please use PropertyFactory
to create properties.,
) as a delimiter. The previous default was a pipe character (|
). The delimiter is not configurable anymore. If needed, the comma can be escaped with a backslash.min
and max
attributes in property definitions in the XML are now optional and can appear separately or be omitted.The module was named just âvmâ which was not a good name. Its module name, language id and package names have been renamed to âvelocityâ.
If you import rules, you also need to adjust the paths, e.g.
category/vm/...
â¡ï¸ category/velocity/...
There was an inconsistency between the naming of the maven module and the language id. The language id used the abbreviation âvfâ, while the maven module used the longer name âvisualforceâ. This has been solved by renaming the language module to its full name âvisualforceâ. The java packages have been renamed as well.
If you import rules, you also need to adjust the paths, e.g.
category/vf/security.xml
â¡ï¸ category/visualforce/security.xml
Apex
OperationWithHighCostInLoop
finds Schema class methods called in a loop, which is a potential performance issue.UnusedMethod
finds unused methods in your code.Java
UnnecessaryBoxing
reports boxing and unboxing conversions that may be made implicit.UseExplicitTypes
reports usages of var
keyword, which was introduced with Java 10.Kotlin
FunctionNameTooShort
finds functions with a too short name.OverrideBothEqualsAndHashcode
finds classes with only either equals
or hashCode
overridden, but not both. This leads to unexpected behavior once instances of such classes are used in collections (Lists, HashMaps, â¦).Swift
ForceCast
flags all force casts, making sure you are defensively considering all types. Having the application crash shouldnât be an option.ForceTry
flags all force tries, making sure you are defensively handling exceptions. Having the application crash shouldnât be an option.ProhibitedInterfaceBuilder
flags any usage of interface builder. Interface builder files are prone to merge conflicts, and are impossible to code review, so larger teams usually try to avoid it or reduce its usage.UnavailableFunction
flags any function throwing a fatalError
not marked as @available(*, unavailable)
to ensure no calls are actually performed in the codebase.XML
MissingEncoding
finds XML files without explicit encoding.General changes
topscore
and sigma
have been removed. The property minimum
is still there, however the type is not a decimal number anymore but has been changed to an integer. This affects rules in the languages Apex, Java, PLSQL and Velocity Template Language (velocity):
ExcessiveClassLength
, ExcessiveParameterList
, ExcessivePublicCount
, NcssConstructorCount
, NcssMethodCount
, NcssTypeCount
ExcessiveImports
, ExcessiveParameterList
, ExcessivePublicCount
, SwitchDensity
ExcessiveMethodLength
, ExcessiveObjectLength
, ExcessivePackageBodyLength
, ExcessivePackageSpecificationLength
, ExcessiveParameterList
, ExcessiveTypeLength
, NcssMethodCount
, NcssObjectCount
, NPathComplexity
ExcessiveTemplateLength
violationSuppressXPath
which is available for all rules to suppress warnings now uses XPath version 3.1 by default. This version of the XPath language is mostly identical to XPath 2.0. In PMD 6, XPath 1.0 has been used. If you upgrade from PMD 6, you need to verify your violationSuppressXPath
properties.Apex General changes
cc_categories
, cc_remediation_points_multiplier
, cc_block_highlighting
have been removed from all rules. These properties have been deprecated since PMD 6.13.0. See issue #1648 for more details.Apex Codestyle
MethodNamingConventions
: The deprecated rule property skipTestMethodUnderscores
has been removed. It was actually deprecated since PMD 6.15.0, but was not mentioned in the release notes back then. Use the property testPattern
instead to configure valid names for test methods.Java General changes
Violations reported on methods or classes previously reported the line range of the entire method or class. With PMD 7.0.0, the reported location is now just the identifier of the method or class. This affects various rules, e.g. CognitiveComplexity
.
The report location is controlled by the overrides of the method Node#getReportLocation
in different node types.
See issue #4439 and issue #730 for more details.
Java Best Practices
ArrayIsStoredDirectly
: Violations are now reported on the assignment and not anymore on the formal parameter. The reported line numbers will probably move.AvoidReassigningLoopVariables
: This rule might not report anymore all reassignments of the control variable in for-loops when the property forReassign
is set to skip
. See issue #4500 for more details.LooseCoupling
: The rule has a new property to allow some types to be coupled to (allowedTypes
).UnusedLocalVariable
: This rule has some important false-negatives fixed and finds many more cases now. For details see issues #2130, #4516, and #4517.Java Codestyle
MethodNamingConventions
: The property checkNativeMethods
has been removed. The property was deprecated since PMD 6.3.0. Use the property nativePattern
to control whether native methods should be considered or not.ShortVariable
: This rule now also reports short enum constant names.UseDiamondOperator
: The property java7Compatibility
has been removed. The rule now handles Java 7 properly without a property.UnnecessaryFullyQualifiedName
: The rule has two new properties, to selectively disable reporting on static field and method qualifiers. The rule also has been improved to be more precise.UselessParentheses
: The rule has two new properties which control how strict the rule should be applied. With ignoreClarifying
(default: true) parentheses that are strictly speaking not necessary are allowed, if they separate expressions of different precedence. The other property ignoreBalancing
(default: true) is similar, in that it allows parentheses that help reading and understanding the expressions.EmptyControlStatement
: The rule has a new property to allow empty blocks when they contain a comment (allowCommentedBlocks
).Java Design
CyclomaticComplexity
: The property reportLevel
has been removed. The property was deprecated since PMD 6.0.0. The report level can now be configured separated for classes and methods using classReportLevel
and methodReportLevel
instead.ImmutableField
: The property ignoredAnnotations
has been removed. The property was deprecated since PMD 6.52.0.LawOfDemeter
: The rule has a new property trustRadius
. This defines the maximum degree of trusted data. The default of 1 is the most restrictive.NPathComplexity
: The property minimum
has been removed. It was deprecated since PMD 6.0.0. Use the property reportLevel
instead.SingularField
: The properties checkInnerClasses
and disallowNotAssignment
have been removed. The rule is now more precise and will check these cases properly.UseUtilityClass
: The property ignoredAnnotations
has been removed.Java Documentation
CommentContent
: The properties caseSensitive
and disallowedTerms
are removed. The new property forbiddenRegex
can be used now to define the disallowed terms with a single regular expression.CommentRequired
:
@Override
annotation. This is relevant for the property methodWithOverrideCommentRequirement
. See also pull request #3757.headerCommentRequirement
has been removed. Use the property classCommentRequirement
instead.CommentSize
: When determining the line-length of a comment, the leading comment prefix markers (e.g. *
or //
) are ignored and donât add up to the line-length. See also pull request #4369.Java Error Prone
AvoidDuplicateLiterals
: The property exceptionfile
has been removed. The property was deprecated since PMD 6.10.0. Use the property exceptionList
instead.DontImportSun
: sun.misc.Signal
is not special-cased anymore.EmptyCatchBlock
: CloneNotSupportedException
and InterruptedException
are not special-cased anymore. Rename the exception parameter to ignored
to ignore them.ImplicitSwitchFallThrough
: Violations are now reported on the case statements rather than on the switch statements. This is more accurate but might result in more violations now.NonSerializableClass
: The deprecated property prefix
has been removed without replacement. In a serializable class all fields have to be serializable regardless of the name.In PMD 7.0.0, there are no deprecated rules.
Removed RulesThe following previously deprecated rules have been finally removed:
Apex
OperationWithLimitsInLoop
OperationWithLimitsInLoop
OperationWithLimitsInLoop
FieldNamingConventions
, FormalParameterNamingConventions
, LocalVariableNamingConventions
, or PropertyNamingConventions
ApexCSRF
Java
ClassNamingConventions
FormalParameterNamingConventions
ComparisonWithNaN
NonSerializableClass
UnnecessaryBoxing
and PrimitiveWrapperInstantiation
UnnecessaryBoxing
and PrimitiveWrapperInstantiation
UnusedAssignment
CommentDefaultAccessModifier
DoNotTerminateVM
UnnecessaryImport
UnnecessaryImport
EmptyControlStatement
EmptyControlStatement
EmptyControlStatement
EmptyControlStatement
UnnecessarySemicolon
EmptyControlStatement
EmptyControlStatement
EmptyControlStatement
EmptyControlStatement
NcssCount
NcssCount
ControlStatementBraces
ControlStatementBraces
ControlStatementBraces
UnnecessaryImport
UnnecessaryBoxing
and PrimitiveWrapperInstantiation
InvalidLogMessageFormat
ProperLogger
UnnecessaryBoxing
and PrimitiveWrapperInstantiation
FieldNamingConventions
, FormalParameterNamingConventions
, or LocalVariableNamingConventions
ImplicitSwitchFallThrough
CyclomaticComplexity
NcssCount
NcssCount
NcssCount
LiteralsFirstInComparisons
LiteralsFirstInComparisons
ReturnEmptyCollectionRatherThanNull
UnnecessaryBoxing
and PrimitiveWrapperInstantiation
SimplifiableTestAssertion
CyclomaticComplexity
FieldNamingConventions
UnnecessaryBoxing
UnsynchronizedStaticFormatter
UnnecessaryImport
SimplifiableTestAssertion
SimplifiableTestAssertion
SimplifiableTestAssertion
SimplifiableTestAssertion
FieldNamingConventions
, FormalParameterNamingConventions
, or LocalVariableNamingConventions
ControlStatementBraces
The following previously deprecated rulesets have been removed. These were the left-over rulesets from PMD 5. The rules have been moved into categories with PMD 6.
Note: The full detailed documentation of the changes are available in the Migration Guide for PMD 7
For endusersrun.sh pmd ...
â¡ï¸ pmd check ...
, run.sh cpd ...
â¡ï¸ pmd cpd ...
).violationSuppressXPath
now requires XPath 3.1: Custom rulesets need to be reviewed.AbstractRule#buildTargetSelector
using RuleTargetSelector#forTypes
.The asset filenames of PMD on GitHub Releases are now pmd-dist-<version>-bin.zip
, pmd-dist-<version>-src.zip
and pmd-dist-<version>-doc.zip
. Keep that in mind, if you have an automated download script.
The structure inside the ZIP files stay the same, e.g. we still provide inside the binary distribution ZIP file the base directory pmd-bin-<version>
.
pmd-core
has been moved into its own module pmd-ant
, which needs to be added explicitly now as an additional dependency.pmd-core
into its own module pmd-cli
. The old entry point, the main class PMD
is gone.The API of PMD has been growing over the years and needed some cleanup. 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 ADR 3 - API evolution principles and API changes below.
Small Changes and cleanups#1648: [apex,vf] Remove CodeClimate dependency - Robert Sösemann Properties âcc_categoriesâ, âcc_remediation_points_multiplierâ, âcc_block_highlightingâ can no longer be overridden in rulesets. They were deprecated without replacement.
The old GUI applications accessible through run.sh designerold
and run.sh bgastviewer
(and corresponding Batch scripts) have been removed from the PMD distribution. Please use the newer rule designer with pmd designer
. The corresponding classes in packages java.net.sourceforge.pmd.util.viewer
and java.net.sourceforge.pmd.util.designer
have all been removed.
All API related to XPath support has been moved to the package net.sourceforge.pmd.lang.rule.xpath
. This includes API that was previously dispersed over net.sourceforge.pmd.lang
, net.sourceforge.pmd.lang.ast.xpath
, net.sourceforge.pmd.lang.rule.xpath
, net.sourceforge.pmd.lang.rule
, and various language-specific packages (which were made internal).
The implementation of the Ant integration has been moved from the module pmd-core
to a new module pmd-ant
. This involves classes in package net.sourceforge.pmd.ant
. The ant CPDTask class net.sourceforge.pmd.cpd.CPDTask
has been moved into the same package net.sourceforge.pmd.ant
. Youâll need to update your taskdef entries in your build.xml files with the FQCN net.sourceforge.pmd.ant.CPDTask
if you use it anywhere.
Utility classes in net.sourceforge.pmd.util
, that have previously marked as @InternalApi
have been finally moved to an internal sub package and are now longer available. This includes ClasspathClassLoader, FileFinder, FileUtil, and IOUtil.
net.sourceforge.pmd.util
are now considered public API:
AntlrCpdLexer
and JavaccCpdLexer
from internal
package into package net.sourceforge.pmd.cpd.impl
. These two classes are part of the API and are base classes for CPD language implementations. Since 7.0.0-rc2. Note: These two classes have been previously called âAntlrTokenizerâ and âJavaCCTokenizerâ.AntlrBaseRule
is gone in favor of AbstractVisitorRule
. Since 7.0.0-rc2.net.sourceforge.pmd.lang.kotlin.ast.KotlinInnerNode
and net.sourceforge.pmd.lang.swift.ast.SwiftInnerNode
are package-private now. Since 7.0.0-rc2.Support for XPath versions 1.0, 1.0-compatibility, 2.0 was removed. The default (and only) supported XPath version is now XPath 3.1. This version of the XPath language is mostly identical to XPath 2.0.
Notable changes:
This version includes a powerful API to navigate trees, similar in usage to the Java 8 Stream API:
node.descendants(ASTMethodCall.class)
.filter(m -> "toString".equals(m.getMethodName()))
.map(m -> m.getQualifier())
.filter(q -> TypeTestUtil.isA(String.class, q))
.foreach(System.out::println);
A pipeline like shown here traverses the tree lazily, which is more efficient than traversing eagerly to put all descendants in a list. It is also much easier to change than the old imperative way.
To make this API as accessible as possible, the Node
interface has been fitted with new methods producing node streams. Those methods replace previous tree traversal methods like Node#findDescendantsOfType
. In all cases, they should be more efficient and more convenient.
See NodeStream
for more details.
Contributors: Clément Fournier (@oowekyala)
Metrics frameworkThe metrics framework has been made simpler and more general.
The metric interface takes an additional type parameter, representing the result type of the metric. This is usually Integer
or Double
. It avoids widening the result to a double
just to narrow it down.
This makes it so, that Double.NaN
is not an appropriate sentinel value to represent ânot supportedâ anymore. Instead, computeFor
may return null
in that case (or a garbage value). The value null
may have caused problems with the narrowing casts, which through unboxing, might have thrown an NPE. But when we deprecated the language-specific metrics façades to replace them with the generic MetricsUtil
, we took care of making the new methods throw an exception if the metric cannot be computed on the parameter. This forces you to guard calls to MetricsUtil#computeMetric
(and other overloads) with something like if (metric.supports(node))
. If youâre following this pattern, then you wonât observe the undefined behavior.
The MetricKey
interface is not so useful and has been merged into the Metric
interface and removed. So the Metric
interface has the new method displayName
.
The framework is not tied to at most 2 node types per language anymore. Previously those were nodes for classes and for methods/constructors. Instead, many metrics support more node types. For example, NCSS can be computed on any code block.
For that reason, keeping around a hard distinction between âclass metricsâ and âoperation metricsâ is not useful. So in the Java framework for example, we removed the interfaces JavaClassMetric
, JavaOperationMetric
, abstract classes for those, JavaClassMetricKey
, and JavaOperationMetricKey
. Metric constants are now all inside the JavaMetrics
utility class. The same was done in the Apex framework.
We donât really need abstract classes for metrics now. So AbstractMetric
is also removed from pmd-core. There is a factory method on the Metric
interface to create a metric easily.
This makes it so, that LanguageMetricsProvider
does not need type parameters. It can just return a Set<Metric<?, ?>>
to list available metrics.
Signature
s, their implementations, and the interface SignedNode
have been removed. Node streams allow replacing their usages very easily.
net.sourceforge.pmd.testframework.PMDTestRunner
net.sourceforge.pmd.testframework.RuleTestRunner
net.sourceforge.pmd.testframework.TestDescriptor
SimpleAggregatorTst
or PmdRuleTst
work as before without change, but use now JUnit5 under the hood. If you added additional JUnit4 tests to your rule test classes, then youâll need to upgrade them to use JUnit5.The documentation page has been updated: Adding a new language with JavaCC and Adding a new language with ANTLR
Related issue: [core] Language lifecycle (#3782)
Rule propertiesIntProperty
and StringProperty
have been removed. Please use PropertyFactory
to create properties.,
) as a delimiter. The previous default was a pipe character (|
). The delimiter is not configurable anymore. If needed, the comma can be escaped with a backslash.min
and max
attributes in property definitions in the XML are now optional and can appear separately or be omitted.This release introduces a new programmatic API to replace the old class CPD
. The new API uses a similar model to PmdAnalysis
and is called CpdAnalysis
. Programmatic execution of CPD should now be done with a CPDConfiguration
and a CpdAnalysis
, for instance:
CPDConfiguration config = new CPDConfiguration();
config.setMinimumTileSize(100);
config.setOnlyRecognizeLanguage(config.getLanguageRegistry().getLanguageById("java"));
config.setSourceEncoding(StandardCharsets.UTF_8);
config.addInputPath(Path.of("src/main/java")
config.setIgnoreAnnotations(true);
config.setIgnoreLiterals(false);
config.setRendererName("text");
try (CpdAnalysis cpd = CpdAnalysis.create(config)) {
// note: don't use `config` once a CpdAnalysis has been created.
// optional: add more files
cpd.files().addFile(Paths.get("src", "main", "more-java", "ExtraSource.java"));
cpd.performAnalysis();
}
CPD can of course still be called via command line or using the module pmd-cli
. But for tight integration this new programmatic API is recommended.
See PR #4397 for details.
API changes 7.0.0These are the changes between 7.0.0-rc4 and final 7.0.0.
pmd-java
ASTPattern
, ASTRecordPattern
, ASTTypePattern
, ASTUnnamedPattern
getParenthesisDepth()
has been removed.ASTTemplateFragment
: To get the content of the template, use now getContent
or @Content
instead of getImage()
/@Image
.ASTUnnamedPattern
is not experimental anymore. The language feature has been standardized with Java 22.New API
The API around TreeRenderer
has been declared as stable. It was previously experimental. It can be used via the CLI subcommand ast-dump
or programmatically, as described on Creating XML dump of the AST.
General AST Changes to avoid @Image
See General AST Changes to avoid @Image in the migration guide for details.
XPath Rules
version
was already deprecated and has finally been removed. Please donât define the version property anymore in your custom XPath rules. By default, the latest XPath version will be used, which is XPath 3.1.Moved classes/consolidated packages
net.sourceforge.pmd
into subpackage net.sourceforge.pmd.lang.rule
Rule
RulePriority
RuleSet
RuleSetFactory
RuleSetLoader
RuleSetLoadException
RuleSetWriter
net.sourceforge.pmd
into subpackage net.sourceforge.pmd.reporting
XPathRule
has been moved into subpackage net.sourceforge.pmd.lang.rule.xpath
.net.sourceforge.pmd.lang.html.ast.HtmlCpdLexer
moved into package cpd
: HtmlCpdLexer
.net.sourceforge.pmd.lang.test
:
AbstractMetricTestRule
(moved from net.sourceforge.pmd.test.AbstractMetricTestRule
)BaseTextComparisonTest
(moved from net.sourceforge.pmd.test.BaseTextComparisonTest
)CpdTextComparisonTest
(moved from net.sourceforge.pmd.cpd.test.CpdTextComparisonTest
)BaseTreeDumpTest
(moved from net.sourceforge.pmd.lang.ast.test.BaseTreeDumpTest
)net.sourceforge.pmd.lang.ast.test
to net.sourceforge.pmd.lang.test
.ScalaCpdLexer
(moved from net.sourceforge.pmd.lang.scala.cpd.ScalaCpdLexer
)ScalaTokenAdapter
(moved from net.sourceforge.pmd.lang.scala.cpd.ScalaTokenAdapter
)AbstractRuleSetFactoryTest
(moved from net.sourceforge.pmd.lang.rule.AbstractRuleSetFactoryTest
)AbstractAntTestHelper
(moved from net.sourceforge.pmd.ant.AbstractAntTestHelper
)AbstractLanguageVersionTest
(moved from net.sourceforge.pmd.AbstractLanguageVersionTest
)PmdRuleTst
(moved from net.sourceforge.pmd.testframework.PmdRuleTst
)RuleTst
(moved from net.sourceforge.pmd.testframework.RuleTst
)SimpleAggregatorTst
(moved from net.sourceforge.pmd.testframework.SimpleAggregatorTst
)PomLanguageModule
(moved from net.sourceforge.pmd.lang.pom.PomLanguageModule
)WsdlLanguageModule
(moved from net.sourceforge.pmd.lang.wsdl.WsdlLanguageModule
)XslLanguageModule
(moved from net.sourceforge.pmd.lang.xsl.XslLanguageModule
)net.sourceforge.pmd.lang.vf
has been renamed to net.sourceforge.pmd.lang.visualforce
.visualforce
(it was previously just âvfâ)category/vf/security.xml
â¡ï¸ category/visualforce/security.xml
net.sourceforge.pmd.lang.vm
has been renamed to net.sourceforge.pmd.lang.velocity
.velocity
(it was previously just âvmâ)category/vm/...
â¡ï¸ category/velocity/...
Vm
, e.g. VmLanguageModule
. This has been changed to be Vtl
:
Internalized classes and interfaces and methods
The following classes/methods have been marked as @InternalApi before and are now moved into a internal
package or made (package) private and are not accessible anymore.
net.sourceforge.pmd.cache.AbstractAnalysisCache
(moved to internal, now package private)net.sourceforge.pmd.cache.AnalysisCache
(moved to internal)net.sourceforge.pmd.cache.AnalysisCacheListener
(moved to internal)net.sourceforge.pmd.cache.AnalysisResult
(moved to internal)net.sourceforge.pmd.cache.CachedRuleMapper
(moved to internal, now package private)net.sourceforge.pmd.cache.CachedRuleViolation
(moved to internal, now package private)net.sourceforge.pmd.cache.ChecksumAware
(moved to internal)net.sourceforge.pmd.cache.FileAnalysisCache
(moved to internal)net.sourceforge.pmd.cache.NoopAnalysisCache
(moved to internal)net.sourceforge.pmd.util.ResourceLoader
(moved to internal)net.sourceforge.pmd.cpd.Tokens
net.sourceforge.pmd.lang.LanguageProcessor.AnalysisTask
withFiles(java.util.List)
is now package private. Note: it was not previously marked with @InternalApi.net.sourceforge.pmd.lang.rule.RuleTargetSelector
isRuleChain()
has been removed.net.sourceforge.pmd.renderers.AbstractAccumulatingRenderer
renderFileReport
- this method is now final and canât be overridden anymore.net.sourceforge.pmd.reporting.Report
addRuleViolation
, addConfigError
, addError
are now private.net.sourceforge.pmd.reporting.RuleContext
getRule()
is now package private.create(FileAnalysisListener listener, Rule rule)
has been removed.net.sourceforge.pmd.rules.RuleFactory
: moved into subpackage lang.rule
and made package private. It has now been hidden completely from public API.lang.rule.internal
.
net.sourceforge.pmd.RuleSetReference
net.sourceforge.pmd.RuleSetReferenceId
net.sourceforge.pmd.RuleSets
net.sourceforge.pmd.lang.rule.ParametricRuleViolation
is now package private and moved to net.sourceforge.pmd.reporting.ParametricRuleViolation
. The only public API is RuleViolation
.net.sourceforge.pmd.lang.rule.RuleSet
applies(Rule,LanguageVersion)
is now package private.applies(TextFile)
has been removed.applies(FileId)
is now package private.net.sourceforge.pmd.lang.rule.RuleSetLoader
loadRuleSetsWithoutException(java.util.List)
is now package private.net.sourceforge.pmd.lang.rule.RuleSetLoadException
net.sourceforge.pmd.lang.ast.LexException
- the constructor LexException(boolean, String, int, int, String, char)
is now package private. It is only used by JavaCC-generated token managers.net.sourceforge.pmd.PMDConfiguration
setAnalysisCache(AnalysisCache)
is now package private. Use setAnalysisCacheLocation
instead.getAnalysisCache()
is now package private.net.sourceforge.pmd.lang.document.FileCollector
newCollector(LanguageVersionDiscoverer, PmdReporter)
is now package private.newCollector(PmdReporter)
is now package private.files
instead.net.sourceforge.pmd.lang.rule.xpath.Attribute
replacementIfDeprecated()
is now package private.net.sourceforge.pmd.properties.PropertyTypeId
- moved in subpackage internal
.net.sourceforge.pmd.properties.PropertyDescriptor
- method getTypeId()
is now package private.pmd-doc
is now considered internal API even though it was not declared so before. Itâs used to generate the rule documentation for the built-in rules.net.sourceforge.pmd.doc.internal
.net.sourceforge.pmd.ant.Formatter
getRenderer()
has been removed.start(String)
is private now.end(Report)
has been removed.isNoOutputSupplied()
is now package private.newListener(Project)
is now package private.net.sourceforge.pmd.ant.PMDTask
getRelativizeRoots()
has been removed.net.sourceforge.pmd.ant.ReportException
is now package private. Note: It was not marked with @InternalApi before.net.sourceforge.pmd.lang.apex.ast.ApexNode
getNode()
has been removed. It was only deprecated before and not marked with @InternalApi. However, it gave access to the wrapped Jorje node and was thus internal API.net.sourceforge.pmd.lang.apex.ast.AbstractApexNode
getNode()
is now package private.net.sourceforge.pmd.lang.apex.multifile.ApexMultifileAnalysis
net.sourceforge.pmd.lang.apex.rule.design.AbstractNcssCountRule
(now package private)net.sourceforge.pmd.lang.apex.rule.AbstractApexUnitTestRule
(moved to package net.sourceforge.pmd.apex.rule.bestpractices
, now package private)net.sourceforge.pmd.lang.java.rule.AbstractIgnoredAnnotationRule
(moved to internal)net.sourceforge.pmd.lang.java.types.ast.LazyTypeResolver
(moved to internal)net.sourceforge.pmd.lang.java.types.JMethodSig
internalApi()
has been removed.net.sourceforge.pmd.lang.java.types.TypeOps
isSameTypeInInference(JTypeMirror,JTypeMirror)
is now package private.net.sourceforge.pmd.lang.jsp.ast.JspParser
getTokenBehavior()
has been removed.net.sourceforge.pmd.lang.modelica.ast.InternalApiBridge
renamed from InternalModelicaNodeApi
.net.sourceforge.pmd.lang.modelica.resolver.InternalApiBridge
renamed from InternalModelicaResolverApi
.net.sourceforge.pmd.lang.modelica.resolver.ModelicaSymbolFacade
has been removed.net.sourceforge.pmd.lang.modelica.resolver.ResolutionContext
(moved to internal)net.sourceforge.pmd.lang.modelica.resolver.ResolutionState
(moved to internal). Note: it was not previously marked with @InternalApi.net.sourceforge.pmd.lang.modelica.resolver.Watchdog
(moved to internal). Note: it was not previously marked with @InternalApi.net.sourceforge.pmd.lang.plsql.rule.design.AbstractNcssCountRule
is now package private.net.sourceforge.pmd.lang.scala.ScalaLanguageModule
dialectOf(LanguageVersion)
has been removed.Removed classes and members (previously deprecated)
The annotation @DeprecatedUntil700
has been removed.
CpdLanguageProperties
. The field DEFAULT_SKIP_BLOCKS_PATTERN
has been removed.BaseAntlrNode
- method joinTokenText()
has been removed.Node
- many methods have been removed:
getNthParent(int)
- Use ancestors
instead, e.g. node.ancestors().get(n-1)
getFirstParentOfType(Class)
- Use ancestors
instead, e.g. node.ancestors(parentType).first()
getParentsOfType(Class)
- Use ancestors
instead, e.g. node.ancestors(parentType).toList()
findChildrenOfType(Class)
- Use children
instead, e.g. node.children(childType).toList()
findDescendantsOfType(Class)
- Use descendants
instead, e.g. node.descendants(targetType).toList()
findDescendantsOfType(Class,boolean)
- Use descendants
instead, e.g. node.descendants(targetType).crossFindBoundaries(b).toList()
getFirstChildOfType(Class)
- Use firstChild
insteadgetFirstDescendantOfType(Class)
- Use descendants
instead, e.g. node.descendants(targetType).first()
hasDescendantOfType(Class)
- Use descendants
instead, e.g. node.descendants(targetType).nonEmpty()
findChildNodesWithXPath(String)
- Use the NodeStream
API instead.GenericNode
- method getNthParent(int)
has been removed. Use ancestors
instead, e.g. node.ancestors().get(n-1)
FileCollector
- method addZipFile(java.nio.file.Path)
has been removed. Use addZipFileWithContent
insteadTextDocument
- method readOnlyString(CharSequence,String,LanguageVersion)
has been removed. Use readOnlyString
instead.TextFile
- method dataSourceCompat(DataSource,PMDConfiguration)
has been removed. Use TextFile
directly, e.g. forPath
XPathVersion
XPATH_1_0
XPATH_1_0_COMPATIBILITY
XPATH_2_0
XPATH_3_1
.net.sourceforge.pmd.lang.rule.AbstractDelegateRule
removed. It has been merged with RuleReference
.AbstractRule
- the following methods have been removed:
deepCopyValuesTo(AbstractRule)
- use deepCopy
instead.addRuleChainVisit(Class)
- override buildTargetSelector
in order to register nodes for rule chain visits.addViolation(...)
- use addViolation
instead, e.g. via asCtx(data).addViolation(...)
. Note: These methods were only marked as deprecated in javadoc.addViolationWithMessage(...)
- use addViolationWithMessage
instead, e.g. via asCtx(data).addViolationWithMessage(...)
. Note: These methods were only marked as deprecated in javadoc.RuleReference
- the following methods have been removed:
setRuleSetReference(RuleSetReference)
- without replacement. Just construct new RuleReference
instead.hasOverriddenProperty(PropertyDescriptor)
- use isPropertyOverridden
instead.XPathRule
XPATH_DESCRIPTOR
has been made private and is not accessible anymore.Language
- method getTerseName()
removed. Use getId
instead.LanguageModuleBase
- method getTerseName()
removed. Use getId
instead.LanguageRegistry
- the following methods have been removed:
getLanguage(String)
- use getLanguageByFullName
via PMD
or CPD
instead.findLanguageByTerseName(String)
- use getLanguageById
via PMD
or CPD
instead.findByExtension(String)
- removed without replacement.LanguageVersionDiscoverer
- method getLanguagesForFile(java.io.File)
removed. Use getLanguagesForFile
instead.AbstractPropertySource
propertyDescriptors
has been made private and is not accessible anymore. Use getPropertyDescriptors
instead.propertyValuesByDescriptor
has been made private and is not accessible anymore. Use getPropertiesByPropertyDescriptor
or getOverriddenPropertiesByPropertyDescriptor
instead.copyPropertyDescriptors()
has been removed. Use getPropertyDescriptors
instead.copyPropertyValues()
has been removed. Use getPropertiesByPropertyDescriptor
or getOverriddenPropertiesByPropertyDescriptor
instead.Reportable
- the following methods have been removed. Use getReportLocation
instead
getBeginLine()
getBeginColumn()
getEndLine()
getEndColumn()
net.sourceforge.pmd.util.datasource.DataSource
- use TextFile
instead.net.sourceforge.pmd.util.datasource.FileDataSource
net.sourceforge.pmd.util.datasource.ReaderDataSource
net.sourceforge.pmd.util.datasource.ZipDataSource
CollectionUtil
invertedMapFrom(...)
has been removed.mapFrom(...)
has been removed.AbstractConfiguration
- the following methods have been removed:
setIgnoreFilePath(String)
- use setIgnoreFilePath
instead.setInputFilePath(String)
- use setInputFilePath
instead.setInputPaths(String)
- use setInputPathList
or addInputPath
instead.setInputUri(String)
- use setInputUri
instead.PMDConfiguration
- the following methods have been removed
prependClasspath(String)
- use prependAuxClasspath
instead.getRuleSets()
- use getRuleSetPaths
instead.setRuleSets(String)
- use setRuleSets
or addRuleSet
instead.setReportFile(String)
- use setReportFile
instead.getReportFile()
- use getReportFilePath
instead.Report
- method merge(Report)
has been removed. Use union
instead.RuleSetLoader
- method toFactory()
has been made package private and is not accessible anymore.RuleViolation
- the following methods have been removed:
getPackageName()
- use getAdditionalInfo
with PACKAGE_NAME
instead, e.g. getAdditionalInfo().get(PACKAGE_NAME)
.getClassName()
- use getAdditionalInfo
with CLASS_NAME
instead, e.g. getAdditionalInfo().get(CLASS_NAME)
.getMethodName()
- use getAdditionalInfo
with METHOD_NAME
instead, e.g. getAdditionalInfo().get(METHOD_NAME)
.getVariableName()
- use getAdditionalInfo
with VARIABLE_NAME
instead, e.g. getAdditionalInfo().get(VARIABLE_NAME)
.ApexNode
and ASTApexFile
#getApexVersion()
: In PMD 6, this method has been deprecated but was defined in the class ApexRootNode
. The version returned is always âVersion.CURRENTâ, as the apex compiler integration doesnât use additional information which Apex version actually is used. Therefore, this method canât be used to determine the Apex version of the project that is being analyzed.
If the current version is needed, then Node.getTextDocument().getLanguageVersion()
can be used. This is the version that has been selected via CLI --use-version
parameter.
ApexNode
jjtAccept()
has been removed. Use acceptVisitor
instead.getNode()
has been removed. The underlying node is only available in AST nodes, but not in rule implementations.AbstractApexNode
- method getNode()
is now package private. AST nodes still have access to the underlying Jorje node via the protected property node
.net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor
Use ApexVisitor
or ApexVisitorBase
instead.net.sourceforge.pmd.lang.apex.ast.ApexParserVisitorAdapter
ASTAssignmentExpression
- method getOperator()
removed. Use getOp
instead.ASTBinaryExpression
- method getOperator()
removed. Use getOp
instead.ASTBooleanExpression
- method getOperator()
removed. Use getOp
instead.ASTPostfixExpression
- method getOperator()
removed. Use getOp
instead.ASTPrefixExpression
- method getOperator()
removed. Use getOp
instead.net.sourceforge.pmd.lang.apex.rule.security.Helper
removed. This was actually internal API.AbstractPackageNameModuleDirective
- method getImage()
has been removed. Use getPackageName
instead.AbstractTypeDeclaration
- method getImage()
has been removed. Use getSimpleName()
instead.ASTAnnotation
- method getAnnotationName()
has been removed.ASTClassType
ASTClassType(java.lang.String)
has been removed.getImage()
has been removed.isReferenceToClassSameCompilationUnit()
has been removed.ASTFieldDeclaration
- method getVariableName()
has been removed.ASTLiteral
- the following methods have been removed:
isStringLiteral()
- use node instanceof ASTStringLiteral
instead.isCharLiteral()
- use node instanceof ASTCharLiteral
instead.isNullLiteral()
- use node instanceof ASTNullLiteral
instead.isBooleanLiteral()
- use node instanceof ASTBooleanLiteral
instead.isNumericLiteral()
- use node instanceof ASTNumericLiteral
instead.isIntLiteral()
- use isIntLiteral
instead.isLongLiteral()
- use isLongLiteral
instead.isFloatLiteral()
- use isFloatLiteral
instead.isDoubleLiteral()
- use isDoubleLiteral
instead.ASTMethodDeclaration
- methods getImage()
and getMethodName()
have been removed. Use getName
instead.ASTMethodReference
- method getImage()
has been removed.ASTModuleName
- method getImage()
has been removed.ASTPrimitiveType
- method getImage()
has been removed.ASTType
getTypeImage()
has been removed.getArrayDepth()
has been removed. Itâs only available for arrays: getArrayDepth
.isPrimitiveType()
- use node instanceof ASTPrimitiveType
instead.isArrayType()
- use node instanceof ASTArrayType
instead.isClassOrInterfaceType()
- use node instanceof ASTClassType
instead.ASTTypeDeclaration
- method getImage()
has been removed.ASTUnaryExpression
- method isPrefix()
has been removed. Use getOperator
.isPrefix()
instead.ASTVariableId
- methods getImage()
and getVariableName()
have been removed. Use getName
instead.JavaComment
- method getImage()
has been removed. Use getText
instead.JavaNode
- method jjtAccept()
has been removed. Use acceptVisitor
instead.net.sourceforge.pmd.lang.java.ast.JavaParserVisitor
Use JavaVisitor
or JavaVisitorBase
instead.net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter
ModifierOwner
isFinal()
- This is still available in various subtypes, where it makes sense, e.g. isFinal
.isAbstract()
- This is still available in subtypes, e.g. isAbstract
.isStrictfp()
- Use hasModifiers
instead, e.g. hasModifiers(STRICTFP)
.isSynchronized()
- Use hasModifiers
instead, e.g. hasModifiers(SYNCHRONIZED)
.isNative()
- Use hasModifiers
instead, e.g. hasModifiers(NATIVE)
.isStatic()
- This is still available in subtypes, e.g. isStatic
.isVolatile()
- Use hasModifiers
instead, e.g. hasModifiers(VOLATILE)
.isTransient()
- Use hasModifiers
instead, e.g. hasModifiers(TRANSIENT)
.isPrivate()
- Use getVisibility
instead, e.g. getVisibility() == Visibility.V_PRIVATE
.isPublic()
- Use getVisibility
instead, e.g. getVisibility() == Visibility.V_PUBLIC
.isProtected()
- Use getVisibility
instead, e.g. getVisibility() == Visibility.V_PROTECTED
.isPackagePrivate()
- Use getVisibility
instead, e.g. getVisibility() == Visibility.V_PACKAGE
.isSyntacticallyAbstract()
- Use hasExplicitModifiers
instead, e.g. hasExplicitModifiers(ABSTRACT)
.isSyntacticallyPublic()
- Use hasExplicitModifiers
instead, e.g. hasExplicitModifiers(PUBLIC)
.isSyntacticallyStatic()
- Use hasExplicitModifiers
instead, e.g. hasExplicitModifiers(STATIC)
.isSyntacticallyFinal()
- Use hasExplicitModifiers
instead, e.g. hasExplicitModifiers(FINAL)
.TypeNode
- method getType()
has been removed. Use getTypeMirror
instead.AbstractEcmascriptNode
- method getNode()
has been removed. AST nodes still have access to the underlying Rhino node via the protected property node
.ASTFunctionNode
- method getBody(int)
removed. Use getBody
instead.ASTTryStatement
isCatch()
has been removed. Use hasCatch
instead.isFinally()
has been removed. Use hasFinally
instead.EcmascriptNode
jjtAccept()
has been removed. Use acceptVisitor
instead.getNode()
has been removed. The underlying node is only available in AST nodes, but not in rule implementations.net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptParserVisitor
Use EcmascriptVisitor
or EcmascriptVisitorBase
instead.net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptParserVisitorAdapter
net.sourceforge.pmd.lang.jsp.ast.JspParserVisitor
Use JspVisitor
or JspVisitorBase
instead.net.sourceforge.pmd.lang.jsp.ast.JspParserVisitorAdapter
JspNode
- method jjtAccept()
has been removed. Use acceptVisitor
instead.net.sourceforge.pmd.lang.modelica.ast.ModelicaParserVisitor
Use ModelicaVisitor
or ModelicaVisitorBase
instead.net.sourceforge.pmd.lang.modelica.ast.ModelicaParserVisitorAdapter
ModelicaNode
- method jjtAccept()
has been removed. Use acceptVisitor
instead.net.sourceforge.pmd.lang.modelica.rule.AmbiguousResolutionRule
Use AmbiguousResolutionRule
instead.net.sourceforge.pmd.lang.modelica.rule.ConnectUsingNonConnector
Use ConnectUsingNonConnectorRule
net.sourceforge.pmd.lang.plsql.ast.PLSQLParserVisitor
Use PlsqlVisitor
or PlsqlVisitorBase
instead.net.sourceforge.pmd.lang.plsql.ast.PLSQLParserVisitorAdapter
PLSQLNode
- method jjtAccept()
has been removed. Use acceptVisitor
instead.pmd-scala
has been removed. Use pmd-scala_2.13
or pmd-scala_2.12
instead.ScalaNode
accept()
has been removed. Use acceptVisitor
instead.getNode()
has been removed. The underlying node is only available in AST nodes, but not in rule implementations.AbstractScalaNode
- method getNode()
has been removed. AST nodes still have access to the underlying Scala node via the protected property node
.VfNode
- method jjtAccept()
has been removed. Use acceptVisitor
instead.net.sourceforge.pmd.lang.vf.ast.VfParserVisitor
Use VfVisitor
or VfVisitorBase
instead.net.sourceforge.pmd.lang.vf.ast.VfParserVisitorAdapter
DataType
- method fromBasicType(BasicType)
has been removed. Use fromTypeName
instead.VtlNode
- method jjtAccept()
has been removed. Use acceptVisitor
instead.net.sourceforge.pmd.lang.vm.ast.VmParserVisitor
Use VtlVisitor
or VtlVisitorBase
instead.net.sourceforge.pmd.lang.vm.ast.VmParserVisitorAdapter
Removed classes, interfaces and methods (not previously deprecated)
isSynthetic()
in ASTMethod
has been removed. With the switch from Jorje to Summit AST as underlying parser, no synthetic methods are generated by the parser anymore. This also means, that there is no XPath attribute @Synthetic
anymore.STATIC_INITIALIZER_METHOD_NAME
in FieldDeclarationsShouldBeAtStartRule
has been removed. It was used to filter out synthetic methods, but these are not generated anymore with the new parser.getContext()
in ASTReferenceExpression
has been removed. It was not used and always returned null
.getNamespace()
in all AST nodes (defined in ApexNode
) has been removed, as it was never fully implemented. It always returned an empty string.getNameSpace()
in ApexQualifiedName
has been removed.net.sourceforge.pmd.lang.apex.ast.ASTBridgeMethodCreator
has been removed. This was a node that has been generated by the old Jorje parser only.net.sourceforge.pmd.util.Predicate
has been removed. It was marked as Experimental before. Use java.util.function.Predicate
instead.FinalizableNode
(introduced in 7.0.0-rc1) has been removed. Its method isFinal()
has been moved down to the nodes where needed, e.g. ASTLocalVariableDeclaration#isFinal
.isPackagePrivate()
in ASTClassDeclaration
(formerly ASTClassOrInterfaceDeclaration) has been removed. Use hasVisibility
instead, which can correctly differentiate between local and package private classes.Renamed classes, interfaces, methods
MessageReporter
has been renamed to PmdReporter
TokenMgrError
has been renamed to LexException
Tokenizer
has been renamed to CpdLexer
. Along with this rename, all the implementations have been renamed as well (Tokenizer
-> CpdLexer
), e.g. âCppCpdLexerâ, âJavaCpdLexerâ. This affects all language modules.AnyTokenizer
has been renamed to AnyCpdLexer
.AccessNode
has been renamed to ModifierOwner
. This is only relevant for Java rules, which use that type directly e.g. through downcasting. Or when using the XPath function pmd-java:nodeIs()
.ASTClassOrInterfaceType
has been renamed to ASTClassType
. XPath rules need to be adjusted.ASTClassOrInterfaceDeclaration
has been renamed to ASTClassDeclaration
. XPath rules need to be adjusted.ASTAnyTypeDeclaration
has been renamed to ASTTypeDeclaration
. This is only relevant for Java rules, which use that type directly, e.g. through downcasting. Or when using the XPath function pmd-java:nodeIs()
.ASTMethodOrConstructorDeclaration
has been renamed to ASTExecutableDeclaration
. This is only relevant for Java rules, which use that type directly, e.g. through downcasting. Or when using the XPath function pmd-java:nodeIs()
.ASTVariableDeclaratorId
has been renamed to ASTVariableId
. XPath rules need to be adjusted.ASTClassOrInterfaceBody
has been renamed to ASTClassBody
. XPath rules need to be adjusted.ScalaParserVisitor
has been renamed to ScalaVisitor
in order to align the naming scheme for the different language modules.ScalaParserVisitorAdapter
has been renamed to ScalaVisitorBase
in order to align the naming scheme for the different language modules.New API
These were annotated with @Experimental
, but can now be considered stable.
CPDReport#filterMatches
AntlrToken#getKind
AbstractJjtreeNode
TokenDocument
AstInfo#getSuppressionComments
AstInfo#withSuppressMap
GenericToken#getKind
FileCollector#addZipFileWithContent
net.sourceforge.pmd.lang.document
LanguageVersionHandler#getLanguageMetricsProvider
LanguageVersionHandler#getDesignerBindings
PlainTextLanguage
PropertyConstraint#getXmlConstraint
PropertyConstraint#toOptionalConstraint
PropertyConstraint#fromPredicate
PropertyConstraint#fromPredicate
AbstractRenderer#setReportFile
Renderer#setReportFile
DesignerBindings
DesignerBindings.TreeIconId
RelatedNodesSelector
Report#filterViolations
Report#union
Removed functionality
--no-ruleset-compatibility
has been removed. It was only used to allow loading some rulesets originally written for PMD 5 also in PMD 6 without fixing the rulesets.RuleSetFactoryCompatibility
has been removed without replacement. The different ways to enable/disable this filter in PMDConfiguration
(Property âRuleSetFactoryCompatibilityEnabledâ) and PMDTask
(Property ânoRuleSetCompatibilityâ) have been removed as well.textcolor
renderer (TextColorRenderer
) now renders always in color. The property color
has been removed. The possibility to override this with the system property pmd.color
has been removed as well. If you donât want colors, use text
renderer (TextRenderer
).pmd-java
Rule properties
IntProperty
and StringProperty
have been removed. Please use PropertyFactory
to create properties.,
) as a delimiter. The previous default was a pipe character (|
). The delimiter is not configurable anymore. If needed, the comma can be escaped with a backslash.min
and max
attributes in property definitions in the XML are now optional and can appear separately or be omitted.New Programmatic API for CPD
See Detailed Release Notes for PMD 7 and PR #4397 for details.
Removed classes and methods
The following previously deprecated classes have been removed:
net.sourceforge.pmd.cpd.AbstractTokenizer
â¡ï¸ use AnyCpdLexer
instead (previously known as AnyTokenizer)net.sourceforge.pmd.cpd.CPD
â¡ï¸ use PmdCli
from pmd-cli
module for CLI support or use CpdAnalysis
for programmatic APInet.sourceforge.pmd.cpd.GridBagHelper
(now package private)net.sourceforge.pmd.cpd.TokenEntry.State
net.sourceforge.pmd.lang.document.CpdCompat
net.sourceforge.pmd.properties.BooleanMultiProperty
net.sourceforge.pmd.properties.BooleanProperty
net.sourceforge.pmd.properties.CharacterMultiProperty
net.sourceforge.pmd.properties.CharacterProperty
net.sourceforge.pmd.properties.DoubleMultiProperty
net.sourceforge.pmd.properties.DoubleProperty
net.sourceforge.pmd.properties.EnumeratedMultiProperty
net.sourceforge.pmd.properties.EnumeratedProperty
net.sourceforge.pmd.properties.EnumeratedPropertyDescriptor
net.sourceforge.pmd.properties.FileProperty
(note: without replacement)net.sourceforge.pmd.properties.FloatMultiProperty
net.sourceforge.pmd.properties.FloatProperty
net.sourceforge.pmd.properties.IntegerMultiProperty
net.sourceforge.pmd.properties.IntegerProperty
net.sourceforge.pmd.properties.LongMultiProperty
net.sourceforge.pmd.properties.LongProperty
net.sourceforge.pmd.properties.MultiValuePropertyDescriptor
net.sourceforge.pmd.properties.NumericPropertyDescriptor
net.sourceforge.pmd.properties.PropertyDescriptorField
net.sourceforge.pmd.properties.RegexProperty
net.sourceforge.pmd.properties.SingleValuePropertyDescriptor
net.sourceforge.pmd.properties.StringMultiProperty
net.sourceforge.pmd.properties.StringProperty
net.sourceforge.pmd.properties.ValueParser
net.sourceforge.pmd.properties.ValueParserConstants
net.sourceforge.pmd.properties.builders.MultiNumericPropertyBuilder
net.sourceforge.pmd.properties.builders.MultiPackagedPropertyBuilder
net.sourceforge.pmd.properties.builders.MultiValuePropertyBuilder
net.sourceforge.pmd.properties.builders.PropertyDescriptorBuilder
net.sourceforge.pmd.properties.builders.PropertyDescriptorBuilderConversionWrapper
net.sourceforge.pmd.properties.builders.PropertyDescriptorExternalBuilder
net.sourceforge.pmd.properties.builders.SingleNumericPropertyBuilder
net.sourceforge.pmd.properties.builders.SinglePackagedPropertyBuilder
net.sourceforge.pmd.properties.builders.SingleValuePropertyBuilder
net.sourceforge.pmd.properties.modules.EnumeratedPropertyModule
net.sourceforge.pmd.properties.modules.NumericPropertyModule
The following previously deprecated methods have been removed:
net.sourceforge.pmd.properties.PropertyBuilder.GenericCollectionPropertyBuilder#delim(char)
net.sourceforge.pmd.properties.PropertySource#setProperty(...)
net.sourceforge.pmd.properties.internal.PropertyTypeId#factoryFor(...)
net.sourceforge.pmd.properties.internal.PropertyTypeId#typeIdFor(...)
net.sourceforge.pmd.properties.PropertyDescriptor
: removed methods errorFor, type, isMultiValue, uiOrder, compareTo, isDefinedExternally, valueFrom, asDelimitedStringThe following methods have been removed:
CPDConfiguration
#sourceCodeFor(File)
, #postConstruct()
, #tokenizer()
, #filenameFilter()
removedMark
#getSourceSlice()
, #setLineCount(int)
, #getLineCount()
, #setSourceCode(SourceCode)
removed#getBeginColumn()
, #getBeginLine()
, #getEndLine()
, #getEndColumn()
removed â¡ï¸ use getLocation
insteadMatch
#LABEL_COMPARATOR
removed#setMarkSet(...)
, #setLabel(...)
, #getLabel()
, #addTokenEntry(...)
removed#getSourceCodeSlice()
removed â¡ï¸ use CPDReport#getSourceCodeSlice
insteadTokenEntry
#getEOF()
, #clearImages()
, #getIdentifier()
, #getIndex()
, #setHashCode(int)
removed#EOF
removed â¡ï¸ use isEof
insteadParser.ParserTask
#getFileDisplayName()
removed â¡ï¸ use getFileId
instead (getFileId().getAbsolutePath()
)The following classes have been removed:
net.sourceforge.pmd.cpd.AbstractLanguage
net.sourceforge.pmd.cpd.AnyLanguage
net.sourceforge.pmd.cpd.Language
net.sourceforge.pmd.cpd.LanguageFactory
net.sourceforge.pmd.cpd.MatchAlgorithm
(now package private)net.sourceforge.pmd.cpd.MatchCollector
(now package private)net.sourceforge.pmd.cpd.SourceCode
(and all inner classes like FileCodeLoader
, â¦)net.sourceforge.pmd.cpd.token.TokenFilter
Moved packages
NumericConstraints
(old package: net.sourceforge.pmd.properties.constraints.NumericConstraints
)PropertyConstraint
(old package: net.sourceforge.pmd.properties.constraints.PropertyConstraint
)
ReportException
(old package: net.sourceforge.pmd.cpd
, moved to module pmd-ant
)
CPDReportRenderer
(old package: net.sourceforge.pmd.cpd.renderer
)AntlrTokenFilter
(old package: net.sourceforge.pmd.cpd.token
)BaseTokenFilter
(old package: net.sourceforge.pmd.cpd.token.internal
)JavaCCTokenFilter
(old package: net.sourceforge.pmd.cpd.token
)Changed types and other changes
PropertyDescriptor
is now a class (was an interface) and it is not comparable anymore.AbstractConfiguration#setSourceEncoding
PMDConfiguration
and CPDConfiguration
AbstractConfiguration
CPDListener#addedFile
File
parameter anymoreCPDReport#getNumberOfTokensPerFile
returns a Map
of FileId,Integer
instead of String
CPDReport#filterMatches
now takes a java.util.function.Predicate
as parameterCpdLexer
PropertyDescriptor
instead of String
, to be used as language propertiestokenize
changed parameters. Now takes a TextDocument
and a TokenFactory
(instead of SourceCode
and Tokens
).Language
#createProcessor(LanguagePropertyBundle)
moved to PmdCapableLanguage
StringUtil#linesWithTrimIndent
now takes a Chars
instead of a String
.net.sourceforge.pmd.lang.<langId>.cpd
CpdCapableLanguage
#getInstance()
ID
, TERSE_NAME
or NAME
. Use getInstance().getName()
etc. insteadInternal APIs
net.sourceforge.pmd.properties.internal.PropertyTypeId
Deprecated API
Language#getTerseName
â¡ï¸ use getId
instead
The method ASTPattern#getParenthesisDepth
has been deprecated and will be removed. It was introduced for supporting parenthesized patterns, but that was removed with Java 21. It is only used when parsing code as java-19-preview.
Experimental APIs
ASTRecordPattern
ASTPatternList
(Note: it was renamed from ASTComponentPatternList
)ASTGuard
(Note: it was renamed from ASTSwitchGuard
)PMD Distribution
The asset filenames of PMD on GitHub Releases are now pmd-dist-<version>-bin.zip
, pmd-dist-<version>-src.zip
and pmd-dist-<version>-doc.zip
. Keep that in mind, if you have an automated download script.
The structure inside the ZIP files stay the same, e.g. we still provide inside the binary distribution ZIP file the base directory pmd-bin-<version>
.
CLI
--stress
(or -stress
) has been removed without replacement.--minimum-priority
was changed with 7.0.0-rc1 to only take the following values: High, Medium High, Medium, Medium Low, Low. With 7.0.0-rc2 compatibility has been restored, so that the equivalent integer values (1 to 5) are supported as well.pmd-core
Replaced RuleViolation::getFilename
with new RuleViolation#getFileId
, that returns a FileId
. This is an identifier for a TextFile
and could represent a path name. This allows to have a separate display name, e.g. renderers use FileNameRenderer
to either display the full path name or a relative path name (see Renderer#setFileNameRenderer
and ConfigurableFileNameRenderer
). Many places where we used a simple String for a path-like name before have been adapted to use the new FileId
.
See PR #4425 for details.
Removed classes and methods
The following previously deprecated classes have been removed:
net.sourceforge.pmd.PMD
net.sourceforge.pmd.cli.PMDCommandLineInterface
net.sourceforge.pmd.cli.PMDParameters
net.sourceforge.pmd.cli.PmdParametersParseResult
CLI
--minimum-priority
was changed with 7.0.0-rc1 to only take the following values: High, Medium High, Medium, Medium Low, Low. With 7.0.0-rc2 compatibility has been restored, so that the equivalent integer values (1 to 5) are supported as well.CLI
--stress
(or -stress
) has been removed without replacement.--minimum-priority
now takes one of the following values instead of an integer: High, Medium High, Medium, Medium Low, Low.Go
Java
net.sourceforge.pmd.lang.java.ast.ASTGuardedPattern
has been removed.PMD CLI
--relativize-paths-with
flag (or short -z
), which replaces --short-names
. It serves the same purpose: Shortening the pathnames in the reports. However, with the new flag itâs possible to explicitly define one or more pathnames that should be used as the base when creating relative paths. The old flag --short-names
is deprecated.Deprecated APIs
For removal
ApexRootNode#getApexVersion()
has been deprecated for removal. The version returned is always Version.CURRENT
, as the apex compiler integration doesnât use additional information which Apex version actually is used. Therefore, this method canât be used to determine the Apex version of the project that is being analyzed.CPDConfiguration#setEncoding
and CPDConfiguration#getEncoding
. Use the methods getSourceEncoding
and setSourceEncoding
instead. Both are available for CPDConfiguration
which extends AbstractConfiguration
.BaseCLITest
and BaseCPDCLITest
have been deprecated for removal without replacement. CLI tests should be done in pmd-core only (and in PMD7 in pmd-cli). Individual language modules shouldnât need to test the CLI integration logic again. Instead, the individual language modules should test their functionality as unit tests.FileCollector#addZipFile
has been deprecated. It is replaced by FileCollector#addZipFileWithContent
which directly adds the content of the zip file for analysis.
PMDConfiguration#setReportShortNames
and PMDConfiguration#isReportShortNames
have been deprecated for removal. Use AbstractConfiguration#addRelativizeRoot
instead.Internal APIs
CSVWriter
AbstractAntTestHelper
Experimental APIs
filterMatches
creates a new CPD report with some matches removed with a given predicate based filter.Deprecated APIs
For removal
These classes / APIs have been deprecated and will be removed with PMD 7.0.0.
ExcessiveLengthRule
(Java)PMD CLI
PMD now supports a new --use-version
flag, which receives a language-version pair (such as java-8
or apex-54
). This supersedes the usage of -language
/ -l
and -version
/ -v
, allowing for multiple versions to be set in a single run. PMD 7 will completely remove support for -language
and -version
in favor of this new flag.
Support for -V
is being deprecated in favor of --verbose
in preparation for PMD 7. In PMD 7, -v
will enable verbose mode and -V
will show the PMD version for consistency with most Unix/Linux tools.
Support for -min
is being deprecated in favor of --minimum-priority
for consistency with most Unix/Linux tools, where -min
would be equivalent to -m -i -n
.
CPD CLI
-d
or --dir
as an alias to --files
, in favor of consistency with PMD. PMD 7 will remove support for --files
in favor of these new flags.Linux run.sh parameters
Using run.sh cpdgui
will now warn about it being deprecated. Use run.sh cpd-gui
instead.
The old designer (run.sh designerold
) is completely deprecated and will be removed in PMD 7. Switch to the new JavaFX designer: run.sh designer
.
The old visual AST viewer (run.sh bgastviewer
) is completely deprecated and will be removed in PMD 7. Switch to the new JavaFX designer: run.sh designer
for a visual tool, or use run.sh ast-dump
for a text-based alternative.
Deprecated API
PMD
and PMD.StatusCode
- PMD 7 will ship with a revamped CLI split from pmd-core. To programmatically launch analysis you can use PmdAnalysis
.PMDConfiguration#getAllInputPaths
- It is now superseded by PMDConfiguration#getInputPathList
PMDConfiguration#setInputPaths
- It is now superseded by PMDConfiguration#setInputPathList
PMDConfiguration#addInputPath
- It is now superseded by PMDConfiguration#addInputPath
PMDConfiguration#getInputFilePath
- It is now superseded by PMDConfiguration#getInputFile
PMDConfiguration#getIgnoreFilePath
- It is now superseded by PMDConfiguration#getIgnoreFile
PMDConfiguration#setInputFilePath
- It is now superseded by PMDConfiguration#setInputFilePath
PMDConfiguration#setIgnoreFilePath
- It is now superseded by PMDConfiguration#setIgnoreFilePath
PMDConfiguration#getInputUri
- It is now superseded by PMDConfiguration#getUri
PMDConfiguration#setInputUri
- It is now superseded by PMDConfiguration#setInputUri
PMDConfiguration#getReportFile
- It is now superseded by PMDConfiguration#getReportFilePath
PMDConfiguration#setReportFile
- It is now superseded by PMDConfiguration#setReportFile
PMDConfiguration#isStressTest
and PMDConfiguration#setStressTest
- Will be removed with no replacement.PMDConfiguration#isBenchmark
and PMDConfiguration#setBenchmark
- Will be removed with no replacement, the CLI will still support it.CPD
and CPD.StatusCode
- PMD 7 will ship with a revamped CLI split from pmd-core. An alternative to programmatically launch CPD analysis will be added in due time.DataType#fromBasicType
has been deprecated. The equivalent method fromTypeName
should be used instead.No changes.
6.50.0CPD CLI
--ignore-literal-sequences
argument when analyzing Lua code.Deprecated API
ASTAssignmentExpression#getOperator
ASTBinaryExpression#getOperator
ASTBooleanExpression#getOperator
ASTPostfixExpression#getOperator
ASTPrefixExpression#getOperator
All these classes have now a new getOp()
method. Existing code should be refactored to use this method instead. It returns the new enums, like AssignmentOperator
, and avoids the dependency to Jorje.
CPD CLI
--debug
. This option has the same behavior as in PMD. It enables more verbose logging output.Rule Test Framework
isRegressionTest
of test-code
is deprecated. The new attribute disabled
should be used instead for defining whether a rule test should be skipped or not.reinitializeRule
and useAuxClasspath
of test-code
are deprecated and assumed true. They will not be replaced.focused
of test-code
allows disabling all tests except the focused one temporarily.Deprecated API
net.sourceforge.pmd.lang.java.ast.ASTGuardedPattern
has been deprecated and will be removed. It was introduced for Java 17 and Java 18 Preview as part of pattern matching for switch, but it is no longer supported with Java 19 Preview.CPDRenderer
is deprecated. For custom CPD renderers the new interface CPDReportRenderer
should be used.TestDescriptor
is deprecated, replaced with RuleTestDescriptor
.RuleTst
have been deprecated as internal API.Experimental 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.
CPDConfiguration#setRenderer
CPDConfiguration#setCPDRenderer
CPDConfiguration#getRenderer
CPDConfiguration#getCPDRenderer
CPDConfiguration#getRendererFromString
CPDConfiguration#getCPDRendererFromString
CPDRendererAdapter
No changes.
6.46.0Deprecated ruleset references
Ruleset references with the following formats are now deprecated and will produce a warning when used on the CLI or in a ruleset XML file:
<lang-name>-<ruleset-name>
, eg java-basic
, which resolves to rulesets/java/basic.xml
600
, which resolves to rulesets/releases/600.xml
Use the explicit forms of these references to be compatible with PMD 7.
Deprecated API
toString
is now deprecated. The format of this method will remain the same until PMD 7. The deprecation is intended to steer users away from relying on this format, as it may be changed in PMD 7.getInputPaths
and setInputPaths
are now deprecated. A new set of methods have been added, which use lists and do not rely on comma splitting.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.
CPDCommandLineInterface
has been internalized. In order to execute CPD either CPD#runCpd
or CPD#main
should be used.BaseCPDCLITest
have been deprecated with replacements.Formatter#start
, Formatter#end
, Formatter#getRenderer
, and Formatter#isNoOutputSupplied
have been internalized.Experimental APIs
Report#filterViolations
creates a new report with some violations removed with a given predicate based filter.Report#union
can combine two reports into a single new Report.net.sourceforge.pmd.util.Predicate
will be replaced in PMD7 with the standard Predicate interface from java8.pmd-html
is entirely experimental right now. Anything in the package net.sourceforge.pmd.lang.html
should be used cautiously.Deprecated API
PMD
have been newly deprecated, including:
PMD#EOL
: use System#lineSeparator()
PMD#SUPPRESS_MARKER
: use DEFAULT_SUPPRESS_MARKER
PMD#processFiles
: use the new programmatic APIPMD#getApplicableFiles
: is internalPMDConfiguration#prependClasspath
is deprecated in favour of prependAuxClasspath
.PMDConfiguration#setRuleSets
and getRuleSets
are deprecated. Use instead setRuleSets
, addRuleSet
, and getRuleSetPaths
.BaseCLITest
have been deprecated with replacements.Several members of PMDCommandLineInterface
have 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.
AmbiguousResolutionRule
and ConnectUsingNonConnector
have been deprecated, since they didnât comply to the usual rule class naming conventions yet. The replacements are in the subpackage bestpractices
.Experimental APIs
Together with the new programmatic API the interface TextFile
has been added as experimental. It intends to replace DataSource
and SourceCode
in 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 FileCollector
decouples you from this. A file collector is available through PmdAnalysis#files
.
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 the addViolation
overloads of AbstractRule
. In PMD 7, RuleContext
will be the API to report violations, and it can already be used as such in PMD 6.configuration
is 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, including apply
, start
, end
, removeDysfunctionalRules
AbstractAccumulatingRenderer#renderFileReport
is internal API and should not be overridden in own renderers.Changed API
It is now forbidden to report a violation:
null
nodenull
messagenull
set 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.
No changes.
6.41.0Command 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
ASTCommentContainer
has 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 for ASTCatchBlockStatement
and used by the rule EmptyCatchBlock
. This information is also available via XPath attribute @ContainsComment
.No changes.
6.38.0No changes.
6.37.0PMD 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
ASTClassOrInterfaceDeclaration#isSealed
, ASTClassOrInterfaceDeclaration#isNonSealed
, ASTClassOrInterfaceDeclaration#getPermittedSubclasses
ASTPermitsList
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.cpd.TokenEntry.State
is considered to be internal API. It will probably be moved away with PMD 7.No changes.
6.35.0Deprecated API
PMD#doPMD
is deprecated. Use PMD#runPmd
instead.PMD#run
is deprecated. Use PMD#runPmd
instead.ThreadSafeReportListener
and the methods to use them in Report
(addListener
, getListeners
, addListeners
) are deprecated. This functionality will be replaced by another TBD mechanism in PMD 7.No changes.
6.33.0No changes.
6.32.0Experimental APIs
ASTTypeTestPattern
has been renamed to ASTTypePattern
in order to align the naming to the JLS.ASTRecordConstructorDeclaration
has been renamed to ASTCompactConstructorDeclaration
in order to align the naming to the JLS.ASTVariableId#isPatternBinding
ASTPattern
ASTTypePattern
ASTRecordDeclaration
ASTRecordComponentList
ASTRecordComponent
ASTRecordBody
ASTCompactConstructorDeclaration
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.
AvoidUsingHardCodedIPRule
are deprecated and considered to be internal API. They will be removed with PMD 7.Deprecated API
AbstractDomXmlRule
AbstractWsdlRule
AbstractXmlRule
Experimental APIs
GenericToken#getKind
has been added as experimental. This unifies the token interface for both JavaCC and Antlr. The already existing method AntlrToken#getKind
is therefore experimental as well. The returned constant depends on the actual language and might change whenever the grammar of the language is changed.Deprecated API
Around RuleSet parsing
RuleSetFactory
and RulesetsFactoryUtils
have been deprecated in favor of RuleSetLoader
. This is easier to configure, and more maintainable than the multiple overloads of RulesetsFactoryUtils
.RuleSet
for simple cases, eg forSingleRule
. These replace some counterparts in RuleSetFactory
RuleSets
is also deprecated, many APIs that require a RuleSets instance now are deprecated, and have a counterpart that expects a List<RuleSet>
.RuleSetReferenceId
, RuleSetReference
, RuleSetFactoryCompatibility
are 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:
net.sourceforge.pmd.cli
in pmd-core, net.sourceforge.pmd.processor
SourceCodeProcessor
PMD
(the class will be made a utility class)Miscellaneous
ASTPackageDeclaration#getPackageNameImage
, ASTTypeParameter#getParameterName
and the corresponding XPath attributes. In both cases theyâre replaced with a new method getName
, the attribute is @Name
.ASTClassOrInterfaceBody#isAnonymousInnerClass
, and ASTClassOrInterfaceBody#isEnumChild
, refs #905Internal 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.Ecmascript3Handler
net.sourceforge.pmd.lang.ecmascript.Ecmascript3Parser
EcmascriptParser#parserOptions
EcmascriptParser#getSuppressMap
net.sourceforge.pmd.lang.rule.ParametricRuleViolation
ParserOptions#suppressMarker
net.sourceforge.pmd.lang.modelica.rule.ModelicaRuleViolationFactory
No changes.
6.28.0Deprecated API
For removal
net.sourceforge.pmd.RuleViolationComparator
. Use RuleViolation#DEFAULT_COMPARATOR
instead.net.sourceforge.pmd.cpd.AbstractTokenizer
. Use net.sourceforge.pmd.cpd.AnyCpdLexer
instead (previously called AnyTokenizer).net.sourceforge.pmd.cpd.FortranTokenizer
. Was replaced by an AnyCpdLexer
. Use FortranLanguageModule#createCpdLexer
anyway.net.sourceforge.pmd.cpd.PerlTokenizer
. Was replaced by an AnyCpdLexer
. Use PerlLanguageModule#createCpdLexer
anyway.net.sourceforge.pmd.cpd.RubyTokenizer
. Was replaced by an AnyCpdLexer
. Use RubyLanguageModule#createCpdLexer
anyway.RuleReference#getOverriddenLanguage
and RuleReference#setLanguage
net.sourceforge.pmd.lang.cs.antlr4.CSharpLexer
will be moved to package net.sourceforge.pmd.lang.cs.ast
with PMD 7.net.sourceforge.pmd.lang.dart.antlr4.Dart2Lexer
will be renamed to DartLexer
and moved to package net.sourceforge.pmd.lang.dart.ast
with PMD 7. All other classes in the old package will be removed.net.sourceforge.pmd.lang.go.antlr4.GolangLexer
will be moved to package net.sourceforge.pmd.lang.go.ast
with PMD 7. All other classes in the old package will be removed.net.sourceforge.pmd.lang.kotlin.antlr4.Kotlin
will be renamed to KotlinLexer
and moved to package net.sourceforge.pmd.lang.kotlin.ast
with PMD 7.net.sourceforge.pmd.lang.lua.antlr4.LuaLexer
will be moved to package net.sourceforge.pmd.lang.lua.ast
with PMD 7. All other classes in the old package will be removed.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()
.
ASTJspDeclarations
ASTJspDocument
ScalaParserVisitorAdapter#zero
ScalaParserVisitorAdapter#combine
ApexParserVisitorReducedAdapter
TypeHelper
is deprecated in favor of TypeTestUtil
, which has the same functionality, but a slightly changed API.net.sourceforge.pmd.lang.java.symboltable
are deprecated as internal API.Deprecated API
For removal
RuleChainVisitor
and all implementations in language modulesAbstractRuleChainVisitor
Language#getRuleChainVisitorClass
BaseLanguageModule#<init>
ImportWrapper
The maven module net.sourceforge.pmd:pmd-scala
is deprecated. Use net.sourceforge.pmd:pmd-scala_2.13
or net.sourceforge.pmd:pmd-scala_2.12
instead.
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)ApexParser
ApexHandler
RuleChain
RuleSets
RulesetsFactoryUtils#getRuleSets
For removal
TokenEntry#TokenEntry
AbstractTokenizerTest
. 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
Deprecated APIs
BaseLanguageModule#addVersion(String, LanguageVersionHandler, boolean)
TokenMgrError
, in particular, a new constructor is available that should be preferred to the old onesANTLRSyntaxError
Experimental APIs
Note: Experimental APIs are identified with the annotation Experimental
, see its javadoc for details
BaseLanguageModule
have been replaced by a definitive API.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:
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.VfNode
or Node
, or the other published interfaces in this package, to refer to nodes generically.Parser
(eg VfParser
) are deprecated and should not be used directly. Use LanguageVersionHandler#getParser
instead.TokenManager
(eg VfTokenManager
) 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.
net.sourceforge.pmd.lang.apex.ast
net.sourceforge.pmd.lang.ecmascript.ast
net.sourceforge.pmd.lang.plsql.ast
net.sourceforge.pmd.lang.scala.ast
net.sourceforge.pmd.lang.vf.ast
These deprecations have already been rolled out in a previous version for the following languages:
net.sourceforge.pmd.lang.java.ast
net.sourceforge.pmd.lang.jsp.ast
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):
CppTokenManager
JavaTokenManager
Ecmascript5TokenManager
JspTokenManager
MatlabTokenManager
ModelicaTokenManager
ObjectiveCTokenManager
PLSQLTokenManager
PythonTokenManager
VfTokenManager
VmTokenManager
In the Java AST the following attributes are deprecated and will issue a warning when used in XPath rules:
ASTAdditiveExpression#getImage
- use getOperator()
insteadASTVariableDeclaratorId#getImage
- use getName()
insteadASTVariableDeclaratorId#getVariableName
- use getName()
insteadFor removal
Parser#getTokenManager
TokenManager#setFileName
AbstractTokenManager#setFileName
AbstractTokenManager#getFileName
AntlrToken#getType
- use getKind()
instead.ImmutableLanguage
MockRule
Node#getFirstParentOfAnyType
Node#getAsDocument
AbstractNode#hasDescendantOfAnyType
ASTRecordDeclaration#getComponentList
XPathRule
. See javadoc for details.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
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
RuleSetFactory
, use factory methods from RulesetsFactoryUtils
insteadAbstractApexNode
AbstractApexNodeBase
, and the related visit
methods on ApexParserVisitor
and its implementations. Use ApexNode
instead, now considers comments too.For removal
DFAGraphRule
and its implementationsDFAGraphMethod
Node
interface and AbstractNode
base class. See their javadoc for details.Node#isFindBoundary
is deprecated for XPath queries.net.sourceforge.pmd.lang.metrics
, though most of them were internal and probably not used directly outside of PMD. Use MetricsUtil
as a replacement for the language-specific façades too.QualifiableNode
, QualifiedName
AbstractJavaParser
AbstractJavaHandler
ASTAnyTypeDeclaration.TypeKind
ASTAnyTypeDeclaration#getTypeKind
JavaQualifiedName
ASTCatchStatement#getBlock
ASTCompilationUnit#declarationsAreInDefaultPackage
JavaQualifiableNode
net.sourceforge.pmd.lang.java.qname
and its contentsMethodLikeNode
ASTMethodOrConstructorDeclaration
, ASTLambdaExpression
.ASTAnyTypeDeclaration#getImage
will be removed. Please use getSimpleName()
instead. This affects ASTAnnotationTypeDeclaration#getImage
, ASTClassOrInterfaceDeclaration#getImage
, and ASTEnumDeclaration#getImage
.ASTTryStatement
, replacements with other names have been added. This includes the XPath attribute @Finally
, replace it with a test for child::FinallyStatement
.getGuardExpressionNode
are replaced with getCondition
. This affects the following nodes: WhileStatement, DoStatement, ForStatement, IfStatement, AssertStatement, ConditionalExpression.ASTYieldStatement
will not implement TypeNode
anymore come 7.0.0. Test the type of the expression nested within it.JavaMetrics
, JavaMetricsComputer
ASTArguments#getArgumentCount
. Use size
instead.ASTFormalParameters#getParameterCount
. Use size
instead.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):
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.JspNode
or Node
, or the other published interfaces in this package, to refer to nodes generically.JspParser
is deprecated and should not be used directly. Use LanguageVersionHandler#getParser
instead.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):
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.VtlNode
or Node
, or the other published interfaces in this package, to refer to nodes generically.net.sourceforge.pmd.lang.vm.directive
as well as the classes DirectiveMapper
and LogUtil
are deprecated for removal. They were only used internally during parsing.VmParser
is deprecated and should not be used directly. Use LanguageVersionHandler#getParser
instead.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
.
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
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
RuleSetFactory
, use factory methods from RulesetsFactoryUtils
insteadAbstractApexNode
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.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
Node
interface and AbstractNode
base class. See their javadoc for details.Node#isFindBoundary
is deprecated for XPath queries.AbstractJavaParser
AbstractJavaHandler
ASTAnyTypeDeclaration.TypeKind
ASTAnyTypeDeclaration#getTypeKind
JavaQualifiedName
ASTCatchStatement#getBlock
ASTCompilationUnit#declarationsAreInDefaultPackage
JavaQualifiableNode
net.sourceforge.pmd.lang.java.qname
and its contentsMethodLikeNode
ASTMethodOrConstructorDeclaration
, ASTLambdaExpression
.ASTAnyTypeDeclaration#getImage
will be removed. Please use getSimpleName()
instead. This affects ASTAnnotationTypeDeclaration#getImage
, ASTClassOrInterfaceDeclaration#getImage
, and ASTEnumDeclaration#getImage
.ASTTryStatement
, replacements with other names have been added. This includes the XPath attribute @Finally
, replace it with a test for child::FinallyStatement
.getGuardExpressionNode
are replaced with getCondition
. This affects the following nodes: WhileStatement, DoStatement, ForStatement, IfStatement, AssertStatement, ConditionalExpression.ASTYieldStatement
will not implement TypeNode
anymore come 7.0.0. Test the type of the expression nested within it.No changes.
6.19.0Deprecated APIs
For removal
net.sourceforge.pmd.dcd
and its subpackages. See DCD
.LanguageRegistry
:
RuleSet#getExcludePatterns
. Use the new method getFileExclusions
instead.RuleSet#getIncludePatterns
. Use the new method getFileInclusions
instead.Parser#canParse
Parser#getSuppressMap
RuleBuilder#RuleBuilder
. Use the new constructor with the correct ResourceLoader instead.RuleFactory#RuleFactory
. Use the new constructor with the correct ResourceLoader instead.CanSuppressWarnings
and its implementationsisSuppressed
getDeclaringType
.isSupressed
ASTMethodDeclarator
getMethodName
getBlock
getParameterCount
CanSuppressWarnings
and its implementationsisSupressed
Internal APIs
net.sourceforge.pmd.util
and its subpackages, except net.sourceforge.pmd.util.datasource
and net.sourceforge.pmd.util.database
.GridBagHelper
ColumnDescriptor
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
ASTImportDeclaration#getImportedNameNode
and ASTImportDeclaration#getPackage
have been deprecated and will be removed with PMD 7.0.0.RuleContext#setSourceCodeFilename
has been deprecated and will be removed. The already existing method RuleContext#setSourceCodeFile
should be used instead. The method RuleContext#getSourceCodeFilename
still exists and returns just the filename without the full path.AbstractPMDProcessor#filenameFrom
has 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.Report#metrics
and Report#hasMetrics
have been deprecated. They were leftovers from a previous deprecation round targeting StatisticalRule
.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.
net.sourceforge.pmd.lang.java.typeresolution
: Everything, including subpackages, except TypeHelper
and JavaTypeDefinition
.ASTCompilationUnit#getClassTypeResolver
No changes.
6.16.0Deprecated 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):
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.Please look at net.sourceforge.pmd.lang.java.ast
to find out the full list of deprecations.
Deprecated APIs
For removal
DumpFacades
in 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.DumpFacade
net.sourceforge.pmd.lang.java.ast.DumpFacade
net.sourceforge.pmd.lang.ecmascript.ast.DumpFacade
net.sourceforge.pmd.lang.jsp.ast.DumpFacade
net.sourceforge.pmd.lang.plsql.ast.DumpFacade
net.sourceforge.pmd.lang.vf.ast.DumpFacade
net.sourceforge.pmd.lang.vm.ast.AbstractVmNode#dump
net.sourceforge.pmd.lang.xml.ast.DumpFacade
LanguageVersionHandler#getDumpFacade
will be removed as well. It is deprecated, along with all its implementations in the subclasses of LanguageVersionHandler
.No changes.
6.13.0Command 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
CodeClimateRule
is 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.xml
has been deprecated and will be removed in 7.0.0. Please use the new quickstart ruleset rulesets/apex/quickstart.xml
instead.
No changes.
6.11.0StatisticalRule
and the related helper classes and base rule classes are deprecated for removal in 7.0.0. This includes all of net.sourceforge.pmd.stat
and net.sourceforge.pmd.lang.rule.stat
, and also AbstractStatisticalJavaRule
, AbstractStatisticalApexRule
and the like. The methods Report#addMetric
and metricAdded
will also be removed.setProperty
is deprecated, because MultiValuePropertyDescriptor
is deprecated as well.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 simpler PropertyBuilder
. Their APIs enjoy a high degree of source compatibility.
Concrete property classes like IntegerProperty
and StringMultiProperty
will gradually all be deprecated until 7.0.0. Their usages should be replaced by direct usage of the PropertyDescriptor
interface, e.g. PropertyDescriptor<Integer>
or PropertyDescriptor<List<String>>
.
Instead of spreading properties across countless classes, the utility class PropertyFactory
will become from 7.0.0 on the only provider for property descriptor builders. Each current property type will be replaced by a corresponding method on PropertyFactory
:
IntegerProperty
is replaced by PropertyFactory#intProperty
IntegerMultiProperty
is replaced by PropertyFactory#intListProperty
FloatProperty
and DoubleProperty
are both replaced by PropertyFactory#doubleProperty
. Having a separate property for floats wasnât that useful.
FloatMultiProperty
and DoubleMultiProperty
are replaced by PropertyFactory#doubleListProperty
.StringProperty
is replaced by PropertyFactory#stringProperty
StringMultiProperty
is replaced by PropertyFactory#stringListProperty
RegexProperty
is replaced by PropertyFactory#regexProperty
EnumeratedProperty
is replaced by PropertyFactory#enumProperty
EnumeratedProperty
is replaced by PropertyFactory#enumListProperty
BooleanProperty
is replaced by PropertyFactory#booleanProperty
BooleanMultiProperty
, is not replaced, because it doesnât have a use case.CharacterProperty
is replaced by PropertyFactory#charProperty
CharacterMultiProperty
is replaced by PropertyFactory#charListProperty
LongProperty
is replaced by PropertyFactory#longIntProperty
LongMultiProperty
is replaced by PropertyFactory#longIntListProperty
MethodProperty
, FileProperty
, TypeProperty
and 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 (in net.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 to PropertyConstraint
s, which will allow virtually any constraint to be defined, and improve documentation and error reporting. The related methods PropertyTypeId#isPropertyNumeric
and PropertyTypeId#isPropertyPackaged
are also deprecated.
MultiValuePropertyDescriptor
and SingleValuePropertyDescriptor
are 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 method PropertyDescriptor#isMultiValue
will be removed accordingly.
Changes to the PropertyDescriptor interface
preferredRowCount
is deprecated with no intended replacement. It was never implemented, and does not belong in this interface. The methods uiOrder
and compareTo(PropertyDescriptor)
are deprecated for the same reason. These methods mix presentation logic with business logic and are not necessary for PropertyDescriptors to work. PropertyDescriptor
will not extend Comparable<PropertyDescriptor>
anymore come 7.0.0.propertyErrorFor
is deprecated and will be removed with no intended replacement. Itâs really just a shortcut for prop.errorFor(rule.getProperty(prop))
.T
valueFrom(String)
and String
asDelimitedString
(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.isMultiValue
and type
are 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, type
will 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.errorFor
is deprecated as its return type will be changed to Optional<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. Only Attribute
remains public API.
The classes PropertyDescriptorField
, PropertyDescriptorBuilderConversionWrapper
, and the methods PropertyDescriptor#attributeValuesById
, PropertyDescriptor#isDefinedExternally
and PropertyTypeId#getFactory
. These were used to read and write properties to and from XML, but were not intended as public API.
The class ValueParserConstants
and the interface ValueParser
.
All classes from net.sourceforge.pmd.lang.java.metrics.impl.visitors
are 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, JavaParserVisitorAdapter
should be directly subclassed.
LanguageVersionHandler#getDataFlowHandler()
, LanguageVersionHandler#getDFAGraphRule()
For removal
All classes from net.sourceforge.pmd.properties.modules
will be removed.
The interface Dimensionable
has 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 ASTLocalVariableDeclaration
and ASTFieldDeclaration
have also been deprecated:
ASTFieldDeclaration
wonât be a TypeNode
come 7.0.0, so getType
and getTypeDefinition
are deprecated.
The method getVariableName
on 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<
ASTVariableId
>
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
, and JavaParserVisitorDecorator
are deprecated with no intended replacement.
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:
CppHandler
CppLanguageModule
CppParser
CsLanguageModule
FortranLanguageModule
GroovyLanguageModule
MatlabHandler
MatlabLanguageModule
MatlabParser
ObjectiveCHandler
ObjectiveCLanguageModule
ObjectiveCParser
PhpLanguageModule
PythonHandler
PythonLanguageModule
PythonParser
Rule
: isDfa()
, isTypeResolution()
, isMultifile()
and their respective setters.RuleSet
: usesDFA(Language)
, usesTypeResolution(Language)
, usesMultifile(Language)
RuleSets
: usesDFA(Language)
, usesTypeResolution(Language)
, usesMultifile(Language)
LanguageVersionHandler
: getDataFlowFacade()
, getSymbolFacade()
, getSymbolFacade(ClassLoader)
, getTypeResolutionFacade(ClassLoader)
, getQualifiedNameResolutionFacade(ClassLoader)
No changes.
6.8.0A couple of methods and fields in net.sourceforge.pmd.properties.AbstractPropertySource
have 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.PropertySource
have been deprecated as well: usesDefaultValues()
, useDefaultValueFor()
, ignoredProperties()
.
The class net.sourceforge.pmd.lang.rule.AbstractDelegateRule
has 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.RuleReference
has 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()
.
All classes in the package net.sourceforge.pmd.lang.dfa.report
have been deprecated and will be removed with PMD 7.0.0. This includes the class net.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 for YAHTMLRenderer
, 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.
The utility class CommentUtil
has 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 node FormalComment
, which contains as children JavadocElement
nodes, which in turn provide access to the JavadocTag
.
All comment AST nodes (FormalComment
, MultiLineComment
, SingleLineComment
) have a new method getFilteredComment()
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.
net.sourceforge.pmd.benchmark
have been deprecated: Benchmark
, Benchmarker
, BenchmarkReport
, BenchmarkResult
, RuleDuration
, StringBuilderCR
and TextReport
. Their API is not supported anymore and is disconnected from the internals of PMD. Use the newer API based around TimeTracker
instead, which can be found in the same package.TypeOfFunction
has been deprecated. Use the newer TypeIsFunction
in the same package.typeof
methods in JavaFunctions
have been deprecated. Use the newer typeIs
method in the same class instead.isA
, isEither
and isNeither
of TypeHelper
. Use the new isExactlyAny
and isExactlyNone
methods in the same class instead.The static method PMDParameters#transformParametersIntoConfiguration
is now deprecated, for removal in 7.0.0. The new instance method toConfiguration
replaces it.
The method ASTConstructorDeclaration#getParameters
has been deprecated in favor of the new method getFormalParameters
. This method is available for both ASTConstructorDeclaration
and ASTMethodDeclaration
.
getXPathNodeName
is added to the Node
interface, which removes the use of toString
of a node to get its XPath element name (see #569).
AbstractNode
, will be removed with 7.0.0Node.toString
method will not necessarily provide its XPath node name anymore.The interface net.sourceforge.pmd.cpd.Renderer
has been deprecated. A new interface CPDRenderer
has been introduced to replace it. The main difference is that the new interface is meant to render directly to a java.io.Writer
rather than to a String. This allows to greatly reduce the memory footprint of CPD, as on large projects, with many duplications, it was causing OutOfMemoryError
s (see #795).
net.sourceforge.pmd.cpd.FileReporter
has also been deprecated as part of this change, as itâs no longer needed.
PMD#VERSION
has been deprecated and will be removed with PMD 7.0.0. Please use PMDVersion#VERSION
instead.isFindBoundary
should not be an attributen.s.pmd.reporting
packagen.s.pmd.lang.rule
packagecolor
and system property pmd.color
in TextColorRenderer
--no-ruleset-compatibility
ClasspathClassLoader::getResource
child first--file-list
is specified--ignore-literals
and --ignore-identifiers
workLanguage specific fixes:
@SuppressWarnings
with constants instead of literalsisOverridden
in ASTMethodDeclarationfoo.bar().size()
Throwable.addSuppressed(...)
new BigDecimal(Expression)
this.run()
foo.bar.run()
foo.notify(bar)
--file-list
is specified - Wener (@wener-tiobe)RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4