Skip to content

Releases: pmd/pmd

PMD 6.51.0 (29-October-2022)

29 Oct 07:50
pmd_releases/6.51.0
66e8340
Compare
Choose a tag to compare

29-October-2022 - 6.51.0

The PMD team is pleased to announce PMD 6.51.0.

This is a minor release.

Table Of Contents

New and noteworthy

New Rules

<rule ref="category/apex/bestpractices.xml/ApexUnitTestClassShouldHaveRunAs"/>

The rule is part of the quickstart.xml ruleset.

Modified Rules

  • The Java rule TestClassWithoutTestCases has a new property testClassPattern. This is
    used to detect empty test classes by name. Previously this rule could only detect empty JUnit3 test cases
    properly. To switch back to the old behavior, this property can be set to an empty value which disables the
    test class detection by pattern.

Fixed Issues

  • apex
    • #4149: [apex] New rule: ApexUnitTestClassShouldHaveRunAs
  • doc
    • #4144: [doc] Update docs to reflect supported languages
    • #4163: [doc] Broken links on page "Architecture Decisions"
  • java-bestpractices
    • #4140: [java] [doc] AccessorClassGeneration violations hidden with Java 11
  • java-codestyle
    • #4139: [java] UnnecessaryFullyQualifiedName FP when the same simple class name exists in the current package
  • java-documentation
    • #4141: [java] UncommentedEmptyConstructor FP when constructor annotated with @Autowired
  • java-performance
    • #1167: [java] AvoidArrayLoops false positive on double assignment
    • #2080: [java] StringToString rule false-positive with field access
    • #2692: [java] [doc] AvoidArrayLoops flags copy assignment in same array as sub-optimal
    • #3437: [java] StringToString doesn't trigger on Bar.class.getSimpleName().toString()
    • #3681: [java] StringToString doesn't trigger on string literals
    • #3847: [java] AvoidArrayLoops should consider final variables
    • #3977: [java] StringToString false-positive with local method name confusion
    • #4091: [java] AvoidArrayLoops false negative with do-while loops
    • #4148: [java] UseArrayListInsteadOfVector ignores Vector when other classes are imported
  • java-errorprone
    • #929: [java] Inconsistent results with TestClassWithoutTestCases
    • #2636: [java] TestClassWithoutTestCases false positive with JUnit5 ParameterizedTest
  • javascript
    • #4165: [javascript] InaccurateNumericLiteral underscore separator notation false positive

API Changes

No changes.

External Contributions

Stats

  • 63 commits
  • 28 closed tickets & PRs
  • Days since last release: 28

PMD 6.50.0 (30-September-2022)

30 Sep 13:58
pmd_releases/6.50.0
37f6d82
Compare
Choose a tag to compare

30-September-2022 - 6.50.0

The PMD team is pleased to announce PMD 6.50.0.

This is a minor release.

Table Of Contents

New and noteworthy

Lua now supports additionally Luau

This release of PMD adds support for Luau, a gradually typed language derived
from Lua. This means, that the Lua language in PMD can now parse both Lua and Luau.

Modified rules

  • The Java rule UnusedPrivateField now ignores private fields, if the fields are
    annotated with any annotation or the enclosing class has any annotation. Annotations often enable a
    framework (such as dependency injection, mocking or e.g. Lombok) which use the fields by reflection or other
    means. This usage can't be detected by static code analysis. Previously these frameworks where explicitly allowed
    by listing their annotations in the property "ignoredAnnotations", but that turned out to be prone of false
    positive for any not explicitly considered framework. That's why the property "ignoredAnnotations" has been
    deprecated for this rule.
  • The Java rule CommentDefaultAccessModifier now by default ignores JUnit5 annotated
    methods. This behavior can be customized using the property ignoredAnnotations.

Fixed Issues

  • cli
    • #4118: [cli] run.sh designer reports "integer expression expected"
  • core
    • #4116: [core] Missing --file arg in TreeExport CLI example
  • doc
    • #4072: [doc] Add architecture decision records
    • #4109: [doc] Add page for 3rd party rulesets
    • #4124: [doc] Fix typos in Java rule docs
  • java
    • #3431: [java] Add sample java project to regression-tester which uses new language constructs
  • java-bestpractices
    • #4033: [java] UnusedPrivateField - false positive with Lombok @ToString.Include
    • #4037: [java] UnusedPrivateField - false positive with Spring @SpyBean
  • java-codestyle
    • #3859: [java] CommentDefaultAccessModifier is triggered in JUnit5 test class
    • #4085: [java] UnnecessaryFullyQualifiedName false positive when nested and non-nested classes with the same name and in the same package are used together
    • #4133: [java] UnnecessaryFullyQualifiedName - FP for inner class pkg.ClassA.Foo implementing pkg.Foo
  • java-design
    • #4090: [java] FinalFieldCouldBeStatic false positive with non-static synchronized block (regression in 6.48, worked with 6.47)
  • java-errorprone
    • #1718: [java] ConstructorCallsOverridableMethod false positive when calling super method
    • #2348: [java] ConstructorCallsOverridableMethod occurs when unused overloaded method is defined
    • #4099: [java] ConstructorCallsOverridableMethod should consider method calls with var access
  • scala
    • #4138: [scala] Upgrade scala-library to 2.12.7 / 2.13.9 and scalameta to 4.6.0

API Changes

CPD CLI

  • CPD now supports the --ignore-literal-sequences argument when analyzing Lua code.

Financial Contributions

Many thanks to our sponsors:

External Contributions

Stats

  • 100 commits
  • 26 closed tickets & PRs
  • Days since last release: 29

PMD 6.49.0 (31-August-2022)

31 Aug 17:41
pmd_releases/6.49.0
4b4ebab
Compare
Choose a tag to compare

31-August-2022 - 6.49.0

The PMD team is pleased to announce PMD 6.49.0.

This is a minor release.

Table Of Contents

New and noteworthy

Updated PMD Designer

This PMD release ships a new version of the pmd-designer.
For the changes, see PMD Designer Changelog.

Fixed Issues

  • apex
    • #4096: [apex] ApexAssertionsShouldIncludeMessage and ApexUnitTestClassShouldHaveAsserts: support new Assert class (introduced with Apex v56.0)
  • core
    • #3970: [core] FileCollector.addFile ignores language parameter
  • java-codestyle
    • #4082: [java] UnnecessaryImport false positive for on-demand imports of nested classes

API Changes

Deprecated API

External Contributions

  • #4081: [apex] Remove Jorje leaks outside ast package - @eklimo
  • #4083: [java] UnnecessaryImport false positive for on-demand imports of nested classes (fix for #4082) - @abyss638
  • #4092: [apex] Implement ApexQualifiableNode for ASTUserEnum - @aaronhurst-google
  • #4095: [core] CPD: Added begin and end token to XML reports - @pacvz
  • #4097: [apex] ApexUnitTestClassShouldHaveAssertsRule: Support new Assert class (Apex v56.0) - @tprouvot
  • #4104: [doc] Add MegaLinter in the list of integrations - @nvuillam

Stats

  • 49 commits
  • 10 closed tickets & PRs
  • Days since last release: 32

PMD 6.48.0 (30-July-2022)

30 Jul 09:58
pmd_releases/6.48.0
6aa2b47
Compare
Choose a tag to compare

30-July-2022 - 6.48.0

The PMD team is pleased to announce PMD 6.48.0.

This is a minor release.

Table Of Contents

New and noteworthy

Java 19 Support

This release of PMD brings support for Java 19. There are no new standard language features.

PMD supports JEP 427: Pattern Matching for switch (Third Preview) and
JEP 405: Record Patterns (Preview) as preview language features.

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 19-preview:

export PMD_JAVA_OPTS=--enable-preview
./run.sh pmd -language java -version 19-preview ...

Note: Support for Java 17 preview language features have been removed. The version "17-preview" is no longer available.

Gherkin support

Thanks to the contribution from Anne Brouwers PMD now has CPD support
for the Gherkin language. It is used to defined test cases for the
Cucumber testing tool for behavior-driven development.

Being based on a proper Antlr grammar, CPD can:

Fixed Issues

  • apex
    • #4056: [apex] ApexSOQLInjection: Add support count query
  • core
    • #3796: [core] CPD should also provide a --debug flag
    • #4021: [core] CPD: Add total number of tokens to XML reports
    • #4031: [core] If report is written to stdout, stdout should not be closed
    • #4051: [doc] Additional rulesets are not listed in documentation
    • #4053: [core] Allow building PMD under Java 18+
  • java
    • #4015: [java] Support JDK 19
  • java-bestpractices
    • #3455: [java] WhileLoopWithLiteralBoolean - false negative with complex expressions
  • java-design
    • #3729: [java] TooManyMethods ignores "real" methods which are named like getters or setters
    • #3949: [java] FinalFieldCouldBeStatic - false negative with unnecessary parenthesis
  • java-performance
    • #3625: [java] AddEmptyString - false negative with empty var
  • lua
    • #4061: [lua] Fix several related Lua parsing issues found when using CPD
  • test
    • #3302: [test] Improve xml test schema
    • #3758: [test] Move pmd-test to java 8
    • #3976: [test] Extract xml schema module

API Changes

CPD CLI

  • CPD has a new CLI option --debug. This option has the same behavior as in PMD. It enables more verbose
    logging output.

Rule Test Framework

  • The module "pmd-test", which contains support classes to write rule tests, now requires Java 8. If you depend on
    this module for testing your own custom rules, you'll need to make sure to use at least Java 8.
  • The new module "pmd-test-schema" contains now the XSD schema and the code to parse the rule test XML files. The
    schema has been extracted in order to easily share it with other tools like the Rule Designer or IDE plugins.
  • Test schema changes:
    • The attribute 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.
    • The attributes reinitializeRule and useAuxClasspath of test-code are deprecated and assumed true.
      They will not be replaced.
    • The new attribute focused of test-code allows disabling all tests except the focused one temporarily.
  • More information about the rule test framework can be found in the documentation:
    Testing your rules

Deprecated API

  • The experimental Java AST class 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.
  • The interface CPDRenderer is deprecated. For custom CPD renderers
    the new interface CPDReportRenderer should be used.
  • The class TestDescriptor is deprecated, replaced with RuleTestDescriptor.
  • Many methods of 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.

Financial Contributions

Many thanks to our sponsors:

External Contributions

Stats

  • 102 commits
  • 26 closed tickets & PRs
  • Days since last release: 35

PMD 6.47.0 (25-June-2022)

25 Jun 07:50
pmd_releases/6.47.0
07eb3d2
Compare
Choose a tag to compare

25-June-2022 - 6.47.0

The PMD team is pleased to announce PMD 6.47.0.

This is a minor release.

Table Of Contents

Fixed Issues

  • core
    • #3999: [cli] All files are analyzed despite parameter --file-list
    • #4009: [core] Cannot build PMD with Temurin 17
  • java-bestpractices
    • #3824: [java] UnusedPrivateField: Do not flag fields annotated with @Version
    • #3825: [java] UnusedPrivateField: Do not flag fields annotated with @Id or @EmbeddedId
  • java-design
    • #3823: [java] ImmutableField: Do not flag fields in @Entity
    • #3981: [java] ImmutableField reports fields annotated with @Value (Spring)
    • #3998: [java] ImmutableField reports fields annotated with @Captor (Mockito)
    • #4004: [java] ImmutableField reports fields annotated with @GwtMock (GwtMockito) and @Spy (Mockito)
    • #4008: [java] ImmutableField not reporting fields that are only initialized in the declaration
    • #4011: [java] ImmutableField: Do not flag fields annotated with @Inject
    • #4020: [java] ImmutableField reports fields annotated with @FindBy and @FindBys (Selenium)
  • java-errorprone
    • #3936: [java] AvoidFieldNameMatchingMethodName should consider enum class
    • #3937: [java] AvoidDuplicateLiterals - uncompilable test cases

API Changes

No changes.

External Contributions

  • #3985: [java] Fix false negative problem about Enum in AvoidFieldNameMatchingMethodName #3936 - @Scrsloota
  • #3993: [java] AvoidDuplicateLiterals - Add the method "buz" definition to test cases - @dalizi007
  • #4002: [java] ImmutableField - Ignore fields annotated with @Value (Spring) or @Captor (Mockito) - @jjlharrison
  • #4003: [java] UnusedPrivateField - Ignore fields annotated with @Id/@EmbeddedId/@Version (JPA) or @Mock/@Spy/@MockBean (Mockito/Spring) - @jjlharrison
  • #4006: [doc] Fix eclipse plugin update site URL - @shiomiyan
  • #4010: [core] Bump kotlin to version 1.7.0 - @maikelsteneker

Stats

  • 45 commits
  • 23 closed tickets & PRs
  • Days since last release: 27

PMD 6.46.0 (28-May-2022)

28 May 09:21
pmd_releases/6.46.0
a75acde
Compare
Choose a tag to compare

28-May-2022 - 6.46.0

The PMD team is pleased to announce PMD 6.46.0.

This is a minor release.

Table Of Contents

New and noteworthy

CLI improvements

The PMD CLI now allows repeating the --dir (-d) and --rulesets (-R) options,
as well as providing several space-separated arguments to either of them. For instance:

pmd -d src/main/java src/test/java -R rset1.xml -R rset2.xml

This also allows globs to be used on the CLI if your shell supports shell expansion.
For instance, the above can be written

pmd -d src/*/java -R rset*.xml

Please use theses new forms instead of using comma-separated lists as argument to these options.

C# Improvements

When executing CPD on C# sources, the option --ignore-annotations is now supported as well.
It ignores C# attributes when detecting duplicated code. This option can also be enabled via
the CPD GUI. See #3974 for details.

New Rules

This release ships with 2 new Java rules.

  • EmptyControlStatement reports many instances of empty things, e.g. control statements whose
    body is empty, as well as empty initializers.

    EmptyControlStatement also works for empty for and do loops, while there were previously
    no corresponding rules.

    This new rule replaces the rules EmptyFinallyBlock, EmptyIfStmt, EmptyInitializer, EmptyStatementBlock,
    EmptySwitchStatements, EmptySynchronizedBlock, EmptyTryBlock, and EmptyWhileStmt.

<rule ref="category/java/codestyle.xml/EmptyControlStatement"/>

The rule is part of the quickstart.xml ruleset.

  • UnnecessarySemicolon reports semicolons that are unnecessary (so called "empty statements"
    and "empty declarations").

    This new rule replaces the rule EmptyStatementNotInLoop.

<rule ref="category/java/codestyle.xml/UnnecessarySemicolon"/>

The rule is part of the quickstart.xml ruleset.

Deprecated Rules

Fixed Issues

  • cli
    • #1445: [core] Allow CLI to take globs as parameters
  • core
    • #2352: [core] Deprecate <lang>-<ruleset> hyphen notation for ruleset references
    • #3787: [core] Internalize some methods in Ant Formatter
    • #3835: [core] Deprecate system properties of CPDCommandLineInterface
    • #3942: [core] common-io path traversal vulnerability (CVE-2021-29425)
  • cs (c#)
    • #3974: [cs] Add option to ignore C# attributes (annotations)
  • go
    • #2752: [go] Error parsing unicode values
  • html
    • #3955: [html] Improvements for handling text and comment nodes
    • #3978: [html] Add additional file extensions htm, xhtml, xht, shtml
  • java
    • #3423: [java] Error processing identifiers with Unicode
  • java-bestpractices
    • #3954: [java] NPE in UseCollectionIsEmptyRule when .size() is called in a record
  • java-design
    • #3874: [java] ImmutableField reports fields annotated with @Autowired (Spring) and @mock (Mockito)
  • java-errorprone
    • #3096: [java] EmptyStatementNotInLoop FP in 6.30.0 with IfStatement
  • java-performance
    • #3379: [java] UseArraysAsList must ignore primitive arrays
    • #3965: [java] UseArraysAsList false positive with non-trivial loops
  • javascript
    • #2605: [js] Support unicode characters
    • #3948: [js] Invalid operator error for method property in object literal
  • python
    • #2604: [python] Support unicode identifiers

API Changes

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:

  • <lang-name>-<ruleset-name>, eg java-basic, which resolves to rulesets/java/basic.xml
  • the internal release number, eg 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.

External Contributions

Stats

  • 92 commits
  • 30 closed tickets & PRs
  • Days since last release: 28

PMD 6.45.0 (30-April-2022)

30 Apr 07:56
1d2b40b
Compare
Choose a tag to compare

30-April-2022 - 6.45.0

The PMD team is pleased to announce PMD 6.45.0.

This is a minor release.

Table Of Contents

New and noteworthy

PMD User Survey

Help shape the future of PMD by telling us how you use it.

Our little survey is still open in case you didn't participate yet.
Please participate in our survey at https://forms.gle/4d8r1a1RDzfixHDc7.

Thank you!

Support for HTML

This version of PMD ships a new language module to support analyzing of HTML.
Support for HTML is experimental and might change without notice.
The language implementation is not complete yet and the AST doesn't look
well for text nodes and comment nodes and might be changed in the future.
You can write your own rules, but we don't guarantee that the rules work with
the next (minor) version of PMD without adjustments.

Please give us feedback about how practical this new language is in
discussions. Please report
missing features or bugs as new issues.

New rules

  • The HTML rule AvoidInlineStyles finds elements which use a style attribute.
    In order to help maintaining a webpage it is considered good practice to separate content and styles. Instead
    of inline styles one should use CSS files and classes.
    <rule ref="category/html/bestpractices.xml/AvoidInlineStyles" />
  • The HTML rule UnnecessaryTypeAttribute finds "link" and "script" elements which
    still have a "type" attribute. This is not necessary anymore since modern browsers automatically use CSS and
    JavaScript.
      <rule ref="category/html/bestpractices.xml/UnnecessaryTypeAttribute" />
  • The HTML rule UseAltAttributeForImages finds "img" elements without an "alt"
    attribute. An alternate text should always be provided in order to help screen readers.
      <rule ref="category/html/bestpractices.xml/UseAltAttributeForImages" />

Modified rules

  • The Java rule UnusedPrivateField has a new property ignoredFieldNames.
    The default ignores serialization-specific fields (eg serialVersionUID).
    The property can be used to ignore more fields based on their name.
    Note that the rule used to ignore fields named IDENT, but doesn't anymore (add this value to the property to restore the old behaviour).

Fixed Issues

  • core
    • #3792: [core] Allow to filter violations in Report
    • #3881: [core] SARIF renderer depends on platform default encoding
    • #3882: [core] Fix AssertionError about exhaustive switch
    • #3884: [core] XML report via ant task contains XML header twice
    • #3896: [core] Fix ast-dump CLI when reading from stdin
  • doc
    • #2505: [doc] Improve side bar to show release date
  • java
    • #3068: [java] Some tests should not depend on real rules
    • #3889: [java] Catch LinkageError in UselessOverridingMethodRule
  • java-bestpractices
    • #3910: [java] UnusedPrivateField - Allow the ignored fieldnames to be configurable
    • #1185: [java] ArrayIsStoredDirectly false positive with field access
    • #1474: [java] ArrayIsStoredDirectly false positive with method call
    • #3879 [java] ArrayIsStoredDirectly reports duplicated violation
    • #3929: [java] ArrayIsStoredDirectly should report the assignment rather than formal parameter
  • java-design
    • #3603: [java] SimplifiedTernary: no violation for 'condition ? true : false' case
  • java-performance
    • #3867: [java] UseArraysAsList with method call
  • plsql
    • #3687: [plsql] Parsing exception EXECUTE IMMEDIATE l_sql BULK COLLECT INTO statement
    • #3706: [plsql] Parsing exception CURSOR statement with parenthesis groupings

API Changes

Experimental APIs

  • Report has two new methods which allow limited mutations of a given report:
    • 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.
  • The module pmd-html is entirely experimental right now. Anything in the package
    net.sourceforge.pmd.lang.html should be used cautiously.

External Contributions

Stats

  • 97 commits
  • 31 closed tickets & PRs
  • Days since last release: 33

PMD 6.44.0 (27-March-2022)

27 Mar 15:20
6859f8d
Compare
Choose a tag to compare

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

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) 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 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 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 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 class.
Programmatic execution of PMD should now be done with a PMDConfiguration and a PmdAnalysis, 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
    • #3817: [apex] Add designer bindings to display main attributes
  • apex-performance
    • #3773: [apex] EagerlyLoadedDescribeSObjectResult false positives with SObjectField.getDescribe()
  • core
    • #2693: [ci] Add integration tests with real open-source projects
    • #3299: [core] Deprecate system properties of PMDCommandLineInterface
  • java
    • #3809: [java] Support JDK 18
  • doc
    • #2504: [doc] Improve "Edit me on github" button
    • #3812: [doc] Documentation website table of contents broken on pages with many subheadings
  • java-design
    • #3850: [java] ImmutableField - false negative when field assigned in constructor conditionally
    • #3851: [java] ClassWithOnlyPrivateConstructorsShouldBeFinal - false negative when a compilation unit contains two class declarations
  • xml
    • #2766: [xml] XMLNS prefix is not pre-declared in xpath query
    • #3863: [xml] Make XPath rules work exactly as in the XPath spec

API Changes

Deprecated API

Experimenta...

Read more

PMD 6.43.0 (26-February-2022)

26 Feb 09:18
dd0ee61
Compare
Choose a tag to compare

26-February-2022 - 6.43.0

The PMD team is pleased to announce PMD 6.43.0.

This is a minor release.

Table Of Contents

New and noteworthy

Fixed Issues

  • core
    • #3427: [core] Stop printing CLI usage text when exiting due to invalid parameters
    • #3768: [core] SARIF formatter reports multiple locations when it should report multiple results
  • doc
    • #2502: [doc] Add floating table-of-contents (toc) on the right
    • #3807: [doc] Document Ant Task parameter threads
  • java
    • #3698: [java] Parsing error with try-with-resources and qualified resource
  • java-bestpractices
    • #3605: [java] SwitchStmtsShouldHaveDefault triggered when default case is present
  • java-codestyle
    • #278: [java] ConfusingTernary should treat != null as positive condition
  • java-performance
    • #3374: [java] UseStringBufferForStringAppends: Wrong example in documentation
  • misc
    • #3759: [lang-test] Upgrade dokka maven plugin to 1.4.32
  • plsql
    • #3746: [plsql] Parsing exception "Less than or equal to/Greater than or equal to" operators in DML statements

API Changes

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 createReport
  • RuleContext: 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.
  • The field 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.

Changed API

It is now forbidden to report a violation:

  • With a null node
  • With a null message
  • With a null 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.

External Contributions

Stats

  • 49 commits
  • 22 closed tickets & PRs
  • Days since last release: 27

PMD 6.42.0 (29-January-2022)

29 Jan 09:14
391c325
Compare
Choose a tag to compare

29-January-2022 - 6.42.0

The PMD team is pleased to announce PMD 6.42.0.

This is a minor release.

Table Of Contents

New and noteworthy

Javascript: Rhino updated to latest version 1.7.14

Rhino, the implementation of JavaScript we use
for parsing JavaScript code, has been updated to the latest version 1.7.14.
Now language features like template strings can be parsed. However Rhino does
not support all features of the latest EcmaScript standard.

New rules

  • The new Java rule FinalParameterInAbstractMethod detects parameters that are
    declared as final in interfaces or abstract methods. Declaring the parameters as final is useless
    because the implementation may choose to not respect it.
    <rule ref="category/java/codestyle.xml/FinalParameterInAbstractMethod" />

The rule is part of the quickstart.xml ruleset.

Modified rules

  • The Apex rule ApexDoc has a new property reportProperty.
    If set to false (default is true if unspecified) doesn't report missing ApexDoc comments on properties.
    It allows you to enforce ApexDoc comments for classes and methods without requiring them for properties.

Fixed Issues

  • core
    • #3328: [core] designer.bat errors when JAVAFX_HOME contains spaces
  • java
    • #3698: [java] Error resolving Symbol Table
  • java-bestpractices
    • #3209: [java] UnusedPrivateMethod false positive with static method and cast expression
    • #3468: [java] UnusedPrivateMethod false positive when outer class calls private static method on inner class
  • java-design
    • #3679: [java] Make FinalFieldCouldBeStatic detect constant variable
  • java-errorprone
    • #3644: [java] InvalidLogMessageFormat: false positives with logstash structured logging
    • #3686: [java] ReturnEmptyCollectionRatherThanNull - false negative with conditioned returns
    • #3701: [java] MissingStaticMethodInNonInstantiatableClass false positive with method inner classes
    • #3721: [java] ReturnEmptyCollectionRatherThanNull - false positive with stream and lambda
  • java-performance
    • #3492: [java] UselessStringValueOf: False positive when there is no initial String to append to
    • #3639: [java] UseStringBufferLength: false negative with empty string variable
    • #3712: [java] InsufficientStringBufferDeclaration false positive with StringBuilder.setLength(0)
  • javascript
    • #3703: [javascript] Error - no Node adapter class registered for XmlPropRef

API Changes

No changes.

External Contributions

Stats

  • 88 commits
  • 35 closed tickets & PRs
  • Days since last release: 62