Thread: [pmd-devel] [ANNOUNCE] PMD 6.44.0 released
A source code analyzer
Brought to you by:
adangel,
juansotuyo
|
From: Andreas D. <and...@pm...> - 2022-03-27 15:49:38
Attachments:
OpenPGP_signature
|
* Downloads: https://github.com/pmd/pmd/releases/tag/pmd_releases%2F6.44.0 * Documentation: https://pmd.github.io/pmd-6.44.0/ 27-March-2022 - 6.44.0 The PMD team is pleased to announce PMD 6.44.0. This is a minor release. Table Of Contents * New and noteworthy <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#new-and-noteworthy> o PMD User Survey <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#pmd-user-survey> o Java 18 Support <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#java-18-support> o Better XML XPath support <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#better-xml-xpath-support> o New XPath functions <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#new-xpath-functions> o New programmatic API <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#new-programmatic-api> * Fixed Issues <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#fixed-issues> * API Changes <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#api-changes> o Deprecated API <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#deprecated-api> o Experimental APIs <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#experimental-apis> * External Contributions <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#external-contributions> * Stats <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#stats> New and noteworthy PMD User Survey Help shape the future of PMD by telling us how you use it. Please participate in our survey at https://forms.gle/4d8r1a1RDzfixHDc7. Thank you! Java 18 Support This release of PMD brings support for Java 18. There are no new standard language features. PMD also supports JEP 420: Pattern Matching for switch (Second Preview) <https://openjdk.java.net/jeps/420> as a preview language feature. In order to analyze a project with PMD that uses these language features, you'll need to enable it via the environment variable |PMD_JAVA_OPTS| and select the new language version |18-preview|: |export PMD_JAVA_OPTS=--enable-preview ./run.sh pmd -language java -version 18-preview ... | Note: Support for Java 16 preview language features have been removed. The version "16-preview" is no longer available. Better XML XPath support The new rule class |DomXPathRule| <https://docs.pmd-code.org/apidocs/pmd-xml/6.44.0/net/sourceforge/pmd/lang/xml/rule/DomXPathRule.html#> is intended to replace usage of the |XPathRule| for XML rules. This rule executes the XPath query in a different way, which sticks to the XPath specification. This means the expression is interpreted the same way in PMD as in all other XPath development tools that stick to the standard. You can for instance test the expression in an online XPath editor. Prefer using this class to define XPath rules: replace the value of the |class| attribute with |net.sourceforge.pmd.lang.xml.rule.DomXPathRule| like so: |<rule name="MyXPathRule" language="xml" message="A message" class="net.sourceforge.pmd.lang.xml.rule.DomXPathRule"> <properties> <property name="xpath"> <value><![CDATA[ /a/b/c[@attr = "5"] ]]></value> </property> <!-- Note: the property "version" is ignored, remove it. The query is XPath 2. --> </properties> </rule> | The rule is more powerful than |XPathRule|, as it can now handle XML namespaces, comments and processing instructions. Please refer to the Javadoc of |DomXPathRule| <https://docs.pmd-code.org/apidocs/pmd-xml/6.44.0/net/sourceforge/pmd/lang/xml/rule/DomXPathRule.html#> for information about the differences with |XPathRule| and examples. |XPathRule| is still perfectly supported for all other languages, including Apex and Java. New XPath functions The new XPath functions |pmd:startLine|, |pmd:endLine|, |pmd:startColumn|, and |pmd:endColumn| are now available in XPath rules for all languages. They replace the node attributes |@BeginLine|, |@EndLine| and such. These attributes will be deprecated in a future release. Please refer to the documentation <https://pmd.github.io/latest/pmd_userdocs_extending_writing_xpath_rules.html#pmd-extension-functions> of these functions for more information, including usage samples. Note that the function |pmd:endColumn| returns an exclusive index, while the attribute |@EndColumn| is inclusive. This is for forward compatibility with PMD 7, which uses exclusive end indices. New programmatic API This release introduces a new programmatic API to replace the inflexible |PMD| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/PMD.html#> class. Programmatic execution of PMD should now be done with a |PMDConfiguration| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/PMDConfiguration.html#> and a |PmdAnalysis| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/PmdAnalysis.html#>, for instance: |PMDConfiguration config = new PMDConfiguration(); config.setDefaultLanguageVersion(LanguageRegistry.findLanguageByTerseName("java").getVersion("11")); config.setInputPaths("src/main/java"); config.prependAuxClasspath("target/classes"); config.setMinimumPriority(RulePriority.HIGH); config.addRuleSet("rulesets/java/quickstart.xml"); config.setReportFormat("xml"); config.setReportFile("target/pmd-report.xml"); try (PmdAnalysis pmd = PmdAnalysis.create(config)) { // note: don't use `config` once a PmdAnalysis has been created. // optional: add more rulesets pmd.addRuleSet(pmd.newRuleSetLoader().loadFromResource("custom-ruleset.xml")); // optional: add more files pmd.files().addFile(Paths.get("src", "main", "more-java", "ExtraSource.java")); // optional: add more renderers pmd.addRenderer(renderer); // or just call PMD pmd.performAnalysis(); } | The |PMD| class still supports methods related to CLI execution: |runPmd| and |main|. All other members are now deprecated for removal. The CLI itself remains compatible, if you run PMD via command-line, no action is required on your part. Fixed Issues * apex o #3817 <https://github.com/pmd/pmd/pull/3817>: [apex] Add designer bindings to display main attributes * apex-performance o #3773 <https://github.com/pmd/pmd/pull/3773>: [apex] EagerlyLoadedDescribeSObjectResult false positives with SObjectField.getDescribe() * core o #2693 <https://github.com/pmd/pmd/issues/2693>: [ci] Add integration tests with real open-source projects o #3299 <https://github.com/pmd/pmd/issues/3299>: [core] Deprecate system properties of PMDCommandLineInterface * java o #3809 <https://github.com/pmd/pmd/issues/3809>: [java] Support JDK 18 * doc o #2504 <https://github.com/pmd/pmd/issues/2504>: [doc] Improve "Edit me on github" button o #3812 <https://github.com/pmd/pmd/issues/3812>: [doc] Documentation website table of contents broken on pages with many subheadings * java-design o #3850 <https://github.com/pmd/pmd/issues/3850>: [java] ImmutableField - false negative when field assigned in constructor conditionally o #3851 <https://github.com/pmd/pmd/issues/3851>: [java] ClassWithOnlyPrivateConstructorsShouldBeFinal - false negative when a compilation unit contains two class declarations * xml o #2766 <https://github.com/pmd/pmd/issues/2766>: [xml] XMLNS prefix is not pre-declared in xpath query o #3863 <https://github.com/pmd/pmd/issues/3863>: [xml] Make XPath rules work exactly as in the XPath spec API Changes Deprecated API * Several members of |PMD| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/PMD.html#> have been newly deprecated, including: * |PMD#EOL|: use |System#lineSeparator()| * |PMD#SUPPRESS_MARKER|: use |DEFAULT_SUPPRESS_MARKER| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/PMDConfiguration.html#DEFAULT_SUPPRESS_MARKER> * |PMD#processFiles|: use the new programmatic API <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#new-programmatic-api> * |PMD#getApplicableFiles|: is internal * |PMDConfiguration#prependClasspath| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/PMDConfiguration.html#prependClasspath(java.lang.String)> is deprecated in favour of |prependAuxClasspath| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/PMDConfiguration.html#prependAuxClasspath(java.lang.String)>. * |PMDConfiguration#setRuleSets| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/PMDConfiguration.html#setRuleSets(java.lang.String)> and |getRuleSets| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/PMDConfiguration.html#getRuleSets()> are deprecated. Use instead |setRuleSets| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/PMDConfiguration.html#setRuleSets(java.util.List)>, |addRuleSet| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/PMDConfiguration.html#addRuleSet(java.lang.String)>, and |getRuleSetPaths| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/PMDConfiguration.html#getRuleSetPaths()>. * Several members of |BaseCLITest| <https://docs.pmd-code.org/apidocs/pmd-test/6.44.0/net/sourceforge/pmd/cli/BaseCLITest.html#> have been deprecated with replacements. * Several members of |PMDCommandLineInterface| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/cli/PMDCommandLineInterface.html#> 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. * In modelica, the rule classes |AmbiguousResolutionRule| <https://docs.pmd-code.org/apidocs/pmd-modelica/6.44.0/net/sourceforge/pmd/lang/modelica/rule/AmbiguousResolutionRule.html#> and |ConnectUsingNonConnector| <https://docs.pmd-code.org/apidocs/pmd-modelica/6.44.0/net/sourceforge/pmd/lang/modelica/rule/ConnectUsingNonConnector.html#> 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 <https://sourceforge.net/p/pmd/news/2022/03/pmd-6440-27-march-2022-released/#new-programmatic-api> the interface |TextFile| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/lang/document/TextFile.html#> has been added as /experimental/. It intends to replace |DataSource| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/util/datasource/DataSource.html#> and |SourceCode| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/cpd/SourceCode.html#> 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| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/lang/document/FileCollector.html#> decouples you from this. A file collector is available through |PmdAnalysis#files| <https://docs.pmd-code.org/apidocs/pmd-core/6.44.0/net/sourceforge/pmd/PmdAnalysis.html#files()>. External Contributions * #3773 <https://github.com/pmd/pmd/pull/3773>: [apex] EagerlyLoadedDescribeSObjectResult false positives with SObjectField.getDescribe() - @filiprafalowicz <https://github.com/filiprafalowicz> * #3811 <https://github.com/pmd/pmd/pull/3811>: [doc] Improve "Edit me on github" button - @btjiong <https://github.com/btjiong> * #3836 <https://github.com/pmd/pmd/pull/3836>: [doc] Make TOC scrollable when too many subheadings - @JerritEic <https://github.com/JerritEic> Stats * 124 commits * 23 closed tickets & PRs * Days since last release: 29 |