Pmd Versions Save

An extensible multilanguage static code analyzer.

pmd_releases/6.41.0

2 years ago

27-November-2021 - 6.41.0

The PMD team is pleased to announce PMD 6.41.0.

This is a minor release.

Table Of Contents

New and noteworthy

GitHub Action for PMD

PMD now has its own official GitHub Action: GitHub Action for PMD. It can execute PMD with your own ruleset against your project. It creates a SARIF report which is uploaded as a build artifact. Furthermore the build can be failed based on the number of violations.

Feedback and pull requests are welcome at https://github.com/pmd/pmd-github-action.

Last release in 2021

This minor release will be the last one in 2021. The next release is scheduled to be end of January 2022.

Fixed Issues

  • core
    • #2954: Create GitHub Action for PMD
    • #3424: [core] Migrate CLI to using GNU-style long options
    • #3425: [core] Add a --version CLI option
    • #3593: [core] Ant task fails with Java17
    • #3635: [ci] Update sample projects for regression tester
  • java-bestpractices
    • #3595: [java] PrimitiveWrapperInstantiation: no violation on 'new Boolean(val)'
    • #3613: [java] ArrayIsStoredDirectly doesn't consider nested classes
    • #3614: [java] JUnitTestsShouldIncludeAssert doesn't consider nested classes
    • #3618: [java] UnusedFormalParameter doesn't consider anonymous classes
    • #3630: [java] MethodReturnsInternalArray doesn't consider anonymous classes
  • java-design
    • #3620: [java] SingularField doesn't consider anonymous classes defined in non-private fields
  • java-errorprone
    • #3624: [java] TestClassWithoutTestCases reports wrong classes in a file
  • java-performance
    • #3491: [java] UselessStringValueOf: False positive when valueOf(char [], int, int) is used

API Changes

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

External Contributions

Stats

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

pmd_releases/6.40.0

2 years ago

30-October-2021 - 6.40.0

The PMD team is pleased to announce PMD 6.40.0.

This is a minor release.

Table Of Contents

New and noteworthy

Updated Apex Support

  • The Apex language support has been bumped to version 54.0 (Spring '22).

New rules

    <rule ref="category/apex/performance.xml/EagerlyLoadedDescribeSObjectResult" />

Modified rules

  • The Apex rule ApexUnitTestClassShouldHaveAsserts has a new property additionalAssertMethodPattern. When specified the pattern is evaluated against each invoked method name to determine whether it represents a test assertion in addition to the standard names.

  • The Apex rule ApexDoc has a new property reportMissingDescription. If set to false (default is true if unspecified) doesn't report an issue if the @description tag is missing. This is consistent with the ApexDoc dialect supported by derivatives such as SfApexDoc and also with analogous documentation tools for other languages, e.g., JavaDoc, ESDoc/JSDoc, etc.

  • The Apex rule ApexCRUDViolation has a couple of new properties: These allow specification of regular-expression-based patterns for additional methods that should be considered valid for pre-CRUD authorization beyond those offered by the system Apex checks and ESAPI, e.g., sirono-common's AuthorizationUtil class. Two new properties have been added per-CRUD operation, one to specify the naming pattern for a method that authorizes that operation and another to specify the argument passed to that method that contains the SObjectType instance of the type being authorized. Here is an example of these new properties:

    <rule ref="category/apex/security.xml/ApexCRUDViolation" message="...">
      <priority>3</priority>
      <properties>
        <property name="createAuthMethodPattern" value="AuthorizationUtil\.(is|assert)(Createable|Upsertable)"/>
        <!--
         There's one of these properties for each operation, and the default value is 0 so this is technically
         superfluous, but it's included it here for example purposes.
         -->
        <property name="createAuthMethodTypeParamIndex" value="0"/>
        <property name="readAuthMethodPattern" value="AuthorizationUtil\.(is|assert)Accessible"/>
        <property name="updateAuthMethodPattern" value="AuthorizationUtil\.(is|assert)(Updateable|Upsertable)"/>
        <property name="deleteAuthMethodPattern" value="AuthorizationUtil\.(is|assert)Deletable"/>
        <property name="undeleteAuthMethodPattern" value="AuthorizationUtil\.(is|assert)Undeletable"/>
        <property name="mergeAuthMethodPattern" value="AuthorizationUtil\.(is|assert)Mergeable"/>
      </properties>
    </rule>
    
  • The Apex rule EmptyStatementBlock has two new properties:

    Setting reportEmptyPrivateNoArgConstructor to false ignores empty private no-arg constructors that are commonly used in singleton pattern implementations and utility classes in support of prescribed best practices.

    Setting reportEmptyVirtualMethod to false ignores empty virtual methods that are commonly used in abstract base classes as default no-op implementations when derived classes typically only override a subset of virtual methods.

    By default, both properties are true to not change the default behaviour of this rule.

  • The Apex rule EmptyCatchBlock has two new properties modeled after the analgous Java rule:

    The allowCommentedBlocks property, when set to true (defaults to false), ignores empty blocks containing comments, e.g.:

    try {
        doSomethingThatThrowsAnExpectedException();
        System.assert(false, 'Expected to catch an exception.');
    } catch (Exception e) {
        // Expected
    }
    

    The allowExceptionNameRegex property is a regular expression for exception variable names for which empty catch blocks should be ignored by this rule. For example, using the default property value of ^(ignored|expected)$, the following empty catch blocks will not be reported:

    try {
        doSomethingThatThrowsAnExpectedException();
        System.assert(false, 'Expected to catch an exception.');
    } catch (IllegalStateException ignored) {
    } catch (NumberFormatException expected) {
    }
    
  • The Apex rule OneDeclarationPerLine has a new property reportInForLoopInitializer: If set to false (default is true if unspecified) doesn't report an issue for multiple declarations in a for loop's initializer section. This is support the common idiom of one declaration for the loop variable and another for the loop bounds condition, e.g.,

    for (Integer i = 0, numIterations = computeNumIterations(); i < numIterations; i++) {
    }
    
  • The Java rule ClassNamingConventions uses a different default value of the property utilityClassPattern: This rule was detecting utility classes by default since PMD 6.3.0 and enforcing the naming convention that utility classes has to be suffixed with Util or Helper or Constants. However this turned out to be not so useful as a default configuration, as there is no standard naming convention for utility classes.

    With PMD 6.40.0, the default value of this property has been changed to [A-Z][a-zA-Z0-9]* (Pascal case), effectively disabling the special handling of utility classes. This is the same default pattern used for concrete classes.

    This means, that the feature to enforce a naming convention for utility classes is now a opt-in feature and can be enabled on demand.

    To use the old behaviour, the property needs to be configured as follows:

    <rule ref="category/java/codestyle.xml/ClassNamingConventions">
        <properties>
            <property name="utilityClassPattern" value="[A-Z][a-zA-Z0-9]+(Utils?|Helper|Constants)" />
        </properties>
    </rule>
    

Fixed Issues

  • apex
    • #1089: [apex] ApexUnitTestClassShouldHaveAsserts: Test asserts in other methods not detected
    • #1090: [apex] ApexCRUDViolation: checks not detected if done in another method
    • #3532: [apex] Promote usage of consistent getDescribe() info
    • #3566: [apex] ApexDoc rule should not require "@description"
    • #3568: [apex] EmptyStatementBlock: should provide options to ignore empty private constructors and empty virtual methods
    • #3569: [apex] EmptyCatchBlock: should provide an option to ignore empty catch blocks in test methods
    • #3570: [apex] OneDeclarationPerLine: should provide an option to ignore multiple declarations in a for loop initializer
    • #3576: [apex] ApexCRUDViolation should provide an option to specify additional patterns for methods that encapsulate authorization checks
    • #3579: [apex] ApexCRUDViolation: false negative with undelete
  • java-bestpractices
    • #3542: [java] MissingOverride: False negative for enum method
  • java-codestyle
    • #1595: [java] Discuss default for utility classes in ClassNamingConventions
    • #3563: [java] The ClassNamingConventionsRule false-positive's on the class name "Constants"
  • java-errorprone
    • #3560: [java] InvalidLogMessageFormat: False positive with message and exception in a block inside a lambda
  • java-performance
    • #2364: [java] AddEmptyString false positive in annotation value
  • java-security
    • #3368: [java] HardcodedCryptoKey false negative with variable assignments

API Changes

Experimental APIs

  • The interface 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.

External Contributions

  • #3538: [apex] New rule EagerlyLoadedDescribeSObjectResult - Jonathan Wiesel
  • #3549: [java] Ignore AddEmptyString rule in annotations - Stanislav Myachenkov
  • #3561: [java] InvalidLogMessageFormat: False positive with message and exception in a block inside a lambda - Nicolas Filotto
  • #3565: [doc] Fix resource leak due to Files.walk - lujiefsi
  • #3571: [apex] Fix for #1089 - Added new configuration property additionalAssertMethodPattern to ApexUnitTestClassShouldHaveAssertsRule - Scott Wells
  • #3572: [apex] Fix for #3566 - Added new configuration property reportMissingDescription to ApexDocRule - Scott Wells
  • #3573: [apex] Fix for #3568 - Added new configuration properties reportEmptyPrivateNoArgConstructor and reportEmptyVirtualMethod to EmptyStatementBlock - Scott Wells
  • #3574: [apex] Fix for #3569 - Added new configuration properties allowCommentedBlocks and allowExceptionNameRegex to EmptyCatchBlock - Scott Wells
  • #3575: [apex] Fix for #3570 - Added new configuration property reportInForLoopInitializer to OneDeclarationPerLine - Scott Wells
  • #3577: [apex] Fix for #3576 - Added new configuration properties *AuthMethodPattern and *AuthMethodTypeParamIndex to ApexCRUDViolation rule - Scott Wells
  • #3578: [apex] ApexCRUDViolation: Documentation changes for #3576 - Scott Wells
  • #3580: [doc] Release notes updates for the changes in issue #3569 - Scott Wells
  • #3581: [apex] #3569 - Requested changes for code review feedback - Scott Wells

Stats

  • 72 commits
  • 37 closed tickets & PRs
  • Days since last release: 34

pmd_releases/6.39.0

2 years ago

25-September-2021 - 6.39.0

The PMD team is pleased to announce PMD 6.39.0.

This is a minor release.

Table Of Contents

New and noteworthy

All Contributors

PMD follows the All Contributors specification. Contributions of any kind welcome!

See credits for our complete contributors list.

Fixed Issues

  • core
    • #3499: [core] Fix XPath rulechain with combined node tests
  • java-errorprone
    • #3493: [java] AvoidAccessibilityAlteration: add tests and fix rule
  • javascript
    • #3516: [javascript] NPE while creating rule violation when specifying explicit line numbers
  • plsql
    • #3487: [plsql] Parsing exception OPEN ref_cursor_name FOR statement
    • #3515: [plsql] Parsing exception SELECT...INTO on Associative Arrays Types

API Changes

No changes.

External Contributions

  • #3516: [javascript] NPE while creating rule violation when specifying explicit line numbers - Kevin Guerra

Stats

  • 37 commits
  • 10 closed tickets & PRs
  • Days since last release: 27

pmd_releases/6.38.0

2 years ago

28-August-2021 - 6.38.0

The PMD team is pleased to announce PMD 6.38.0.

This is a minor release.

Table Of Contents

Fixed Issues

  • apex
    • #3462: [apex] SOQL performed in a for-each loop doesn't trigger ApexCRUDViolationRule
    • #3484: [apex] ApexCRUDViolationRule maintains state across files
  • core
    • #3446: [core] Allow XPath rules to access the current file name
  • java-bestpractices
    • #3403: [java] MethodNamingConventions junit5TestPattern does not detect parameterized tests

External Contributions

Stats

  • 32 commits
  • 8 closed tickets & PRs
  • Days since last release: 27

pmd_releases/6.37.0

2 years ago

31-July-2021 - 6.37.0

The PMD team is pleased to announce PMD 6.37.0.

This is a minor release.

Table Of Contents

New and noteworthy

Java 17 Support

This release of PMD brings support for Java 17. PMD supports JEP 409: Sealed Classes which has been promoted to be a standard language feature of Java 17.

PMD also supports JEP 406: Pattern Matching for switch (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 17-preview:

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

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

Updated PMD Designer

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

New rules

This release ships with 3 new Java rules.

    <rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation" />

The rule is part of the quickstart.xml ruleset.

    <rule ref="category/java/bestpractices.xml/SimplifiableTestAssertion" />

The rule is part of the quickstart.xml ruleset.

    <rule ref="category/java/errorprone.xml/ReturnEmptyCollectionRatherThanNull" />

The rule is part of the quickstart.xml ruleset.

Renamed rules

  • The Java rule MissingBreakInSwitch has been renamed to ImplicitSwitchFallThrough (category error prone) to better reflect the rule's purpose: The rule finds implicit fall-through cases in switch statements, which are most likely unexpected. The old rule name described only one way how to avoid a fall-through, namely using break but continue, throw and return avoid a fall-through as well. This enables us to improve this rule in the future.

Deprecated rules

Fixed Issues

  • apex
    • #3201: [apex] ApexCRUDViolation doesn't report Database class DMLs, inline no-arg object instantiations and inline list initialization
    • #3329: [apex] ApexCRUDViolation doesn't report SOQL for loops
  • core
    • #1603: [core] Language version comparison
    • #2133: [xml] Allow to check Salesforce XML Metadata using XPath rules
    • #3377: [core] NPE when specifying report file in current directory in PMD CLI
    • #3387: [core] CPD should avoid unnecessary copies when running with --skip-lexical-errors
  • java-bestpractices
    • #2908: [java] Merge Junit assertion simplification rules
    • #3235: [java] UseTryWithResources false positive when closeable is provided as a method argument or class field
  • java-errorprone
    • #3361: [java] Rename rule MissingBreakInSwitch to ImplicitSwitchFallThrough
    • #3382: [java] New rule ReturnEmptyCollectionRatherThanNull
  • java-performance
    • #3420: [java] NPE in InefficientStringBuffering with Records

API Changes

PMD CLI

  • PMD has a new CLI option -force-language. With that a language can be forced to be used for all input files, irrespective of filenames. When using this option, the automatic language selection by extension is disabled and all files are tried to be parsed with the given language. Parsing errors are ignored and unparsable files are skipped.

    This option allows to use the xml language for files, that don't use xml as extension. See also the examples on PMD CLI reference.

Experimental APIs

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

  • 82 commits
  • 29 closed tickets & PRs
  • Days since last release: 35

pmd_releases/6.36.0

2 years ago

26-June-2021 - 6.36.0

The PMD team is pleased to announce PMD 6.36.0.

This is a minor release.

Table Of Contents

New and noteworthy

Improved Incremental Analysis

Incremental Analysis has long helped our users obtain faster analysis results, however, its implementation tended to be too cautious in detecting changes to the runtime and type resolution classpaths, producing more cache invalidations than necessary. We have now improved the heuristics to remove several bogus invalidations, and slightly sped up the cache usage along the way.

PMD will now ignore:

  • Non class files in classpath and jar / zip files being referenced.
  • Changes to the order of file entries within a jar / zip
  • Changes to file metadata within jar / zip (ie: creation and modification time, significant in multi-module / composite build projects where lateral artifacts are frequently recreated)

New rules

  • The new Apex rule AvoidDebugStatements finds usages of System.debug calls. Debug statements contribute to longer transactions and consume Apex CPU time even when debug logs are not being captured. You can try out this rule like so:
    <rule ref="category/apex/performance.xml/AvoidDebugStatements" />
  • The new Apex rule InaccessibleAuraEnabledGetter checks that an AuraEnabled getter is public or global. This is necessary if it is referenced in Lightning components. You can try out this rule like so:
    <rule ref="category/apex/errorprone.xml/InaccessibleAuraEnabledGetter" />

Renamed rules

  • The Java rule BadComparison has been renamed to ComparisonWithNaN to better reflect what the rule actually detects. It now considers usages of Double.NaN or Float.NaN in more cases and fixes false negatives.

Fixed Issues

  • apex
    • #3307: [apex] Avoid debug statements since it impact performance
    • #3321: [apex] New rule to detect inaccessible AuraEnabled getters (summer '21 security update)
    • #3332: [apex] CognitiveComplexity - incorrect increment for "else if"
  • core
    • #2637: [cpd] Error Loading stylesheet cpdhtml.xslt
    • #3323: [core] Adds fullDescription and tags in SARIF report
  • java-bestpractices
    • #957: [java] GuardLogStatement: False positive with compile-time constant arguments
    • #3076: [java] UnusedAssignment reports unused variable when used in increment expr
    • #3114: [java] UnusedAssignment false positive when reporting unused variables
    • #3315: [java] LiteralsFirstInComparisons false positive with two constants
    • #3341: [java] JUnitTestsShouldIncludeAssert should support Junit 5
    • #3340: [java] NullPointerException applying rule GuardLogStatement
  • java-codestyle
    • #3317: [java] Update UnnecessaryImport to recognize usage of imported types in javadoc's @exception tag
  • java-errorprone
    • #2895: [java] Improve BadComparison and rename to ComparisonWithNaN
    • #3284: [java] InvalidLogMessageFormat may examine the value of a different but identically named String variable
    • #3304: [java] NPE in MoreThanOneLoggerRule on a java 16 record
    • #3305: [java] ConstructorCallsOverridableMethodRule IndexOutOfBoundsException on a java16 record
    • #3343: [java] CloneMethodMustImplementCloneable: FN with local classes
  • java-performance
    • #3331: [java] UseArraysAsList false negative with for-each loop
    • #3344: [java] InefficientEmptyStringCheck FN with trim.length on method call

API Changes

No changes.

External Contributions

  • #3276: [apex] Update ApexCRUDViolation and OperationWithLimitsInLoop docs - Jonathan Wiesel
  • #3306: [java] More than one logger rule test null pointer exception - Arnaud Jeansen
  • #3317: [java] Update UnnecessaryImport to recognize usage of imported types in javadoc's @exception tag - Piotrek Żygieło
  • #3319: [apex] New AvoidDebugStatements rule to mitigate performance impact - Jonathan Wiesel
  • #3320: [java] Fix incorrect increment for "else if" branch in Cognitive Complexity docs - Denis Borovikov
  • #3322: [apex] added rule to detect inaccessible AuraEnabled getters - Philippe Ozil
  • #3323: [core] Adds fullDescription and tags in SARIF report - Clint Chester
  • #3339: [java] JUnitTestsShouldIncludeAssert Tweak assertion definition to avoid false positive with modern JUnit5 - Arnaud Jeansen

Stats

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

pmd_releases/6.35.0

2 years ago

29-May-2021 - 6.35.0

The PMD team is pleased to announce PMD 6.35.0.

This is a minor release.

Table Of Contents

New and noteworthy

Javascript module now requires at least Java 8

The latest version of Rhino, the implementation of JavaScript we use for parsing JavaScript code, requires at least Java 8. Therefore we decided to upgrade the pmd-javascript module to Java 8 as well. This means that from now on, a Java 8 or later runtime is required in order to analyze JavaScript code. Note that PMD core still only requires Java 7.

New rules

This release ships with 3 new Java rules.

    <rule ref="category/java/bestpractices.xml/JUnit5TestShouldBePackagePrivate" />
  • CognitiveComplexity uses the cognitive complexity metric to find overly complex code. This metric improves on the similar cyclomatic complexity in several ways, for instance, it incentivizes using clearly readable shorthands and idioms. See the rule documentation for more details. You can try out this rule like so:
    <rule ref="category/java/design.xml/CognitiveComplexity" />
  • MutableStaticState finds non-private static fields that are not final. These fields break encapsulation since these fields can be modified from anywhere within the program. You can try out this rule like so:
    <rule ref="category/java/design.xml/MutableStaticState" />

Modified rules

  • The Java rule CompareObjectsWithEquals has now a new property typesThatCompareByReference. With that property, you can configure types, that should be whitelisted for comparison by reference. By default, java.lang.Enum and java.lang.Class are allowed, but you could add custom types here. Additionally comparisons against constants are allowed now. This makes the rule less noisy when two constants are compared. Constants are identified by looking for an all-caps identifier.

Deprecated rules

  • The java rule DefaultPackage has been deprecated in favor of CommentDefaultAccessModifier.

    The rule "DefaultPackage" assumes that any usage of package-access is accidental, and by doing so, prohibits using a really fundamental and useful feature of the language.

    To satisfy the rule, you have to make the member public even if it doesn't need to, or make it protected, which muddies your intent even more if you don't intend the class to be extended, and may be at odds with other rules like AvoidProtectedFieldInFinalClass.

    The rule CommentDefaultAccessModifier should be used instead. It flags the same thing, but has an escape hatch.

  • The Java rule CloneThrowsCloneNotSupportedException has been deprecated without replacement.

    The rule has no real value as CloneNotSupportedException is a checked exception and therefore you need to deal with it while implementing the clone() method. You either need to declare the exception or catch it. If you catch it, then subclasses can't throw it themselves explicitly. However, Object.clone() will still throw this exception if the Cloneable interface is not implemented.

    Note, this rule has also been removed from the Quickstart Ruleset (rulesets/java/quickstart.xml).

Fixed Issues

  • apex
    • #3183: [apex] ApexUnitTestMethodShouldHaveIsTestAnnotation false positive with helper method
    • #3243: [apex] Correct findBoundary when traversing AST
  • core
    • #2639: [core] PMD CLI output file is not created if directory or directories in path don't exist
    • #3196: [core] Deprecate ThreadSafeReportListener
  • doc
    • #3230: [doc] Remove "Edit me" button for language index pages
  • dist
    • #2466: [dist] Distribution archive doesn't include all batch scripts
  • java
    • #3269: [java] Fix NPE in MethodTypeResolution
  • java-bestpractices
    • #1175: [java] UnusedPrivateMethod FP with Junit 5 @MethodSource
    • #2219: [java] Document Reasons to Avoid Reassigning Parameters
    • #2737: [java] Fix misleading rule message on rule SwitchStmtsShouldHaveDefault with non-exhaustive enum switch
    • #3236: [java] LiteralsFirstInComparisons should consider constant fields (cont'd)
    • #3239: [java] PMD could enforce non-public methods for Junit5 / Jupiter test methods
    • #3254: [java] AvoidReassigningParameters reports violations on wrong line numbers
  • java-codestyle
    • #2655: [java] UnnecessaryImport false positive for on-demand imports
    • #3206: [java] Deprecate rule DefaultPackage
    • #3262: [java] FieldDeclarationsShouldBeAtStartOfClass: false negative with anon classes
    • #3265: [java] MethodArgumentCouldBeFinal: false negatives with interfaces and inner classes
    • #3266: [java] LocalVariableCouldBeFinal: false negatives with interfaces, anon classes
    • #3274: [java] OnlyOneReturn: false negative with anonymous class
    • #3275: [java] UnnecessaryLocalBeforeReturn: false negatives with lambda and anon class
  • java-design
    • #2780: [java] DataClass example from documentation results in false-negative
    • #2987: [java] New Rule: Public and protected static fields must be final
    • #2329: [java] Cognitive complexity rule for Java
  • java-errorprone
    • #3110: [java] Enhance CompareObjectsWithEquals with list of exceptions
    • #3112: [java] Deprecate rule CloneThrowsCloneNotSupportedException
    • #3205: [java] Make CompareObjectWithEquals allow comparing against constants
    • #3248: [java] Documentation is wrong for SingletonClassReturningNewInstance rule
    • #3249: [java] AvoidFieldNameMatchingTypeName: False negative with interfaces
    • #3268: [java] ConstructorCallsOverridableMethod: IndexOutOfBoundsException with annotations
  • java-performance
    • #1438: [java] InsufficientStringBufferDeclaration false positive for initial calculated StringBuilder size
  • javascript
    • #699: [javascript] Update Rhino library to 1.7.13
    • #2081: [javascript] Failing with OutOfMemoryError parsing a Javascript file

API Changes

Deprecated API

External Contributions

Stats

  • 143 commits
  • 53 closed tickets & PRs
  • Days since last release: 34

pmd_releases/6.34.0

3 years ago

24-April-2021 - 6.34.0

The PMD team is pleased to announce PMD 6.34.0.

This is a minor release.

Table Of Contents

New and noteworthy

New rules

Modified rules

  • The Apex rule ApexCRUDViolation does not ignore getters anymore and also flags SOQL/SOSL/DML operations without access permission checks in getters. This will produce false positives now for VF getter methods, but we can't reliably detect, whether a getter is a VF getter or not. In such cases, the violation should be suppressed.

Deprecated rules

Fixed Issues

  • apex-performance
    • #3198: [apex] OperationWithLimitsInLoopRule: Support more limit consuming static method invocations
  • apex-security
    • #3202: [apex] ApexCRUDViolationRule fails to report CRUD violation on COUNT() queries
    • #3210: [apex] ApexCRUDViolationRule false-negative on non-VF getter
  • java-bestpractices
    • #3190: [java] Use StandardCharsets instead of Charset.forName
    • #3224: [java] UnusedAssignment crashes with nested records
  • java-codestyle
    • #3128: [java] New rule UnnecessaryImport, deprecate DuplicateImports, ImportFromSamePackage, UnusedImports
  • java-errorprone
    • #2757: [java] CloseResource: support Lombok's @Cleanup annotation
    • #3169: [java] CheckSkipResult: NPE when using pattern bindings

API Changes

No changes.

External Contributions

  • #3193: [java] New rule: UseStandardCharsets - Andrea Aime
  • #3198: [apex] OperationWithLimitsInLoopRule: Support more limit consuming static method invocations - Jonathan Wiesel
  • #3211: [apex] ApexCRUDViolationRule: Do not assume method is VF getter to avoid CRUD checks - Jonathan Wiesel
  • #3234: [apex] ApexCRUDViolation: COUNT is indeed CRUD checkable since it exposes data (false-negative) - Jonathan Wiesel

Stats

  • 74 commits
  • 18 closed tickets & PRs
  • Days since last release: 27

pmd_releases/6.33.0

3 years ago

27-March-2021 - 6.33.0

The PMD team is pleased to announce PMD 6.33.0.

This is a minor release.

Table Of Contents

New and noteworthy

PLSQL parsing exclusions

The PMD PLSQL parser might not parse every valid PL/SQL code without problems. In order to still use PMD on such files, you can now mark certain lines for exclusion from the parser. More information can be found in the language specific documentation for PLSQL.

Fixed Issues

  • apex-design
    • #3142: [apex] ExcessiveClassLength multiple warning on the same class
  • java
    • #3117: [java] Infinite loop when parsing invalid code nested in lambdas
    • #3145: [java] Parse exception when using "record" as variable name
  • java-bestpractices
    • #3118: [java] UnusedPrivateMethod false positive when passing in lombok.val as argument
    • #3144: [java] GuardLogStatement can have more detailed example
    • #3155: [java] GuardLogStatement: False negative with unguarded method call
    • #3160: [java] MethodReturnsInternalArray does not consider static final fields and fields initialized with empty array
  • java-errorprone
    • #2977: [java] CloseResource: false positive with reassignment detection
    • #3146: [java] InvalidLogMessageFormat detection failing when String.format used
    • #3148: [java] CloseResource false positive with Objects.nonNull
    • #3165: [java] InvalidLogMessageFormat detection failing when String.format used in a variable
  • java-performance
    • #2427: [java] ConsecutiveLiteralAppend false-positive with builder inside lambda
    • #3152: [java] ConsecutiveLiteralAppends and InsufficientStringBufferDeclaration: FP with switch expressions
  • plsql
    • #195: [plsql] Ampersand '&' causes PMD processing error in sql file - Lexical error in file

External Contributions

  • #3161: [plsql] Add support for lexical parameters in SQL*Plus scripts, allow excluding lines which the parser does not understand - Henning von Bargen
  • #3167: [java] Minor typo in quickstart ruleset - Austin Tice

Stats

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

pmd_releases/6.32.0

3 years ago

27-February-2021 - 6.32.0

The PMD team is pleased to announce PMD 6.32.0.

This is a minor release.

Table Of Contents

New and noteworthy

Java 16 Support

This release of PMD brings support for Java 16. PMD supports JEP 394: Pattern Matching for instanceof and JEP 395: Records. Both have been promoted to be a standard language feature of Java 16.

PMD also supports JEP 397: Sealed Classes (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 16-preview:

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

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

Modified Rules

  • The Apex rule ApexDoc has two new properties: reportPrivate and reportProtected. Previously the rule only considered public and global classes, methods, and properties. With these properties, you can verify the existence of ApexDoc comments for private and protected methods as well. By default, these properties are disabled to preserve backwards compatible behavior.

Fixed Issues

  • apex-documentation
    • #3075: [apex] ApexDoc should support private access modifier
  • java
    • #3101: [java] NullPointerException when running PMD under JRE 11
  • java-bestpractices
    • #3132: [java] UnusedImports with static imports on subclasses
  • java-errorprone
    • #2716: [java] CompareObjectsWithEqualsRule: False positive with Enums
    • #3089: [java] CloseResource rule throws exception on spaces in property types
    • #3133: [java] InvalidLogMessageFormat FP with StringFormattedMessage and ParameterizedMessage
  • plsql
    • #3106: [plsql] ParseException while parsing EXECUTE IMMEDIATE 'drop database link ' || linkname;

API Changes

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.

  • The protected or public member of the Java rule AvoidUsingHardCodedIPRule are deprecated and considered to be internal API. They will be removed with PMD 7.

External Contributions

Stats

  • 43 commits
  • 21 closed tickets & PRs
  • Days since last release: 27