A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.pmd-code.org/latest/pmd_release_notes_pmd7.html below:

Detailed Release Notes for PMD 7

These are the detailed release notes for PMD 7.

Table of Contents 🚀 Major Features and Enhancements New official logo

Many 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 Java

The 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 Interface

PMD 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 support

PMD 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 Designer

This 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

New CPD report format cpdhtml-v2.xslt

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.

New: CPD support for Coco

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 Julia

Thanks 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 TypeScript

Thanks 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 Support

This 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 support

PMD 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:

Contributors: Jeroen Borgers (@jborgers), Peter Paul Bakker (@stokpop)

New: Swift support

Given 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.

Contributors: Lucas Soncini (@lsoncini), Matías Fraga (@matifraga), Tomás De Lucca (@tomidelucca)

Changed: Apex Support: Replaced Jorje with fully open source front-end

When 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) Changed: Groovy Support (CPD) Changed: HTML support

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 support

The 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 versions

We 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 properties Changed: Velocity Template Language (VTL)

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.

Changed: Visualforce

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.

🌟 New and changed rules New Rules

Apex

Java

Kotlin

Swift

XML

Changed Rules

General changes

Apex General changes

Apex Codestyle

Java General changes

Java Best Practices

Java Codestyle

Java Design

Java Documentation

Java Error Prone

Deprecated Rules

In PMD 7.0.0, there are no deprecated rules.

Removed Rules

The following previously deprecated rules have been finally removed:

Apex

Java

Removed rulesets

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.

💥 Compatibility and Migration Notes

Note: The full detailed documentation of the changes are available in the Migration Guide for PMD 7

For endusers For integrators 🚨 API

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 XPath 3.1 support

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:

Node stream API for AST traversal

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 framework

The metrics framework has been made simpler and more general.

Testing framework Language Lifecycle and Language Properties

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 properties New Programmatic API for CPD

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.0

These are the changes between 7.0.0-rc4 and final 7.0.0.

pmd-java

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

Moved classes/consolidated packages

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.

Removed classes and members (previously deprecated)

The annotation @DeprecatedUntil700 has been removed.

Removed classes, interfaces and methods (not previously deprecated)

Renamed classes, interfaces, methods

New API

These were annotated with @Experimental, but can now be considered stable.

Removed functionality

7.0.0-rc4

pmd-java

Rule properties

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:

The following previously deprecated methods have been removed:

The following methods have been removed:

The following classes have been removed:

Moved packages

Changed types and other changes

Internal APIs

Deprecated API

Experimental APIs

7.0.0-rc3

PMD Distribution

CLI

pmd-core

7.0.0-rc2

Removed classes and methods

The following previously deprecated classes have been removed:

CLI

7.0.0-rc1

CLI

6.55.0

Go

Java

6.54.0

PMD CLI

Deprecated APIs

For removal

Internal APIs

Experimental APIs

6.53.0

Deprecated APIs

For removal

These classes / APIs have been deprecated and will be removed with PMD 7.0.0.

6.52.0

PMD CLI

CPD CLI

Linux run.sh parameters

Deprecated API

6.51.0

No changes.

6.50.0

CPD CLI

6.49.0

Deprecated API

6.48.0

CPD CLI

Rule Test Framework

Deprecated 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.

6.47.0

No changes.

6.46.0

Deprecated 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:

Use the explicit forms of these references to be compatible with PMD 7.

Deprecated API

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.

6.45.0

Experimental APIs

6.44.0

Deprecated API

Experimental APIs

6.43.0

Deprecated API

Some API deprecations were performed in core PMD classes, to improve compatibility with PMD 7.

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.

Changed API

It is now forbidden to report a violation:

Note that the message is set from the XML rule declaration, so this is only relevant if you instantiate rules manually.

RuleContext now requires setting the current rule before calling apply. This is done automatically by RuleSet#apply and such. Creating and configuring a RuleContext manually is strongly advised against, as the lifecycle of RuleContext will change drastically in PMD 7.

6.42.0

No changes.

6.41.0

Command Line Interface

The command line options for PMD and CPD now use GNU-syle long options format. E.g. instead of -rulesets the preferred usage is now --rulesets. Alternatively one can still use the short option -R. Some options also have been renamed to a more consistent casing pattern at the same time (--fail-on-violation instead of -failOnViolation). The old single-dash options are still supported but are deprecated and will be removed with PMD 7. This change makes the command line interface more consistent within PMD and also less surprising compared to other cli tools.

The changes in detail for PMD:

old option new option -rulesets --rulesets (or -R) -uri --uri -dir --dir (or -d) -filelist --file-list -ignorelist --ignore-list -format --format (or -f) -debug --debug -verbose --verbose -help --help -encoding --encoding -threads --threads -benchmark --benchmark -stress --stress -shortnames --short-names -showsuppressed --show-suppressed -suppressmarker --suppress-marker -minimumpriority --minimum-priority -property --property -reportfile --report-file -force-language --force-language -auxclasspath --aux-classpath -failOnViolation --fail-on-violation --failOnViolation --fail-on-violation -norulesetcompatibility --no-ruleset-compatibility -cache --cache -no-cache --no-cache

The changes in detail for CPD:

old option new option --failOnViolation --fail-on-violation -failOnViolation --fail-on-violation --filelist --file-list 6.40.0

Experimental APIs

6.39.0

No changes.

6.38.0

No changes.

6.37.0

PMD CLI

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.

6.36.0

No changes.

6.35.0

Deprecated API

6.34.0

No changes.

6.33.0

No changes.

6.32.0

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.

6.31.0

Deprecated API

Experimental APIs

6.30.0

Deprecated API

Around RuleSet parsing

Around the PMD class

Many classes around PMD’s entry point (PMD) have been deprecated as internal, including:

Miscellaneous

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.

6.29.0

No changes.

6.28.0

Deprecated API

For removal

6.27.0

Deprecated API

For removal

6.26.0

Deprecated API

For removal

6.25.0

Deprecated APIs

Internal API

Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. You can identify them with the @InternalApi annotation. You’ll also get a deprecation warning.

For removal

6.24.0

Deprecated APIs

Experimental APIs

Note: Experimental APIs are identified with the annotation Experimental, see its javadoc for details

6.23.0

Deprecated APIs

Internal API

Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. You can identify them with the @InternalApi annotation. You’ll also get a deprecation warning.

In ASTs

As part of the changes we’d like to do to AST classes for 7.0.0, we would like to hide some methods and constructors that rule writers should not have access to. The following usages are now deprecated in the Apex, Javascript, PL/SQL, Scala and Visualforce ASTs:

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.

These deprecations have already been rolled out in a previous version for the following languages:

Outside of these packages, these changes also concern the following TokenManager implementations, and their corresponding Parser if it exists (in the same package):

In the Java AST the following attributes are deprecated and will issue a warning when used in XPath rules:

For removal

6.22.0

Deprecated APIs

Internal API

Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. You can identify them with the @InternalApi annotation. You’ll also get a deprecation warning.

For removal

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):

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):

Please look at net.sourceforge.pmd.lang.vm.ast to find out the full list of deprecations.

PLSQL AST

The production and node ASTCursorBody was unnecessary, not used and has been removed. Cursors have been already parsed as ASTCursorSpecification.

6.21.0

Deprecated APIs

Internal API

Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. You can identify them with the @InternalApi annotation. You’ll also get a deprecation warning.

For removal

6.20.0

No changes.

6.19.0

Deprecated APIs

For removal

Internal APIs

6.18.0

Changes to Renderer

Deprecated APIs

For removal

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.

6.17.0

No changes.

6.16.0

Deprecated APIs

Reminder: Please don’t use members marked with the annotation InternalApi, as they will likely be removed, hidden, or otherwise intentionally broken with 7.0.0.

In ASTs

As part of the changes we’d like to do to AST classes for 7.0.0, we would like to hide some methods and constructors that rule writers should not have access to. The following usages are now deprecated in the Java AST (with other languages to come):

Please look at net.sourceforge.pmd.lang.java.ast to find out the full list of deprecations.

6.15.0

Deprecated APIs

For removal

6.14.0

No changes.

6.13.0

Command Line Interface

The start scripts run.sh, pmd.bat and cpd.bat support the new environment variable PMD_JAVA_OPTS. This can be used to set arbitrary JVM options for running PMD, such as memory settings (e.g. PMD_JAVA_OPTS=-Xmx512m) or enable preview language features (e.g. PMD_JAVA_OPTS=--enable-preview).

The previously available variables such as OPTS or HEAPSIZE are deprecated and will be removed with PMD 7.0.0.

Deprecated API

6.12.0

No changes.

6.11.0 6.10.0

Properties framework

The properties framework is about to get a lifting, and for that reason, we need to deprecate a lot of APIs to remove them in 7.0.0. The proposed changes to the API are described on the wiki

Changes to how you define properties

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

Changes to the PropertyDescriptor interface

Deprecated APIs

For internalization

For removal

6.9.0

No changes.

6.8.0 6.7.0 6.5.0 6.4.0 6.2.0 6.1.0 6.0.1 🐛 Fixed Issues

Language specific fixes:

✨ External Contributions

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