--- title: Old Release Notes permalink: pmd_release_notes_old.html --- Previous versions of PMD can be downloaded here: [Releases - pmd/pmd (GitHub)](https://github.com/pmd/pmd/releases) ## 27-September-2024 - 7.6.0 The PMD team is pleased to announce PMD 7.6.0. This is a minor release. ### Table Of Contents * [πŸš€ New and noteworthy](#new-and-noteworthy) * [New Git default branch - "main"](#new-git-default-branch---main) * [πŸ› Fixed Issues](#fixed-issues) * [🚨 API Changes](#api-changes) * [✨ Merged pull requests](#merged-pull-requests) * [πŸ“¦ Dependency updates](#dependency-updates) * [πŸ“ˆ Stats](#stats) ### πŸš€ New and noteworthy #### New Git default branch - "main" We are joining the Git community and updating "master" to "main". Using the term "master" for the main development branch can be offensive to some people. Existing versions of Git have been always capable of working with any branch name and since 2.28.0 (July 2020) the default initial branch is configurable (`init.defaultBranch`). Since October 2020, the default branch for new repositories on GitHub is "main". Finally, PMD will also use this new name for the main branch in all our own repositories. Why "main"? PMD uses a very simple branching model - pull requests with feature branches and one main development branch, from which releases are created. That's why "main" is currently the best fitting name. More information: - - What changes? - We change the default branch on GitHub, so that pull requests are automatically created against `main` from now on. - If you have already a local clone of PMD's repository, you'll need to rename the old master branch locally: ``` git branch --move master main git fetch origin git branch --set-upstream-to=origin/main main git remote set-head origin --auto ``` More info: and - If you created a fork on GitHub, you'll need to change the default branch in your fork to `main` as well (Settings > Default Branch). - Some time after this release, we'll delete the old master branch on GitHub. Then only `main` can be used. - This change is expanded to the other PMD repositories as well, e.g. pmd-designer and pmd-regression-tester. ### πŸ› Fixed Issues * apex * [#5138](https://github.com/pmd/pmd/issues/5138): \[apex] Various false-negatives since 7.3.0 when using triggers (ApexCRUDViolation, CognitiveComplexity, OperationWithLimitsInLoop) * [#5163](https://github.com/pmd/pmd/issues/5163): \[apex] Parser error when using toLabel in SOSL query * [#5182](https://github.com/pmd/pmd/issues/5182): \[apex] Parser error when using GROUPING in a SOQL query * [#5218](https://github.com/pmd/pmd/issues/5218): \[apex] Parser error when using nested subqueries in SOQL * [#5228](https://github.com/pmd/pmd/issues/5228): \[apex] Parser error when using convertCurrency() in SOQL * core * [#5059](https://github.com/pmd/pmd/issues/5059): \[core] xml output doesn't escape CDATA inside its own CDATA * [#5201](https://github.com/pmd/pmd/issues/5201): \[core] PMD sarif schema file points to nonexistent location * [#5222](https://github.com/pmd/pmd/issues/5222): \[core] RuleReference/RuleSetWriter don't handle changed default property values correctly * [#5229](https://github.com/pmd/pmd/issues/5229): \[doc] CLI flag `--show-suppressed` needs to mention xml, html, summaryhtml * java * [#5190](https://github.com/pmd/pmd/issues/5190): \[java] NPE in type inference * java-codestyle * [#5046](https://github.com/pmd/pmd/issues/5046): \[java] LocalVariableCouldBeFinal false positive with try/catch * java-errorprone * [#5068](https://github.com/pmd/pmd/issues/5068): \[java] MissingStaticMethodInNonInstantiatableClass: false positive with builder pattern * [#5207](https://github.com/pmd/pmd/issues/5207): \[java] CheckSkipResult: false positve for a private method `void skip(int)` in a subclass of FilterInputStream ### 🚨 API Changes No changes. ### ✨ Merged pull requests * [#5186](https://github.com/pmd/pmd/pull/5186): \[java] Cleanup things about implicit classes - [ClΓ©ment Fournier](https://github.com/oowekyala) (@oowekyala) * [#5188](https://github.com/pmd/pmd/pull/5188): \[apex] Use new apex-parser 4.2.0 - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5191](https://github.com/pmd/pmd/pull/5191): \[java] Fix #5046 - FPs in LocalVariableCouldBeFinal - [ClΓ©ment Fournier](https://github.com/oowekyala) (@oowekyala) * [#5192](https://github.com/pmd/pmd/pull/5192): \[java] Fix #5190 - NPE in type inference caused by null type - [ClΓ©ment Fournier](https://github.com/oowekyala) (@oowekyala) * [#5195](https://github.com/pmd/pmd/pull/5195): \[apex] Fix various FNs when using triggers - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5202](https://github.com/pmd/pmd/pull/5202): \[core] Sarif format: refer to schemastore.org - [David Schach](https://github.com/dschach) (@dschach) * [#5208](https://github.com/pmd/pmd/pull/5208): \[doc] Added Codety to "Tools / Integrations" - [Tony](https://github.com/random1223) (@random1223) * [#5210](https://github.com/pmd/pmd/pull/5210): \[core] Fix PMD's XMLRenderer to escape CDATA - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5211](https://github.com/pmd/pmd/pull/5211): Change branch master to main - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5212](https://github.com/pmd/pmd/pull/5212): \[java] Adjust signature matching in CheckSkipResultRule - [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5223](https://github.com/pmd/pmd/pull/5223): \[core] Fix RuleReference / RuleSetWriter handling of properties - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5224](https://github.com/pmd/pmd/pull/5224): \[java] Fix #5068: Class incorrectly identified as non-instantiatable - [Lukas GrΓ€f](https://github.com/lukasgraef) (@lukasgraef) * [#5230](https://github.com/pmd/pmd/pull/5230): \[doc] Documentation update for --show-suppressed flag - [David Schach](https://github.com/dschach) (@dschach) * [#5237](https://github.com/pmd/pmd/pull/5237): \[apex] Support convertCurrency() in SOQL/SOSL - [Andreas Dangel](https://github.com/adangel) (@adangel) ### πŸ“¦ Dependency updates * [#5185](https://github.com/pmd/pmd/issues/5185): Bump checkstyle from 10.14.0 to 10.18.1 * [#5187](https://github.com/pmd/pmd/issues/5187): Bump org.apache.maven.plugins:maven-install-plugin from 3.1.1 to 3.1.3 * [#5199](https://github.com/pmd/pmd/issues/5199): Bump org.apache.maven.plugins:maven-deploy-plugin from 3.1.1 to 3.1.3 * [#5216](https://github.com/pmd/pmd/issues/5216): Bump com.github.siom79.japicmp:japicmp-maven-plugin from 0.20.0 to 0.23.0 * [#5226](https://github.com/pmd/pmd/issues/5226): Bump rouge from 4.3.0 to 4.4.0 in the all-gems group across 1 directory * [#5227](https://github.com/pmd/pmd/issues/5227): Bump com.google.code.gson:gson from 2.10.1 to 2.11.0 * [#5232](https://github.com/pmd/pmd/issues/5232): Bump com.google.protobuf:protobuf-java from 3.25.3 to 3.25.5 * [#5233](https://github.com/pmd/pmd/issues/5233): Bump webrick from 1.8.1 to 1.8.2 in /docs ### πŸ“ˆ Stats * 60 commits * 27 closed tickets & PRs * Days since last release: 27 ## 30-August-2024 - 7.5.0 The PMD team is pleased to announce PMD 7.5.0. This is a minor release. ### Table Of Contents * [πŸš€ New: Java 23 Support](#new-java-23-support) * [🌟 New Rules](#new-rules) * [πŸ› Fixed Issues](#fixed-issues) * [🚨 API Changes](#api-changes) * [Deprecations](#deprecations) * [Experimental](#experimental) * [✨ External Contributions](#external-contributions) * [πŸ“¦ Dependency updates](#dependency-updates) * [πŸ“ˆ Stats](#stats) ### πŸš€ New: Java 23 Support This release of PMD brings support for Java 23. There are no new standard language features, but a couple of preview language features: * [JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview)](https://openjdk.org/jeps/455) * [JEP 476: Module Import Declarations (Preview)](https://openjdk.org/jeps/476) * [JEP 477: Implicitly Declared Classes and Instance Main Methods (Third Preview)](https://openjdk.org/jeps/477) * [JEP 482: Flexible Constructor Bodies (Second Preview)](https://openjdk.org/jeps/482) Note that String Templates (introduced as preview in Java 21 and 22) are not supported anymore in Java 23, see [JDK-8329949](https://bugs.openjdk.org/browse/JDK-8329949) for details. 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 `23-preview`: export PMD_JAVA_OPTS=--enable-preview pmd check --use-version java-23-preview ... Note: Support for Java 21 preview language features have been removed. The version "21-preview" are no longer available. ### 🌟 New Rules * The new Java rule [`AvoidSynchronizedStatement`](https://docs.pmd-code.org/pmd-doc-7.5.0/pmd_rules_java_multithreading.html#avoidsynchronizedstatement) finds synchronization blocks that could cause performance issues with virtual threads due to pinning. * The new JavaScript rule [`AvoidConsoleStatements`](https://docs.pmd-code.org/pmd-doc-7.5.0/pmd_rules_ecmascript_performance.html#avoidconsolestatements) finds any function calls on the Console API (e.g. `console.log`). Using these in production code might negatively impact performance. ### πŸ› Fixed Issues * apex-performance * [#5139](https://github.com/pmd/pmd/issues/5139): \[apex] OperationWithHighCostInLoop: false negative for triggers * java * [#5062](https://github.com/pmd/pmd/issues/5062): \[java] Support Java 23 * [#5167](https://github.com/pmd/pmd/issues/5167): \[java] java.lang.IllegalArgumentException: \ cannot be a wildcard bound * java-bestpractices * [#3602](https://github.com/pmd/pmd/issues/3602): \[java] GuardLogStatement: False positive when compile-time constant is created from external constants * [#4731](https://github.com/pmd/pmd/issues/4731): \[java] GuardLogStatement: Documentation is unclear why getters are flagged * [#5145](https://github.com/pmd/pmd/issues/5145): \[java] UnusedPrivateMethod: False positive with method calls inside lambda * [#5151](https://github.com/pmd/pmd/issues/5151): \[java] GuardLogStatement: Should not need to guard parameterized log messages where the replacement arg is a constant from another class * [#5152](https://github.com/pmd/pmd/issues/5152): \[java] GuardLogStatement: Should not need to guard parameterized log messages where the replacement arg is "this" * [#5153](https://github.com/pmd/pmd/issues/5153): \[java] GuardLogStatement: Should not need to guard parameterized log messages where the replacement arg is an array element * java-design * [#5048](https://github.com/pmd/pmd/issues/5084): \[java] CognitiveComplexity: Exception when using Map.of() * [#5162](https://github.com/pmd/pmd/issues/5162): \[java] SingularField: False-positive when preceded by synchronized block * java-multithreading * [#5175](https://github.com/pmd/pmd/issues/5175): \[java] Update AvoidSynchronizedAtMethodLevel message to mention ReentrantLock, new rule AvoidSynchronizedStatement * javascript-performance * [#5105](https://github.com/pmd/pmd/issues/5105): \[javascript] Prohibit any console methods * plsql * [#5125](https://github.com/pmd/pmd/pull/5125): \[plsql] Improve merge statement (order of merge insert/update flexible, allow prefixes in column names) * plsql-bestpractices * [#5132](https://github.com/pmd/pmd/issues/5132): \[plsql] TomKytesDespair: XPathException for more complex exception handler ### 🚨 API Changes #### Deprecations * pmd-jsp * JspParserImpl is deprecated now. It should have been package-private because this is an implementation class that should not be used directly. * pmd-plsql * MergeUpdateClausePrefix is deprecated. This production is not used anymore and will be removed. Note: The whole parser implementation class has been deprecated since 7.3.0, as it is supposed to be internalized. * pmd-velocity * VtlParserImpl is deprecated now. It should have been package-private because this is an implementation class that should not be used directly. * pmd-visualforce * VfParserImpl is deprecated now. It should have been package-private because this is an implementation class that should not be used directly. #### Experimental * pmd-java * Renamed `isUnnamedClass()` to ASTCompilationUnit#isSimpleCompilationUnit * ASTImplicitClassDeclaration * ASTImportDeclaration#isModuleImport * JavaVisitorBase#visit(ASTImplicitClassDeclaration, P) ### ✨ External Contributions * [#5125](https://github.com/pmd/pmd/pull/5125): \[plsql] Improve merge statement (order of merge insert/update flexible, allow prefixes in column names) - [Arjen Duursma](https://github.com/duursma) (@duursma) * [#5175](https://github.com/pmd/pmd/pull/5175): \[java] Update AvoidSynchronizedAtMethodLevel message to mention ReentrantLock, new rule AvoidSynchronizedStatement - [Chas Honton](https://github.com/chonton) (@chonton) ### πŸ“¦ Dependency updates * [#5100](https://github.com/pmd/pmd/issues/5100): Enable Dependabot * [#5141](https://github.com/pmd/pmd/issues/5141): Bump org.apache.maven.plugins:maven-checkstyle-plugin from 3.3.1 to 3.4.0 * [#5142](https://github.com/pmd/pmd/issues/5142): Bump org.apache.maven.plugins:maven-compiler-plugin from 3.12.1 to 3.13.0 * [#5144](https://github.com/pmd/pmd/issues/5144): Bump org.codehaus.mojo:versions-maven-plugin from 2.16.2 to 2.17.1 * [#5148](https://github.com/pmd/pmd/issues/5148): Bump org.apache.commons:commons-text from 1.11.0 to 1.12.0 * [#5149](https://github.com/pmd/pmd/issues/5149): Bump org.apache.maven.plugins:maven-site-plugin from 4.0.0-M13 to 4.0.0-M16 * [#5160](https://github.com/pmd/pmd/issues/5160): Bump org.pcollections:pcollections from 3.2.0 to 4.0.2 * [#5161](https://github.com/pmd/pmd/issues/5161): Bump danger from 9.4.3 to 9.5.0 in the all-gems group across 1 directory * [#5164](https://github.com/pmd/pmd/issues/5164): Bump org.apache.maven.plugins:maven-dependency-plugin from 3.6.1 to 3.7.1 * [#5165](https://github.com/pmd/pmd/issues/5165): Bump the all-gems group across 1 directory with 2 updates * [#5171](https://github.com/pmd/pmd/issues/5171): Bump net.bytebuddy:byte-buddy-agent from 1.14.12 to 1.14.19 * [#5180](https://github.com/pmd/pmd/issues/5180): Bump net.sf.saxon:Saxon-HE from 12.4 to 12.5 ### πŸ“ˆ Stats * 87 commits * 25 closed tickets & PRs * Days since last release: 35 ## 26-July-2024 - 7.4.0 The PMD team is pleased to announce PMD 7.4.0. This is a minor release. ### Table Of Contents * [🌟 New and changed rules](#new-and-changed-rules) * [New Rules](#new-rules) * [Changed rules](#changed-rules) * [Renamed rules](#renamed-rules) * [πŸ› Fixed Issues](#fixed-issues) * [🚨 API Changes](#api-changes) * [✨ External Contributions](#external-contributions) * [πŸ“ˆ Stats](#stats) ### 🌟 New and changed rules #### New Rules * The new Apex rule [`AvoidNonRestrictiveQueries`](https://docs.pmd-code.org/pmd-doc-7.4.0/pmd_rules_apex_performance.html#avoidnonrestrictivequeries) finds SOQL and SOSL queries without a where or limit statement. This can quickly cause governor limit exceptions. #### Changed rules * [`ClassNamingConventions`](https://docs.pmd-code.org/pmd-doc-7.4.0/pmd_rules_apex_codestyle.html#classnamingconventions) (Apex Codestyle): Two new properties to configure different patterns for inner classes and interfaces: `innerClassPattern` and `innerInterfacePattern`. #### Renamed rules * [`InaccurateNumericLiteral`](https://docs.pmd-code.org/pmd-doc-7.4.0/pmd_rules_ecmascript_errorprone.html#inaccuratenumericliteral) (JavaScript Error Prone) has been renamed from `InnaccurateNumericLiteral`. The old rule name still works but is deprecated. ### πŸ› Fixed Issues * apex * [#5094](https://github.com/pmd/pmd/issues/5094): \[apex] "No adapter exists for type" error message printed to stdout instead of stderr * apex-bestpractices * [#5095](https://github.com/pmd/pmd/issues/5095): \[apex] ApexUnitTestShouldNotUseSeeAllDataTrue false negative due to casing (regression in PMD 7) * apex-codestyle * [#4800](https://github.com/pmd/pmd/issues/4800): \[apex] ClassNamingConvention: Support naming convention for *inner* classes * apex-performance * [#635](https://github.com/pmd/pmd/issues/635): \[apex] New Rule: Avoid soql/sosl queries without a where clause or limit statement * java-bestpractices * [#5106](https://github.com/pmd/pmd/issues/5106): \[java] AccessorClassGeneration: Node was null for default constructor * [#5110](https://github.com/pmd/pmd/issues/5110): \[java] UnusedPrivateMethod for method referenced by lombok.Builder.ObtainVia * [#5117](https://github.com/pmd/pmd/issues/5117): \[java] UnusedPrivateMethod for methods annotated with jakarta.annotation.PostConstruct or PreDestroy * java-errorprone * [#1488](https://github.com/pmd/pmd/issues/1488): \[java] MissingStaticMethodInNonInstantiatableClass: False positive with Lombok Builder on Constructor * javascript-errorprone * [#2367](https://github.com/pmd/pmd/issues/2367): \[javascript] InnaccurateNumericLiteral is misspelled * [#4716](https://github.com/pmd/pmd/issues/4716): \[javascript] InaccurateNumericLiteral with number 259200000 * plsql * [#5086](https://github.com/pmd/pmd/pull/5086): \[plsql] Fixed issue with missing optional table alias in MERGE usage * [#5087](https://github.com/pmd/pmd/pull/5087): \[plsql] Add support for SQL_MACRO * [#5088](https://github.com/pmd/pmd/pull/5088): \[plsql] Add support for 'DEFAULT' clause on the arguments of some oracle functions * [#5133](https://github.com/pmd/pmd/issues/5133): \[plsql] AssertionError: Root of the tree should implement RootNode for a PL/SQL type declaration * cli * [#5120](https://github.com/pmd/pmd/issues/5120): \[cli] Can't start designer under Windows * core * [#5091](https://github.com/pmd/pmd/issues/5091): \[core] PMD CPD v7.3.0 gives deprecation warning for skipLexicalErrors even when not used ### 🚨 API Changes * javascript * The old rule name `InnaccurateNumericLiteral` has been deprecated. Use the new name [`InaccurateNumericLiteral`](https://docs.pmd-code.org/pmd-doc-7.4.0/pmd_rules_ecmascript_errorprone.html#inaccuratenumericliteral) instead. ### ✨ External Contributions * [#5048](https://github.com/pmd/pmd/pull/5048): \[apex] Added Inner Classes to Apex Class Naming Conventions Rule - [Justin Stroud](https://github.com/justinstroudbah) (@justinstroudbah / @sgnl-labs) * [#5086](https://github.com/pmd/pmd/pull/5086): \[plsql] Fixed issue with missing optional table alias in MERGE usage - [Arjen Duursma](https://github.com/duursma) (@duursma) * [#5087](https://github.com/pmd/pmd/pull/5087): \[plsql] Add support for SQL_MACRO - [Arjen Duursma](https://github.com/duursma) (@duursma) * [#5088](https://github.com/pmd/pmd/pull/5088): \[plsql] Add support for 'DEFAULT' clause on the arguments of some oracle functions - [Arjen Duursma](https://github.com/duursma) (@duursma) * [#5107](https://github.com/pmd/pmd/pull/5107): \[doc] Update maven.md - Typo fixed for maven target - [karthikaiyasamy](https://github.com/karthikaiyasamy) (@karthikaiyasamy) * [#5109](https://github.com/pmd/pmd/pull/5109): \[java] Exclude constructor with lombok.Builder for MissingStaticMethodInNonInstantiatableClass - [Krzysztof Debski](https://github.com/kdebski85) (@kdebski85) * [#5111](https://github.com/pmd/pmd/pull/5111): \[java] Fix UnusedPrivateMethod for @lombok.Builder.ObtainVia - [Krzysztof Debski](https://github.com/kdebski85) (@kdebski85) * [#5118](https://github.com/pmd/pmd/pull/5118): \[java] FP for UnusedPrivateMethod with Jakarta @PostConstruct/PreDestroy annotations - [Krzysztof Debski](https://github.com/kdebski85) (@kdebski85) * [#5121](https://github.com/pmd/pmd/pull/5121): \[plsql] Fixed issue with missing optional table alias in MERGE usage - [Arjen Duursma](https://github.com/duursma) (@duursma) ### πŸ“ˆ Stats * 81 commits * 32 closed tickets & PRs * Days since last release: 27 ## 28-June-2024 - 7.3.0 The PMD team is pleased to announce PMD 7.3.0. This is a minor release. ### Table Of Contents * [πŸš€ New and noteworthy](#new-and-noteworthy) * [✨ New Rules](#new-rules) * [πŸ’₯ pmd-compat6 removed (breaking)](#pmd-compat6-removed-breaking) * [πŸ› Fixed Issues](#fixed-issues) * [🚨 API Changes](#api-changes) * [CPD Report Format XML](#cpd-report-format-xml) * [CLI](#cli) * [Ant](#ant) * [Deprecated API](#deprecated-api) * [Breaking changes: pmd-compat6 removed](#breaking-changes-pmd-compat6-removed) * [πŸ“ˆ Stats](#stats) ### πŸš€ New and noteworthy #### ✨ New Rules * The new Java rule [`UseEnumCollections`](https://docs.pmd-code.org/pmd-doc-7.3.0/pmd_rules_java_bestpractices.html#useenumcollections) reports usages for `HashSet` and `HashMap` when the keys are of an enum type. The specialized enum collections are more space- and time-efficient. #### πŸ’₯ pmd-compat6 removed (breaking) The already deprecated PMD 6 compatibility module (pmd-compat6) has been removed. It was intended to be used with older versions of the maven-pmd-plugin, but since maven-pmd-plugin 3.22.0, PMD 7 is supported directly and this module is not needed anymore. If you currently use this dependency (`net.sourceforge.pmd:pmd-compat6`), remove it and upgrade maven-pmd-plugin to the latest version (3.23.0 or newer). See also [Maven PMD Plugin](https://docs.pmd-code.org/pmd-doc-7.3.0/pmd_userdocs_tools_maven.html). ### πŸ› Fixed Issues * cli * [#2827](https://github.com/pmd/pmd/issues/2827): \[cli] Consider processing errors in exit status * core * [#4396](https://github.com/pmd/pmd/issues/4396): \[core] CPD is always case sensitive * [#4992](https://github.com/pmd/pmd/pull/4992): \[core] CPD: Include processing errors in XML report * [#5066](https://github.com/pmd/pmd/issues/5066): \[core] CPD throws java.lang.OutOfMemoryError: Java heap space (since 7.1.0) * apex * [#4922](https://github.com/pmd/pmd/issues/4922): \[apex] SOQL syntax error with TYPEOF in sub-query * [#5053](https://github.com/pmd/pmd/issues/5053): \[apex] CPD fails to parse string literals with escaped characters * [#5055](https://github.com/pmd/pmd/issues/5055): \[apex] SOSL syntax error with WITH USER_MODE or WITH SYSTEM_MODE * apex-bestpractices * [#5000](https://github.com/pmd/pmd/issues/5000): \[apex] UnusedLocalVariable FP with binds in SOSL / SOQL * java * [#4885](https://github.com/pmd/pmd/issues/4885): \[java] AssertionError: Method should be accessible * [#5050](https://github.com/pmd/pmd/issues/5050): \[java] Problems with pattern variables in switch branches * java-bestpractices * [#577](https://github.com/pmd/pmd/issues/577): \[java] New Rule: Check that Map is an EnumMap if K is an enum value * [#5047](https://github.com/pmd/pmd/issues/5047): \[java] UnusedPrivateMethod FP for Generics & Overloads * plsql * [#1934](https://github.com/pmd/pmd/issues/1934): \[plsql] ParseException with MERGE statement in anonymous block * [#2779](https://github.com/pmd/pmd/issues/2779): \[plsql] Error while parsing statement with (Oracle) DML Error Logging * [#4270](https://github.com/pmd/pmd/issues/4270): \[plsql] Parsing exception COMPOUND TRIGGER with EXCEPTION handler ### 🚨 API Changes #### CPD Report Format XML There are some important changes: 1. The XML format will now use an XSD schema, that is available at . This schema defines the valid elements and attributes that one can expect from a CPD report. 2. The root element `pmd-cpd` contains the new attributes `pmdVersion`, `timestamp` and `version`. The latter is the schema version and is currently "1.0.0". 3. The CPD XML report will now also contain recoverable errors as additional `` elements. See [Report formats for CPD](pmd_userdocs_cpd_report_formats.html#xml) for an example. The XML format should be compatible as only attributes and elements have been added. However, if you parse the document with a namespace aware parser, you might encounter some issues like no elements being found. In case the new format doesn't work for you (e.g. namespaces, unexpected error elements), you can go back using the old format with the renderer "xmlold" (XMLOldRenderer). Note, that this old renderer is deprecated and only there for compatibility reasons. Whatever tooling is used to read the XML format should be updated. #### CLI * New exit code 5 introduced. PMD and CPD will exit now by default with exit code 5, if any recoverable error (e.g. parsing exception, lexing exception or rule exception) occurred. PMD will still create a report with all detected violations or duplications if recoverable errors occurred. Such errors mean, that the report might be incomplete, as either violations or duplications for an entire file or for a specific rule are missing. These cases can be considered as false-negatives. In any case, the root cause should be investigated. If it's a problem in PMD itself, please create a bug report. * New CLI parameter `--no-fail-on-error` to ignore such errors and not exit with code 5. By default, a build with errors will now fail and with that parameter, the previous behavior can be restored. This parameter is available for both PMD and CPD. * The CLI parameter `--skip-lexical-errors` is deprecated. By default, lexical errors are skipped but the build is failed. Use the new parameter `--[no-]fail-on-error` instead to control whether to fail the build or not. #### Ant * CPDTask has a new parameter `failOnError`. It controls, whether to fail the build if any recoverable error occurred. By default, the build will fail. CPD will still create a report with all detected duplications, but the report might be incomplete. * The parameter `skipLexicalError` in CPDTask is deprecated and ignored. Lexical errors are now always skipped. Use the new parameter `failOnError` instead to control whether to fail the build or not. #### Deprecated API * pmd-ant * CPDTask#setSkipLexicalErrors: Use setFailOnError instead to control, whether to ignore errors or fail the build. * pmd-core * CPDConfiguration#isSkipLexicalErrors and setSkipLexicalErrors: Use setFailOnError to control whether to ignore errors or fail the build. * net.sourceforge.pmd.cpd.XMLOldRenderer (the CPD format "xmlold"). * The constructor AntlrToken#AntlrToken shouldn't be used directly. Use AntlrTokenManager instead. * pmd-java * ASTResource#getStableName and the corresponding attribute `@StableName`. * ASTRecordPattern#getVarId This method was added here by mistake. Record patterns don't declare a pattern variable for the whole pattern, but rather for individual record components, which can be accessed via getComponentPatterns. * pmd-plsql * PLSQLParserImpl is deprecated now. It should have been package-private because this is an implementation class that should not be used directly. * The node ASTKEYWORD_UNRESERVED is deprecated and is now removed from the AST. #### Breaking changes: pmd-compat6 removed The already deprecated PMD 6 compatibility module (pmd-compat6) has been removed. See above for details. ### πŸ“ˆ Stats * 88 commits * 32 closed tickets & PRs * Days since last release: 27 ## 31-May-2024 - 7.2.0 The PMD team is pleased to announce PMD 7.2.0. This is a minor release. ### Table Of Contents * [πŸš€ New and noteworthy](#new-and-noteworthy) * [Collections exposed as XPath attributes](#collections-exposed-as-xpath-attributes) * [Updated PMD Designer](#updated-pmd-designer) * [πŸ› Fixed Issues](#fixed-issues) * [🚨 API Changes](#api-changes) * [Deprecated API](#deprecated-api) * [✨ External Contributions](#external-contributions) * [πŸ“ˆ Stats](#stats) ### πŸš€ New and noteworthy #### Collections exposed as XPath attributes Up to now, all AST node getters would be exposed to XPath, as long as the return type was a primitive (boxed or unboxed), String or Enum. That meant that collections, even of these basic types, were not exposed, so for instance accessing Apex's `ASTUserClass.getInterfaceNames()` to list the interfaces implemented by a class was impossible from XPath, and would require writing a Java rule to check it. Since this release, PMD will also expose any getter returning a collection of any supported type as a sequence through an XPath attribute. They would require to use apropriate XQuery functions to manipulate the sequence. So for instance, to detect any given `ASTUserClass` in Apex that implements `Queueable`, it is now possible to write: ```xml /UserClass[@InterfaceNames = 'Queueable'] ``` #### Updated PMD Designer This PMD release ships a new version of the pmd-designer. For the changes, see [PMD Designer Changelog (7.2.0)](https://github.com/pmd/pmd-designer/releases/tag/7.2.0). ### πŸ› Fixed Issues * core * [#4467](https://github.com/pmd/pmd/issues/4467): \[core] Expose collections from getters as XPath sequence attributes * [#4978](https://github.com/pmd/pmd/issues/4978): \[core] Referenced Rulesets do not emit details on validation errors * [#4983](https://github.com/pmd/pmd/pull/4983): \[cpd] Fix CPD crashes about unicode escapes * [#5009](https://github.com/pmd/pmd/issues/5009): \[core] Kotest tests aren't picked up by surefire * java * [#4912](https://github.com/pmd/pmd/issues/4912): \[java] Unable to parse some Java9+ resource references * [#4973](https://github.com/pmd/pmd/pull/4973): \[java] Stop parsing Java for CPD * [#4980](https://github.com/pmd/pmd/issues/4980): \[java] Bad intersection, unrelated class types java.lang.Object\[] and java.lang.Number * [#4988](https://github.com/pmd/pmd/pull/4988): \[java] Fix impl of ASTVariableId::isResourceDeclaration / VariableId/@ResourceDeclaration * [#4990](https://github.com/pmd/pmd/issues/4990): \[java] Add an attribute @PackageQualifier to ASTClassType * [#5006](https://github.com/pmd/pmd/issues/5006): \[java] Bad intersection, unrelated class types Child and Parent * [#5029](https://github.com/pmd/pmd/issues/5029): \[java] PMD 7.x throws stack overflow in TypeOps$ProjectionVisitor while parsing a Java class * java-bestpractices * [#4278](https://github.com/pmd/pmd/issues/4278): \[java] UnusedPrivateMethod FP with Junit 5 @MethodSource and default factory method name * [#4852](https://github.com/pmd/pmd/issues/4852): \[java] ReplaceVectorWithList false-positive (neither Vector nor List usage) * [#4975](https://github.com/pmd/pmd/issues/4975): \[java] UnusedPrivateMethod false positive when using @MethodSource on a @Nested test * [#4985](https://github.com/pmd/pmd/issues/4985): \[java] UnusedPrivateMethod false-positive / method reference in combination with custom object * java-codestyle * [#1619](https://github.com/pmd/pmd/issues/1619): \[java] LocalVariableCouldBeFinal on 'size' variable in for loop * [#3122](https://github.com/pmd/pmd/issues/3122): \[java] LocalVariableCouldBeFinal should consider blank local variables * [#4903](https://github.com/pmd/pmd/issues/4903): \[java] UnnecessaryBoxing, but explicit conversion is necessary * [#4924](https://github.com/pmd/pmd/issues/4924): \[java] UnnecessaryBoxing false positive in PMD 7.0.0 in lambda * [#4930](https://github.com/pmd/pmd/issues/4930): \[java] EmptyControlStatement should not allow empty try with concise resources * [#4954](https://github.com/pmd/pmd/issues/4954): \[java] LocalVariableNamingConventions should allow unnamed variables by default * [#5028](https://github.com/pmd/pmd/issues/5028): \[java] FormalParameterNamingConventions should accept unnamed parameters by default * java-errorprone * [#4042](https://github.com/pmd/pmd/issues/4042): \[java] A false negative about the rule StringBufferInstantiationWithChar * [#5007](https://github.com/pmd/pmd/issues/5007): \[java] AvoidUsingOctalValues triggers on non-octal double literals with a leading 0 * java-multithreading * [#2368](https://github.com/pmd/pmd/issues/2368): \[java] False positive UnsynchronizedStaticFormatter in static initializer ### 🚨 API Changes #### Deprecated API * pmd-java * ASTResource#getStableName and the corresponding attribute `@StableName` ### ✨ External Contributions * [#5020](https://github.com/pmd/pmd/issues/5020): \[java] Fix AvoidUsingOctalValues false-positive - [Gold856](https://github.com/Gold856) (@Gold856) ### πŸ“ˆ Stats * 152 commits * 46 closed tickets & PRs * Days since last release: 35 ## 26-April-2024 - 7.1.0 The PMD team is pleased to announce PMD 7.1.0. This is a minor release. ### Table Of Contents * [πŸš€ New and noteworthy](#new-and-noteworthy) * [More robust CPD reports](#more-robust-cpd-reports) * [✨ New Rules](#new-rules) * [🌟 Rule Changes](#rule-changes) * [πŸ› Fixed Issues](#fixed-issues) * [🚨 API Changes](#api-changes) * [Deprecated methods](#deprecated-methods) * [✨ External Contributions](#external-contributions) * [πŸ“ˆ Stats](#stats) ### πŸš€ New and noteworthy #### More robust CPD reports There were a number of circumstances, specially around (but not limited to) literal sequences, were CPD would report duplicate overlapping or partially overlapping matches. These have now been fixed, and CPD will report only the longest non-overlapping duplicate. These improvements apply to all supported languages, irrespective of supported flags. #### ✨ New Rules - The new Java rule [`UnnecessaryVarargsArrayCreation`](https://docs.pmd-code.org/pmd-doc-7.1.0/pmd_rules_java_bestpractices.html#unnecessaryvarargsarraycreation) reports explicit array creation when a varargs is expected. This is more heavy to read and could be simplified. - The new Java rule [`ConfusingArgumentToVarargsMethod`](https://docs.pmd-code.org/pmd-doc-7.1.0/pmd_rules_java_errorprone.html#confusingargumenttovarargsmethod) reports some confusing situations where a varargs method is called with an inexact argument type. These may end up in a mismatch between the expected parameter type and the actual value. - The new Java rule [`LambdaCanBeMethodReference`](https://docs.pmd-code.org/pmd-doc-7.1.0/pmd_rules_java_codestyle.html#lambdacanbemethodreference) reports lambda expressions that can be replaced with a method reference. Please read the documentation of the rule for more info. This rule is now part of the Quickstart ruleset. #### 🌟 Rule Changes * [`JUnitTestsShouldIncludeAssert`](https://docs.pmd-code.org/pmd-doc-7.1.0/pmd_rules_java_bestpractices.html#junittestsshouldincludeassert) and [`JUnitTestContainsTooManyAsserts`](https://docs.pmd-code.org/pmd-doc-7.1.0/pmd_rules_java_bestpractices.html#junittestcontainstoomanyasserts) have a new property named `extraAssertMethodNames`. With this property, you can configure which additional static methods should be considered as valid verification methods. This allows to use custom mocking or assertion libraries. ### πŸ› Fixed Issues * core * [#494](https://github.com/pmd/pmd/issues/494): \[core] Adopt JApiCmp to enforce control over API changes * [#4942](https://github.com/pmd/pmd/issues/4942): \[core] CPD: `--skip-duplicate-files` has no effect (7.0.0 regression) * [#4959](https://github.com/pmd/pmd/pull/4959): \[core] Upgrade saxon to 12.4 * cli * [#4791](https://github.com/pmd/pmd/issues/4791): \[cli] Could not find or load main class * [#4913](https://github.com/pmd/pmd/issues/4913): \[cli] cpd-gui closes immediately * doc * [#4901](https://github.com/pmd/pmd/issues/4901): \[doc] Improve documentation on usage of violationSuppressXPath * apex * [#4418](https://github.com/pmd/pmd/issues/4418): \[apex] ASTAnnotation.getImage() does not return value as written in the class * apex-errorprone * [#3953](https://github.com/pmd/pmd/issues/3953): \[apex] EmptyCatchBlock false positive with formal (doc) comments * cpp * [#2438](https://github.com/pmd/pmd/issues/2438): \[cpp] Repeated Duplication blocks * java * [#4899](https://github.com/pmd/pmd/issues/4899): \[java] Parsing failed in ParseLock#doParse() java.io.IOException: Stream closed * [#4902](https://github.com/pmd/pmd/issues/4902): \[java] "Bad intersection, unrelated class types" for Constable\[] and Enum\[] * [#4947](https://github.com/pmd/pmd/issues/4947): \[java] Broken TextBlock parser * java-bestpractices * [#1084](https://github.com/pmd/pmd/issues/1084): \[java] Allow JUnitTestsShouldIncludeAssert to configure verification methods * [#3216](https://github.com/pmd/pmd/issues/3216): \[java] New rule: UnnecessaryVarargsArrayCreation * [#4435](https://github.com/pmd/pmd/issues/4435): \[java] \[7.0-rc1] UnusedAssignment for used field * [#4569](https://github.com/pmd/pmd/issues/4569): \[java] ForLoopCanBeForeach reports on loop `for (int i = 0; i < list.size(); i += 2)` * [#4618](https://github.com/pmd/pmd/issues/4618): \[java] UnusedAssignment false positive with conditional assignments of fields * java-codestyle * [#4602](https://github.com/pmd/pmd/issues/4602): \[java] UnnecessaryImport: false positives with static imports * [#4785](https://github.com/pmd/pmd/issues/4785): \[java] False Positive: PMD Incorrectly report violation for UnnecessaryImport * [#4779](https://github.com/pmd/pmd/issues/4779): \[java] Examples in documentation of MethodArgumentCanBeFinal do not trigger the rule * [#4881](https://github.com/pmd/pmd/issues/4881): \[java] ClassNamingConventions: interfaces are identified as abstract classes (regression in 7.0.0) * java-design * [#2440](https://github.com/pmd/pmd/issues/2440): \[java] FinalFieldCouldBeStatic FN when the right side of the assignment is a constant expression * [#3694](https://github.com/pmd/pmd/issues/3694): \[java] SingularField ignores static variables * [#4873](https://github.com/pmd/pmd/issues/4873): \[java] AvoidCatchingGenericException: Can no longer suppress on the exception itself * java-errorprone * [#2056](https://github.com/pmd/pmd/issues/2056): \[java] CloseResource false-positive with URLClassLoader in cast expression * [#4751](https://github.com/pmd/pmd/issues/4751): \[java] PMD crashes when analyzing CloseResource Rule * [#4928](https://github.com/pmd/pmd/issues/4928): \[java] EmptyCatchBlock false negative when allowCommentedBlocks=true * [#4948](https://github.com/pmd/pmd/issues/4948): \[java] ImplicitSwitchFallThrough: False-positive with nested switch statements * java-performance * [#3845](https://github.com/pmd/pmd/issues/3845): \[java] InsufficientStringBufferDeclaration should consider literal expression * [#4874](https://github.com/pmd/pmd/issues/4874): \[java] StringInstantiation: False-positive when using `new String(charArray)` * [#4886](https://github.com/pmd/pmd/issues/4886): \[java] BigIntegerInstantiation: False Positive with Java 17 and BigDecimal.TWO * pom-errorprone * [#4388](https://github.com/pmd/pmd/issues/4388): \[pom] InvalidDependencyTypes doesn't consider dependencies at all * misc * [#4967](https://github.com/pmd/pmd/pull/4967): Fix reproducible build issues with 7.0.0 ### 🚨 API Changes #### Deprecated methods * pmd-java * ASTLambdaExpression#getBlock and ASTLambdaExpression#getExpression * SingularFieldRule#mayBeSingular has been deprecated for removal. The method is only useful for the rule itself and shouldn't be used otherwise. ### ✨ External Contributions * [#4864](https://github.com/pmd/pmd/pull/4864): Fix #1084 \[Java] add extra assert method names to Junit rules - [Erwan Moutymbo](https://github.com/emouty) (@emouty) * [#4894](https://github.com/pmd/pmd/pull/4894): Fix #4791 Error caused by space in JDK path - [Scrates1](https://github.com/Scrates1) (@Scrates1) ### πŸ“ˆ Stats * 205 commits * 71 closed tickets & PRs * Days since last release: 34 ## 22-March-2024 - 7.0.0 πŸŽ‰ After a long time, we're excited to bring you now the next major version of PMD! πŸŽ‰ Since this is a big release, we provide here only a concise version of the release notes. We prepared a separate page with the full [Detailed Release Notes for PMD 7.0.0](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_release_notes_pmd7.html). πŸ€πŸ™ Many thanks to all users and contributors who were testing the release candidates and provided feedback and/or PRs! ✨ PMD 7... * ...has a new logo * ...analyzes Java 21 and Java 22 projects with even better type resolution and symbol table support * ...analyzes Kotlin and Swift * ...analyzes Apex with a new parser * ...finds duplicated code in Coco, Julia, TypeScript * ...ships 11 new rules and tons of improvements for existing rules * ...provides a new CLI interface with progress bar * ...supports Antlr based languages * ...and many more enhancements πŸ’₯ Note: Since PMD 7 is a major release, it is not a drop-in replacement for PMD 6.55.0. A detailed documentation of required changes are available in the [Migration Guide for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_userdocs_migrating_to_pmd7.html).
Expand to see Release Notes ### Table Of Contents * [Changes since 7.0.0-rc4](#changes-since-700-rc4) * [New and Noteworthy](#new-and-noteworthy) * [Maven PMD Plugin compatibility with PMD 7](#maven-pmd-plugin-compatibility-with-pmd-7) * [Java 22 Support](#java-22-support) * [Swift Support](#swift-support) * [Groovy Support (CPD)](#groovy-support-cpd) * [Updated PMD Designer](#updated-pmd-designer) * [Apex Support: Replaced Jorje with fully open source front-end](#apex-support-replaced-jorje-with-fully-open-source-front-end) * [Changed: Visualforce](#changed-visualforce) * [Changed: HTML support](#changed-html-support) * [Changed: Kotlin support](#changed-kotlin-support) * [Changed: Velocity Template Language (VTL)](#changed-velocity-template-language-vtl) * [Rule Changes](#rule-changes) * [Fixed issues](#fixed-issues) * [API Changes](#api-changes) * [External Contributions](#external-contributions) * [πŸš€ Major Features and Enhancements](#major-features-and-enhancements) * [New official logo](#new-official-logo) * [Revamped Java module](#revamped-java-module) * [Revamped Command Line Interface](#revamped-command-line-interface) * [Full Antlr support](#full-antlr-support) * [Updated PMD Designer](#updated-pmd-designer) * [New CPD report format cpdhtml-v2.xslt](#new-cpd-report-format-cpdhtml-v2xslt) * [πŸŽ‰ Language Related Changes](#language-related-changes) * [New: CPD support for Apache Velocity Template Language (VTL)](#new-cpd-support-for-apache-velocity-template-language-vtl) * [New: CPD support for Coco](#new-cpd-support-for-coco) * [New: CPD support for Julia](#new-cpd-support-for-julia) * [New: CPD support for TypeScript](#new-cpd-support-for-typescript) * [New: Java 21 and 22 Support](#new-java-21-and-22-support) * [New: Kotlin support](#new-kotlin-support) * [New: Swift support](#new-swift-support) * [Changed: Apex Support: Replaced Jorje with fully open source front-end](#changed-apex-support-replaced-jorje-with-fully-open-source-front-end) * [Changed: CPP can now ignore identifiers in sequences (CPD)](#changed-cpp-can-now-ignore-identifiers-in-sequences-cpd) * [Changed: Groovy Support (CPD)](#changed-groovy-support-cpd) * [Changed: HTML support](#changed-html-support) * [Changed: JavaScript support](#changed-javascript-support) * [Changed: Language versions](#changed-language-versions) * [Changed: Rule properties](#changed-rule-properties) * [Changed: Velocity Template Language (VTL)](#changed-velocity-template-language-vtl) * [Changed: Visualforce](#changed-visualforce) * [🌟 New and changed rules](#new-and-changed-rules) * [New Rules](#new-rules) * [Other changes](#other-changes) * [🚨 API](#api) * [πŸ’₯ Compatibility and migration notes](#compatibility-and-migration-notes) * [πŸ› Fixed Issues](#fixed-issues) * [✨ External Contributions](#external-contributions) * [πŸ“ˆ Stats](#stats) ### Changes since 7.0.0-rc4 This section lists the most important changes from the last release candidate. The remaining section describes the complete release notes for 7.0.0. #### New and Noteworthy ##### Maven PMD Plugin compatibility with PMD 7 In order to use PMD 7 with [maven-pmd-plugin](https://maven.apache.org/plugins/maven-pmd-plugin/) a new compatibility module has been created. This allows to use PMD 7 by simply adding one additional dependency: 1. Follow the guide [Upgrading PMD at Runtime](https://maven.apache.org/plugins/maven-pmd-plugin/examples/upgrading-PMD-at-runtime.html) 2. Add additionally the following dependency: ```xml net.sourceforge.pmd pmd-compat6 ${pmdVersion} ``` It is important to add this dependency as the **first** in the list, so that maven-pmd-plugin sees the (old) compatible versions of some classes. This module is available beginning with version 7.0.0-rc4 and will be there at least for the first final version PMD 7 (7.0.0). It's not decided yet, whether we will keep updating it, after PMD 7 is finally released. Note: This compatibility module only works for the built-in rules, that are still available in PMD 7. E.g. you need to review your rulesets and look out for deprecated rules and such. See the use case [I'm using only built-in rules](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_userdocs_migrating_to_pmd7.html#im-using-only-built-in-rules) in the [Migration Guide for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_userdocs_migrating_to_pmd7.html). As PMD 7 revamped the Java module, if you have custom rules, you need to migrate these rules. See the use case [I'm using custom rules](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_userdocs_migrating_to_pmd7.html#im-using-custom-rules) in the Migration Guide. Note: Once the default version of PMD is upgraded to PMD7 in maven-pmd-plugin (see [MPMD-379](https://issues.apache.org/jira/projects/MPMD/issues/MPMD-379)), this compatibility module is no longer needed. The module pmd-compat6 might not be maintained then any further, hence it is already declared as deprecated. No guarantee is given, that the (deprecated) module pmd-compat6 is being maintained over the whole lifetime of PMD 7. ##### Java 22 Support This release of PMD brings support for Java 22. There are the following new standard language features, that are supported now: * [JEP 456: Unnamed Variables & Patterns](https://openjdk.org/jeps/456) PMD also supports the following preview language features: * [JEP 447: Statements before super(...) (Preview)](https://openjdk.org/jeps/447) * [JEP 459: String Templates (Second Preview)](https://openjdk.org/jeps/459) * [JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview)](https://openjdk.org/jeps/463) 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 `22-preview`: export PMD_JAVA_OPTS=--enable-preview pmd check --use-version java-22-preview ... Note: Support for Java 20 preview language features have been removed. The version "20-preview" is no longer available. ##### Swift Support * limited support for Swift 5.9 (Macro Expansions) ##### Groovy Support (CPD) * We now support parsing all Groovy features from Groovy 3 and 4. * We now support [suppression](pmd_userdocs_cpd.html#suppression) through `CPD-ON`/`CPD-OFF` comment pairs. * See [PR #4726](https://github.com/pmd/pmd/pull/4726) for details. ##### 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 [PMD Designer Changelog (7.0.0)](https://github.com/pmd/pmd-designer/releases/tag/7.0.0). ##### 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](https://github.com/forcedotcom/salesforcedx-vscode), 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: * [apex-parser](https://github.com/apex-dev-tools/apex-parser) originally by [Kevin Jones](https://github.com/nawforce) (@nawforce). This project provides the grammar for a ANTLR based parser. * [Summit-AST](https://github.com/google/summit-ast) by [Google](https://github.com/google) (@google) This project translates the ANTLR parse tree into an AST, that is similar to the AST Jorje provided. Note: This is not an official Google product. Although the parser is completely switched, there are only little known changes to the AST. These are documented in the [Migration Guide for PMD 7: Apex AST](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_userdocs_migrating_to_pmd7.html#apex-ast). With the new Apex parser, the new language constructs like [User Mode Database Operations](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_enforce_usermode.htm) and the new [Null Coalescing Operator `??`](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_NullCoalescingOperator.htm) can be parsed now. PMD should be able to parse Apex code up to version 60.0 (Spring '24). See [#3766](https://github.com/pmd/pmd/issues/3766) for details. Contributors: [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google), [Edward Klimoshenko](https://github.com/eklimo) (@eklimo) ##### 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. * `category/vf/security.xml` ➑️ `category/visualforce/security.xml` ##### 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: Kotlin support Support for Kotlin was introduced with PMD 7.0.0-rc1 as an experimental feature. With PMD 7.0.0 this is now considered stable. ##### 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. * `category/vm/...` ➑️ `category/velocity/...` #### Rule Changes **New Rules** * [`OperationWithHighCostInLoop`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_apex_performance.html#operationwithhighcostinloop) finds Schema class methods called in a loop, which is a potential performance issue. * [`UseExplicitTypes`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_codestyle.html#useexplicittypes) reports usages of `var` keyword, which was introduced with Java 10. * [`MissingEncoding`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_xml_bestpractices.html#missingencoding) finds XML files without explicit encoding. **Changed Rules** * [`EmptyControlStatement`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_codestyle.html#emptycontrolstatement): The rule has a new property to allow empty blocks when they contain a comment (`allowCommentedBlocks`). * [`MethodNamingConventions`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_apex_codestyle.html#methodnamingconventions): The deprecated rule property `skipTestMethodUnderscores` has been removed. It was actually deprecated since PMD 6.15.0, but was not mentioned in the release notes back then. Use the property `testPattern` instead to configure valid names for test methods. * [`CommentRequired`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_documentation.html#commentrequired): The deprecated property `headerCommentRequirement` has been removed. Use the property `classCommentRequirement` instead. * [`NonSerializableClass`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_errorprone.html#nonserializableclass): The deprecated property `prefix` has been removed without replacement. In a serializable class all fields have to be serializable regardless of the name. **Renamed Rulesets** * `category/vf/security.xml` ➑️ `category/visualforce/security.xml` * `category/vm/bestpractices.xml` ➑️ `category/velocity/bestpractices.xml` * `category/vm/design.xml` ➑️ `category/velocity/design.xml` * `category/vm/errorprone.xml` ➑️ `category/velocity/errorprone.xml` **Removed Rules** The following previously deprecated rules have been finally removed: * Apex * performance.xml/AvoidSoqlInLoops (deleted) ➑️ use [`OperationWithLimitsInLoop`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_apex_performance.html#operationwithlimitsinloop) * performance.xml/AvoidSoslInLoops (deleted) ➑️ use [`OperationWithLimitsInLoop`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_apex_performance.html#operationwithlimitsinloop) * performance.xml/AvoidDmlStatementsInLoops (deleted) ➑️ use [`OperationWithLimitsInLoop`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_apex_performance.html#operationwithlimitsinloop) * Java * design.xml/ExcessiveClassLength (deleted) ➑️ use [`NcssCount`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_design.html#ncsscount) * design.xml/ExcessiveMethodLength (deleted) ➑️ use [`NcssCount`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_design.html#ncsscount) * errorprone.xml/BeanMembersShouldSerialize (deleted) ➑️ use [`NonSerializableClass`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_errorprone.html#nonserializableclass) * errorprone.xml/EmptyFinallyBlock (deleted) ➑️ use [`EmptyControlStatement`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_codestyle.html#emptycontrolstatement) * errorprone.xml/EmptyIfStmt (deleted) ➑️ use [`EmptyControlStatement`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_codestyle.html#emptycontrolstatement) * errorprone.xml/EmptyInitializer (deleted) ➑️ use [`EmptyControlStatement`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_codestyle.html#emptycontrolstatement) * errorprone.xml/EmptyStatementBlock (deleted) ➑️ use [`EmptyControlStatement`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_codestyle.html#emptycontrolstatement) * errorprone.xml/EmptyStatementNotInLoop (deleted) ➑️ use [`UnnecessarySemicolon`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_codestyle.html#unnecessarysemicolon) * errorprone.xml/EmptySwitchStatements (deleted) ➑️ use [`EmptyControlStatement`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_codestyle.html#emptycontrolstatement) * errorprone.xml/EmptySynchronizedBlock (deleted) ➑️ use [`EmptyControlStatement`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_codestyle.html#emptycontrolstatement) * errorprone.xml/EmptyTryBlock (deleted) ➑️ use [`EmptyControlStatement`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_codestyle.html#emptycontrolstatement) * errorprone.xml/EmptyWhileStmt (deleted) ➑️ use [`EmptyControlStatement`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_codestyle.html#emptycontrolstatement) **Removed deprecated 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.
List of deprecated rulesets * rulesets/apex/apexunit.xml * rulesets/apex/braces.xml * rulesets/apex/complexity.xml * rulesets/apex/empty.xml * rulesets/apex/metrics.xml * rulesets/apex/performance.xml * rulesets/apex/ruleset.xml * rulesets/apex/securty.xml * rulesets/apex/style.xml * rulesets/java/android.xml * rulesets/java/basic.xml * rulesets/java/clone.xml * rulesets/java/codesize.xml * rulesets/java/comments.xml * rulesets/java/controversial.xml * rulesets/java/coupling.xml * rulesets/java/design.xml * rulesets/java/empty.xml * rulesets/java/finalizers.xml * rulesets/java/imports.xml * rulesets/java/j2ee.xml * rulesets/java/javabeans.xml * rulesets/java/junit.xml * rulesets/java/logging-jakarta-commons.xml * rulesets/java/logging-java.xml * rulesets/java/metrics.xml * rulesets/java/migrating.xml * rulesets/java/migrating_to_13.xml * rulesets/java/migrating_to_14.xml * rulesets/java/migrating_to_15.xml * rulesets/java/migrating_to_junit4.xml * rulesets/java/naming.xml * rulesets/java/optimizations.xml * rulesets/java/strictexception.xml * rulesets/java/strings.xml * rulesets/java/sunsecure.xml * rulesets/java/typeresolution.xml * rulesets/java/unnecessary.xml * rulesets/java/unusedcode.xml * rulesets/ecmascript/basic.xml * rulesets/ecmascript/braces.xml * rulesets/ecmascript/controversial.xml * rulesets/ecmascript/unnecessary.xml * rulesets/jsp/basic.xml * rulesets/jsp/basic-jsf.xml * rulesets/plsql/codesize.xml * rulesets/plsql/dates.xml * rulesets/plsql/strictsyntax.xml * rulesets/plsql/TomKytesDespair.xml * rulesets/vf/security.xml * rulesets/vm/basic.xml * rulesets/pom/basic.xml * rulesets/xml/basic.xml * rulesets/xsl/xpath.xml * rulesets/releases/*
#### Fixed issues * cli * [#4594](https://github.com/pmd/pmd/pull/4594): \[cli] Change completion generation to runtime * [#4685](https://github.com/pmd/pmd/pull/4685): \[cli] Clarify CPD documentation, fix positional parameter handling * [#4723](https://github.com/pmd/pmd/issues/4723): \[cli] Launch fails for "bash pmd" * core * [#1027](https://github.com/pmd/pmd/issues/1027): \[core] Apply the new PropertyDescriptor<Pattern> type where applicable * [#3903](https://github.com/pmd/pmd/issues/3903): \[core] Consolidate `n.s.pmd.reporting` package * [#3905](https://github.com/pmd/pmd/issues/3905): \[core] Stabilize tree export API * [#3917](https://github.com/pmd/pmd/issues/3917): \[core] Consolidate `n.s.pmd.lang.rule` package * [#4065](https://github.com/pmd/pmd/issues/4065): \[core] Rename TokenMgrError to LexException, Tokenizer to CpdLexer * [#4309](https://github.com/pmd/pmd/issues/4309): \[core] Cleanups in XPath area * [#4312](https://github.com/pmd/pmd/issues/4312): \[core] Remove unnecessary property `color` and system property `pmd.color` in `TextColorRenderer` * [#4313](https://github.com/pmd/pmd/issues/4313): \[core] Remove support for <lang>-<ruleset> hyphen notation for ruleset references * [#4314](https://github.com/pmd/pmd/issues/4314): \[core] Remove ruleset compatibility filter (RuleSetFactoryCompatibility) and CLI option `--no-ruleset-compatibility` * [#4348](https://github.com/pmd/pmd/issues/4348): \[core] Consolidate @InternalApi classes * [#4349](https://github.com/pmd/pmd/issues/4349): \[core] Cleanup remaining experimental and deprecated API * [#4378](https://github.com/pmd/pmd/issues/4378): \[core] Ruleset loading processes commented rules * [#4674](https://github.com/pmd/pmd/issues/4674): \[core] WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass * [#4694](https://github.com/pmd/pmd/pull/4694): \[core] Fix line/col numbers in TokenMgrError * [#4717](https://github.com/pmd/pmd/issues/4717): \[core] XSLTRenderer doesn't close report file * [#4750](https://github.com/pmd/pmd/pull/4750): \[core] Fix flaky SummaryHTMLRenderer * [#4782](https://github.com/pmd/pmd/pull/4782): \[core] Avoid using getImage/@Image * doc * [#995](https://github.com/pmd/pmd/issues/995): \[doc] Document API evolution principles as ADR * [#2511](https://github.com/pmd/pmd/issues/2511): \[doc] Review guides for writing java/xpath rules for correctness with PMD 7 * [#3175](https://github.com/pmd/pmd/issues/3175): \[doc] Document language module features * [#4308](https://github.com/pmd/pmd/issues/4308): \[doc] Document XPath API @DeprecatedAttribute * [#4319](https://github.com/pmd/pmd/issues/4319): \[doc] Document TypeRes API and Symbols API * [#4659](https://github.com/pmd/pmd/pull/4659): \[doc] Improve ant documentation * [#4669](https://github.com/pmd/pmd/pull/4669): \[doc] Add bld PMD Extension to Tools / Integrations * [#4676](https://github.com/pmd/pmd/issues/4676): \[doc] Clarify how CPD `--ignore-literals` and `--ignore-identifiers` work * [#4704](https://github.com/pmd/pmd/issues/4704): \[doc] Multivalued properties do not accept \| as a separator * miscellaneous * [#4699](https://github.com/pmd/pmd/pull/4699): Make PMD buildable with java 21 * [#4586](https://github.com/pmd/pmd/pull/4586): Use explicit encoding in ruleset xml files * [#4642](https://github.com/pmd/pmd/issues/4642): Update regression tests with Java 21 language features * [#4736](https://github.com/pmd/pmd/issues/4736): \[ci] Improve build procedure * [#4741](https://github.com/pmd/pmd/pull/4741): Add pmd-compat6 module for maven-pmd-plugin * [#4749](https://github.com/pmd/pmd/pull/4749): Fixes NoSuchMethodError on processing errors in pmd-compat6 * [#4776](https://github.com/pmd/pmd/issues/4776): \[ci] Upgrade to ruby 3 * [#4796](https://github.com/pmd/pmd/pull/4796): Remove deprecated and release rulesets * [#4823](https://github.com/pmd/pmd/pull/4823): Update to use renamed pmd-designer * [#4827](https://github.com/pmd/pmd/pull/4827): \[compat6] Support config errors and cpd for csharp * [#4830](https://github.com/pmd/pmd/issues/4830): Consolidate packages in each maven module * [#4867](https://github.com/pmd/pmd/issues/4867): \[dist] ./mvnw command not found in dist-src * apex * [#3766](https://github.com/pmd/pmd/issues/3766): \[apex] Replace Jorje with fully open source front-end * [#4828](https://github.com/pmd/pmd/issues/4828): \[apex] Support null coalescing operator ?? (apex 60) * [#4845](https://github.com/pmd/pmd/issues/4845): \[apex] Use same ANLTR version for apex-parser * apex-bestpractices * [#4556](https://github.com/pmd/pmd/issues/4556): \[apex] UnusedLocalVariable flags for variables which are using in SOQL/SOSL binds * apex-documentation * [#4774](https://github.com/pmd/pmd/issues/4774): \[apex] ApexDoc false-positive for the first method of an annotated Apex class * apex-performance * [#4675](https://github.com/pmd/pmd/issues/4675): \[apex] New Rule: OperationWithHighCostInLoop * groovy * [#4726](https://github.com/pmd/pmd/pull/4726): \[groovy] Support Groovy to 3 and 4 and CPD suppressions * java * [#1307](https://github.com/pmd/pmd/issues/1307): \[java] AccessNode API changes * [#3751](https://github.com/pmd/pmd/issues/3751): \[java] Rename some node types * [#4628](https://github.com/pmd/pmd/pull/4628): \[java] Support loading classes from java runtime images * [#4753](https://github.com/pmd/pmd/issues/4753): \[java] PMD crashes while using generics and wildcards * [#4757](https://github.com/pmd/pmd/issues/4757): \[java] Intermittent NPEs while analyzing Java code * [#4794](https://github.com/pmd/pmd/issues/4794): \[java] Support JDK 22 * java-bestpractices * [#4603](https://github.com/pmd/pmd/issues/4603): \[java] UnusedAssignment false positive in record compact constructor * [#4625](https://github.com/pmd/pmd/issues/4625): \[java] UnusedPrivateMethod false positive: Autoboxing into Number * [#4817](https://github.com/pmd/pmd/issues/4817): \[java] UnusedPrivateMethod false-positive used in lambda * java-codestyle * [#2847](https://github.com/pmd/pmd/issues/2847): \[java] New Rule: Use Explicit Types * [#4239](https://github.com/pmd/pmd/issues/4239): \[java] UnnecessaryLocalBeforeReturn - false positive with catch clause * [#4578](https://github.com/pmd/pmd/issues/4578): \[java] CommentDefaultAccessModifier comment needs to be before annotation if present * [#4631](https://github.com/pmd/pmd/issues/4631): \[java] UnnecessaryFullyQualifiedName fails to recognize illegal self reference in enums * [#4645](https://github.com/pmd/pmd/issues/4645): \[java] CommentDefaultAccessModifier - False Positive with JUnit5's ParameterizedTest * [#4754](https://github.com/pmd/pmd/pull/4754): \[java] EmptyControlStatementRule: Add allowCommentedBlocks property * [#4816](https://github.com/pmd/pmd/issues/4816): \[java] UnnecessaryImport false-positive on generic method call with on lambda * java-design * [#174](https://github.com/pmd/pmd/issues/174): \[java] SingularField false positive with switch in method that both assigns and reads field * java-errorprone * [#718](https://github.com/pmd/pmd/issues/718): \[java] BrokenNullCheck false positive with parameter/field confusion * [#932](https://github.com/pmd/pmd/issues/932): \[java] SingletonClassReturningNewInstance false positive with double assignment * [#1831](https://github.com/pmd/pmd/issues/1831): \[java] DetachedTestCase reports abstract methods * [#4719](https://github.com/pmd/pmd/pull/4719): \[java] UnnecessaryCaseChange: example doc toUpperCase() should compare to a capitalized string * javascript * [#2305](https://github.com/pmd/pmd/issues/2305): \[javascript] UnnecessaryBlock - false positives with destructuring assignments * [#4673](https://github.com/pmd/pmd/pull/4673): \[javascript] CPD: Added support for decorator notation * plsql * [#4820](https://github.com/pmd/pmd/issues/4820): \[plsql] WITH clause is ignored for SELECT INTO statements * swift * [#4697](https://github.com/pmd/pmd/issues/4697): \[swift] Support Swift 5.9 features (mainly macros expansion expressions) * xml-bestpractices * [#4592](https://github.com/pmd/pmd/pull/4592): \[xml] Add MissingEncoding rule #### API Changes See [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_release_notes_pmd7.html#700). #### External Contributions * [#4093](https://github.com/pmd/pmd/pull/4093): \[apex] Summit-AST Apex module - Part 1 - [Edward Klimoshenko](https://github.com/eklimo) (@eklimo) * [#4151](https://github.com/pmd/pmd/pull/4151): \[apex] Summit-AST Apex module - Part 2 - expression nodes - [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google) * [#4171](https://github.com/pmd/pmd/pull/4171): \[apex] Summit-AST Apex module - Part 3 - initializers - [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google) * [#4206](https://github.com/pmd/pmd/pull/4206): \[apex] Summit-AST Apex module - Part 4 - statements - [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google) * [#4219](https://github.com/pmd/pmd/pull/4219): \[apex] Summit-AST Apex module - Part 5 - annotations, triggers, misc. - [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google) * [#4242](https://github.com/pmd/pmd/pull/4242): \[apex] Merge 6.52 into experimental-apex-parser - [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google) * [#4251](https://github.com/pmd/pmd/pull/4251): \[apex] Summit-AST Apex module - Part 6 Passing testsuite - [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google) * [#4448](https://github.com/pmd/pmd/pull/4448): \[apex] Bump summit-ast to new release 2.1.0 (and remove workaround) - [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google) * [#4479](https://github.com/pmd/pmd/pull/4479): \[apex] Merge main (7.x) branch into experimental-apex-parser and fix tests - [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google) * [#4562](https://github.com/pmd/pmd/pull/4562): \[apex] Fixes #4556 - Update Apex bind regex match for all possible combinations - [nwcm](https://github.com/nwcm) (@nwcm) * [#4640](https://github.com/pmd/pmd/pull/4640): \[cli] Launch script fails if run via "bash pmd" - [Shai Bennathan](https://github.com/shai-bennathan) (@shai-bennathan) * [#4673](https://github.com/pmd/pmd/pull/4673): \[javascript] CPD: Added support for decorator notation - [Wener](https://github.com/wener-tiobe) (@wener-tiobe) * [#4677](https://github.com/pmd/pmd/pull/4677): \[apex] Add new rule: OperationWithHighCostInLoop - [Thomas Prouvot](https://github.com/tprouvot) (@tprouvot) * [#4698](https://github.com/pmd/pmd/pull/4698): \[swift] Add macro expansion support for swift 5.9 - [Richard B.](https://github.com/kenji21) (@kenji21) * [#4706](https://github.com/pmd/pmd/pull/4706): \[java] DetachedTestCase should not report on abstract methods - [Debamoy Datta](https://github.com/Debamoy) (@Debamoy) * [#4719](https://github.com/pmd/pmd/pull/4719): \[java] UnnecessaryCaseChange: example doc toUpperCase() should compare to a capitalized string - [ciufudean](https://github.com/ciufudean) (@ciufudean) * [#4738](https://github.com/pmd/pmd/pull/4738): \[doc] Added reference to the PMD extension for bld - [Erik C. Thauvin](https://github.com/ethauvin) (@ethauvin) * [#4749](https://github.com/pmd/pmd/pull/4749): Fixes NoSuchMethodError on processing errors in pmd-compat6 - [Andreas Bergander](https://github.com/bergander) (@bergander) * [#4750](https://github.com/pmd/pmd/pull/4750): \[core] Fix flaky SummaryHTMLRenderer - [219sansim](https://github.com/219sansim) (@219sansim) * [#4752](https://github.com/pmd/pmd/pull/4752): \[core] Fix flaky LatticeRelationTest - [219sansim](https://github.com/219sansim) (@219sansim) * [#4754](https://github.com/pmd/pmd/pull/4754): \[java] EmptyControlStatementRule: Add allowCommentedBlocks property - [Andreas Bergander](https://github.com/bergander) (@bergander) * [#4759](https://github.com/pmd/pmd/pull/4759): \[java] fix: remove delimiter attribute from ruleset category/java/errorprone.xml - [Marcin DΔ…browski](https://github.com/marcindabrowski) (@marcindabrowski) * [#4825](https://github.com/pmd/pmd/pull/4825): \[plsql] Fix ignored WITH clause for SELECT INTO statements - [Laurent Bovet](https://github.com/lbovet) (@lbovet) * [#4857](https://github.com/pmd/pmd/pull/4857): \[javascript] Fix UnnecessaryBlock issues with empty statements - [Oleksandr Shvets](https://github.com/oleksandr-shvets) (@oleksandr-shvets) ### πŸš€ Major Features and Enhancements #### New official logo The new official logo of PMD: ![New PMD Logo](https://docs.pmd-code.org/pmd-doc-7.0.0/images/logo/pmd-logo-300px.png) For more information, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_release_notes_pmd7.html#new-official-logo). #### Revamped Java module * Java grammar substantially refactored - more correct regarding the Java Language Specification (JLS) * Built-in rules have been upgraded for the changed AST * Rewritten type resolution framework and symbol table correctly implements the JLS * AST exposes more semantic information (method calls, field accesses) For more information, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_release_notes_pmd7.html#revamped-java). Contributors: [ClΓ©ment Fournier](https://github.com/oowekyala) (@oowekyala), [Andreas Dangel](https://github.com/adangel) (@adangel), [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) #### Revamped Command Line Interface * Unified and consistent Command Line Interface for both Linux/Unix and Windows across our different utilities * Single script `pmd` (`pmd.bat` for Windows) to launch the different utilities: * `pmd check` to run PMD rules and analyze a project * `pmd cpd` to run CPD (copy paste detector) * `pmd designer` to run the PMD Rule Designer * Progress bar support for `pmd check` * Shell completion ![Demo](https://docs.pmd-code.org/pmd-doc-7.0.0/images/userdocs/pmd-demo.gif) For more information, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_release_notes_pmd7.html#revamped-command-line-interface). Contributors: [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) #### Full Antlr support * [Antlr](https://www.antlr.org/) based grammars can now be used to build full-fledged PMD rules. * Previously, Antlr grammar could only be used for CPD * New supported languages: Swift and Kotlin For more information, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_release_notes_pmd7.html#full-antlr-support). Contributors: [Lucas Soncini](https://github.com/lsoncini) (@lsoncini), [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga), [TomΓ‘s De Lucca](https://github.com/tomidelucca) (@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 * [PMD Designer Changelog (7.0.0)](https://github.com/pmd/pmd-designer/releases/tag/7.0.0). * [PMD Designer Changelog (7.0.0-rc4)](https://github.com/pmd/pmd-designer/releases/tag/7.0.0-rc4). * [PMD Designer Changelog (7.0.0-rc1)](https://github.com/pmd/pmd-designer/releases/tag/7.0.0-rc1). #### 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](https://docs.pmd-code.org/pmd-doc-7.0.0/report-examples/cpdhtml-v2.html). Contributors: [Mohan Chinnappan](https://github.com/mohan-chinnappan-n) (@mohan-chinnappan-n) ### πŸŽ‰ Language Related Changes Note that this is just a concise listing of the highlights. For more information on the languages, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_release_notes_pmd7.html#-language-related-changes). #### 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](https://github.com/wener-tiobe) (@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](https://github.com/wener-tiobe) (@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](https://github.com/pguyot) (@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: * [JEP 456: Unnamed Variables & Patterns](https://openjdk.org/jeps/456) (Java 22) * [JEP 440: Record Patterns](https://openjdk.org/jeps/440) (Java 21) * [JEP 441: Pattern Matching for switch](https://openjdk.org/jeps/441) (Java 21) PMD also supports the following preview language features: * [JEP 447: Statements before super(...) (Preview)](https://openjdk.org/jeps/447) (Java 22) * [JEP 459: String Templates (Second Preview)](https://openjdk.org/jeps/459) (Java 21 and 22) * [JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview)](https://openjdk.org/jeps/463) (Java 21 and 22) 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 * Use PMD to analyze Kotlin code with PMD rules. * Support for Kotlin 1.8 grammar * Initially 2 built-in rules * Support for Kotlin was introduced with PMD 7.0.0-rc1 as an experimental feature. With PMD 7.0.0 this is now considered stable. Contributors: [Jeroen Borgers](https://github.com/jborgers) (@jborgers), [Peter Paul Bakker](https://github.com/stokpop) (@stokpop) #### New: Swift support * Use PMD to analyze Swift code with PMD rules. * Limited support for Swift 5.9 (Macro Expansions) * Initially 4 built-in rules Contributors: [Lucas Soncini](https://github.com/lsoncini) (@lsoncini), [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga), [TomΓ‘s De Lucca](https://github.com/tomidelucca) (@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](https://github.com/forcedotcom/salesforcedx-vscode), 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: * [apex-parser](https://github.com/nawforce/apex-parser) by [Kevin Jones](https://github.com/nawforce) (@nawforce) This project provides the grammar for a ANTLR based parser. * [Summit-AST](https://github.com/google/summit-ast) by [Google](https://github.com/google) (@google) This project translates the ANTLR parse tree into an AST, that is similar to the AST Jorje provided. Note: This is not an official Google product. 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](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_userdocs_migrating_to_pmd7.html#apex-ast). With the new Apex parser, the new language constructs like [User Mode Database Operations](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_enforce_usermode.htm) and the new [Null Coalescing Operator `??`](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_NullCoalescingOperator.htm) can be parsed now. PMD should be able to parse Apex code up to version 60.0 (Spring '24). See [#3766](https://github.com/pmd/pmd/issues/3766) for details. Contributors: [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google), [Edward Klimoshenko](https://github.com/eklimo) (@eklimo) #### Changed: CPP can now ignore identifiers in sequences (CPD) * New command line option for CPD: `--ignore-sequences`. * This option is used for CPP only: with the already existing option `--ignore-literal-sequences`, only literals were ignored. The new option additionally ignores identifiers as well in sequences. * See [PR #4470](https://github.com/pmd/pmd/pull/4470) for details. Contributors: [Wener](https://github.com/wener-tiobe) (@wener-tiobe) #### Changed: Groovy Support (CPD) * We now support parsing all Groovy features from Groovy 3 and 4. * We now support [suppression](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_userdocs_cpd.html#suppression) through `CPD-ON`/`CPD-OFF` comment pairs. * See [PR #4726](https://github.com/pmd/pmd/pull/4726) for details. Contributors: [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) #### 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 * Latest version supports ES6 and also some new constructs (see [Rhino](https://github.com/mozilla/rhino)) * Comments are retained #### Changed: Language versions * More predefined language versions for each supported language * Can be used to limit rule execution for specific versions only with `minimumLanguageVersion` and `maximumLanguageVersion` attributes. #### Changed: Rule properties * The old deprecated classes like `IntProperty` and `StringProperty` have been removed. Please use PropertyFactory to create properties. * All properties which accept multiple values now use a comma (`,`) as a delimiter. The previous default was a pipe character (`|`). The delimiter is not configurable anymore. If needed, the comma can be escaped with a backslash. * The `min` and `max` attributes in property definitions in the XML are now optional and can appear separately or be omitted. #### 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. * `category/vm/...` ➑️ `category/velocity/...` #### 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. * `category/vf/security.xml` ➑️ `category/visualforce/security.xml` ### 🌟 New and changed rules #### New Rules **Apex** * [`OperationWithHighCostInLoop`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_apex_performance.html#operationwithhighcostinloop) finds Schema class methods called in a loop, which is a potential performance issue. * [`UnusedMethod`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_apex_design.html#unusedmethod) finds unused methods in your code. **Java** * [`UnnecessaryBoxing`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_codestyle.html#unnecessaryboxing) reports boxing and unboxing conversions that may be made implicit. * [`UseExplicitTypes`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_java_codestyle.html#useexplicittypes) reports usages of `var` keyword, which was introduced with Java 10. **Kotlin** * [`FunctionNameTooShort`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_kotlin_bestpractices.html#functionnametooshort) finds functions with a too short name. * [`OverrideBothEqualsAndHashcode`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_kotlin_errorprone.html#overridebothequalsandhashcode) finds classes with only either `equals` or `hashCode` overridden, but not both. This leads to unexpected behavior once instances of such classes are used in collections (Lists, HashMaps, ...). **Swift** * [`ForceCast`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_swift_errorprone.html#forcecast) flags all force casts, making sure you are defensively considering all types. Having the application crash shouldn't be an option. * [`ForceTry`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_swift_errorprone.html#forcetry) flags all force tries, making sure you are defensively handling exceptions. Having the application crash shouldn't be an option. * [`ProhibitedInterfaceBuilder`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_swift_bestpractices.html#prohibitedinterfacebuilder) flags any usage of interface builder. Interface builder files are prone to merge conflicts, and are impossible to code review, so larger teams usually try to avoid it or reduce its usage. * [`UnavailableFunction`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_swift_bestpractices.html#unavailablefunction) flags any function throwing a `fatalError` not marked as `@available(*, unavailable)` to ensure no calls are actually performed in the codebase. **XML** * [`MissingEncoding`](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_rules_xml_bestpractices.html#missingencoding) finds XML files without explicit encoding. #### Other changes The information about changed rules, removed rules and rulesets can be found in the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_release_notes_pmd7.html#-new-and-changed-rules). ### 🚨 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. Also, there are some improvement and changes in different areas. For the detailed description of the changes listed here, see [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_release_notes_pmd7.html#-api). * Miscellaneous smaller changes and cleanups * XPath 3.1 support for XPath-based rules * Node stream API for AST traversal * Metrics framework * Testing framework * Language Lifecycle and Language Properties * Rule Properties * New Programmatic API for CPD ### πŸ’₯ Compatibility and migration notes A detailed documentation of required changes are available in the [Migration Guide for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_userdocs_migrating_to_pmd7.html). See also [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_release_notes_pmd7.html#-compatibility-and-migration-notes). ### πŸ› Fixed Issues More than 300 issues have been fixed in PMD 7. See [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_release_notes_pmd7.html#-fixed-issues) for the complete list of fixed issues. ### ✨ External Contributions Many thanks to the following contributors: @219sansim, @aaronhurst-google, @anastasiia-koba, @AndreyBozhko, @bergander, @ciufudean, @cyw3, @dague1, @Debamoy, @eklimo, @ethauvin, @JerritEic, @joaodinissf, @kenji21, @krdabrowski, @lbovet, @lsoncini, @LynnBroe, @marcindabrowski, @matifraga, @mohan-chinnappan-n, @mohui1999, @nawforce, @nirvikpatel, @nwcm, @oleksandr-shvets, @pguyot, @PimvanderLoos, @rcorfieldffdc, @sfdcsteve, @shai-bennathan, @tomidelucca, @tprouvot, @wener-tiobe. See [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_release_notes_pmd7.html#-external-contributions) for the full list of PRs. ### πŸ“ˆ Stats * 5741 commits * 849 closed tickets & PRs * Days since last release (6.55.0): 390 * Days since last release (7.0.0-rc4): 173
## 30-September-2023 - 7.0.0-rc4 We're excited to bring you the next major version of PMD! Since this is a big release, we provide here only a concise version of the release notes. We prepared a separate page with the full [Detailed Release Notes for PMD 7.0.0](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_release_notes_pmd7.html).
ℹ️ Release Candidates

PMD 7.0.0 is finally almost ready. In order to gather feedback, we are going to ship a couple of release candidates. These are officially available on GitHub and Maven Central and can be used as usual (e.g. as a dependency). We encourage you to try out the new features, but keep in mind that we may introduce API breaking changes between the release candidates. It should be stable enough if you don't use custom rules.

We have still some tasks planned for the next release candidates. You can see the progress in PMD 7 Tracking Issue #3898.

If you find any problem or difficulty while updating from PMD 6, please provide feedback via our issue tracker. That way we can improve the experience for all.

### Table Of Contents * [Changes since 7.0.0-rc3](#changes-since-7.0.0-rc3) * [New and Noteworthy](#new-and-noteworthy) * [Migration Guide for PMD 7](#migration-guide-for-pmd-7) * [Apex Jorje Updated](#apex-jorje-updated) * [Java 21 Support](#java-21-support) * [Fixed issues](#fixed-issues) * [API Changes](#api-changes) * [pmd-java](#pmd-java) * [Rule properties](#rule-properties) * [New Programmatic API for CPD](#new-programmatic-api-for-cpd) * [Removed classes and methods](#removed-classes-and-methods) * [Moved packages](#moved-packages) * [Changed types and other changes](#changed-types-and-other-changes) * [Internal APIs](#internal-apis) * [Deprecated API](#deprecated-api) * [Experimental APIs](#experimental-apis) * [External Contributions](#external-contributions) * [πŸš€ Major Features and Enhancements](#πŸš€-major-features-and-enhancements) * [New official logo](#new-official-logo) * [Revamped Java module](#revamped-java-module) * [Revamped Command Line Interface](#revamped-command-line-interface) * [Full Antlr support](#full-antlr-support) * [Updated PMD Designer](#updated-pmd-designer) * [New CPD report format cpdhtml-v2.xslt](#new-cpd-report-format-cpdhtml-v2.xslt) * [πŸŽ‰ Language Related Changes](#πŸŽ‰-language-related-changes) * [New: Swift support](#new:-swift-support) * [New: Kotlin support (experimental)](#new:-kotlin-support-(experimental)) * [New: CPD support for TypeScript](#new:-cpd-support-for-typescript) * [New: CPD support for Julia](#new:-cpd-support-for-julia) * [New: CPD support for Coco](#new:-cpd-support-for-coco) * [New: Java 21 Support](#new:-java-21-support) * [Changed: JavaScript support](#changed:-javascript-support) * [Changed: Language versions](#changed:-language-versions) * [Changed: CPP can now ignore identifiers in sequences (CPD)](#changed:-cpp-can-now-ignore-identifiers-in-sequences-(cpd)) * [Changed: Apex Jorje Updated](#changed:-apex-jorje-updated) * [Changed: Rule properties](#changed:-rule-properties) * [🌟 New and changed rules](#🌟-new-and-changed-rules) * [New Rules](#new-rules) * [Changed Rules](#changed-rules) * [Removed Rules](#removed-rules) * [🚨 API](#🚨-api) * [πŸ’₯ Compatibility and migration notes](#πŸ’₯-compatibility-and-migration-notes) * [πŸ› Fixed Issues](#πŸ›-fixed-issues) * [✨ External Contributions](#✨-external-contributions) * [πŸ“ˆ Stats](#πŸ“ˆ-stats) ### Changes since 7.0.0-rc3 This section lists the most important changes from the last release candidate. The remaining section describes the complete release notes for 7.0.0. #### New and Noteworthy ##### Migration Guide for PMD 7 A detailed documentation of required changes are available in the [Migration Guide for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_userdocs_migrating_to_pmd7.html). ##### Apex Jorje Updated With the new version of Apex Jorje, the new language constructs like User Mode Database Operations can be parsed now. PMD should now be able to parse Apex code up to version 59.0 (Winter '23). ##### Java 21 Support This release of PMD brings support for Java 21. There are the following new standard language features, that are supported now: * [JEP 440: Record Patterns](https://openjdk.org/jeps/440) * [JEP 441: Pattern Matching for switch](https://openjdk.org/jeps/441) PMD also supports the following preview language features: * [JEP 430: String Templates (Preview)](https://openjdk.org/jeps/430) * [JEP 443: Unnamed Patterns and Variables (Preview)](https://openjdk.org/jeps/443) * [JEP 445: Unnamed Classes and Instance Main Methods (Preview)](https://openjdk.org/jeps/445) 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 `21-preview`: export PMD_JAVA_OPTS=--enable-preview pmd check --use-version java-21-preview ... Note: Support for Java 19 preview language features have been removed. The version "19-preview" is no longer available. #### Fixed issues * miscellaneous * [#4582](https://github.com/pmd/pmd/issues/4582): \[dist] Download link broken * [#4691](https://github.com/pmd/pmd/issues/4691): \[CVEs] Critical and High CEVs reported on PMD and PMD dependencies * core * [#1204](https://github.com/pmd/pmd/issues/1204): \[core] Allow numeric properties in XML to be within an unbounded range * [#3919](https://github.com/pmd/pmd/issues/3919): \[core] Merge CPD and PMD language * [#4204](https://github.com/pmd/pmd/issues/4204): \[core] Provide a CpdAnalysis class as a programmatic entry point into CPD * [#4301](https://github.com/pmd/pmd/issues/4301): \[core] Remove deprecated property concrete classes * [#4302](https://github.com/pmd/pmd/issues/4302): \[core] Migrate Property Framework API to Java 8 * [#4323](https://github.com/pmd/pmd/issues/4323): \[core] Refactor CPD integration * [#4397](https://github.com/pmd/pmd/pull/4397): \[core] Refactor CPD * [#4611](https://github.com/pmd/pmd/pull/4611): \[core] Fix loading language properties from env vars * [#4621](https://github.com/pmd/pmd/issues/4621): \[core] Make `ClasspathClassLoader::getResource` child first * cli * [#4423](https://github.com/pmd/pmd/pull/4423): \[cli] Fix NPE when only `--file-list` is specified * doc * [#4294](https://github.com/pmd/pmd/issues/4294): \[doc] Migration Guide for upgrading PMD 6 ➑️ 7 * [#4303](https://github.com/pmd/pmd/issues/4303): \[doc] Document new property framework * [#4521](https://github.com/pmd/pmd/issues/4521): \[doc] Website is not mobile friendly * apex * [#3973](https://github.com/pmd/pmd/issues/3973): \[apex] Update parser to support new 'as user' keywords (User Mode for Database Operations) * [#4453](https://github.com/pmd/pmd/issues/4453): \[apex] \[7.0-rc1] Exception while initializing Apexlink (Index 34812 out of bounds for length 34812) * apex-design * [#4596](https://github.com/pmd/pmd/issues/4596): \[apex] ExcessivePublicCount ignores properties * apex-security * [#4646](https://github.com/pmd/pmd/issues/4646): \[apex] ApexSOQLInjection does not recognise SObjectType or SObjectField as safe variable types * java * [#4401](https://github.com/pmd/pmd/issues/4401): \[java] PMD 7 fails to build under Java 19 * [#4583](https://github.com/pmd/pmd/issues/4583): \[java] Support JDK 21 (LTS) * java-bestpractices * [#4634](https://github.com/pmd/pmd/issues/4634): \[java] JUnit4TestShouldUseTestAnnotation false positive with TestNG #### API Changes ##### pmd-java * Support for Java 19 preview language features have been removed. The version "19-preview" is no longer available. ##### Rule properties * The old deprecated classes like `IntProperty` and `StringProperty` have been removed. Please use PropertyFactory to create properties. * All properties which accept multiple values now use a comma (`,`) as a delimiter. The previous default was a pipe character (`|`). The delimiter is not configurable anymore. If needed, the comma can be escaped with a backslash. * The `min` and `max` attributes in property definitions in the XML are now optional and can appear separately or be omitted. ##### New Programmatic API for CPD See [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_release_notes_pmd7.html#new-programmatic-api-for-cpd) and [PR #4397](https://github.com/pmd/pmd/pull/4397) for details. ##### Removed classes and methods The following previously deprecated classes have been removed: * pmd-core * `net.sourceforge.pmd.cpd.AbstractTokenizer` ➑️ use AnyTokenizer instead * `net.sourceforge.pmd.cpd.CPD` ➑️ use PmdCli from `pmd-cli` module for CLI support or use CpdAnalysis for programmatic API * `net.sourceforge.pmd.cpd.GridBagHelper` (now package private) * `net.sourceforge.pmd.cpd.TokenEntry.State` * `net.sourceforge.pmd.lang.document.CpdCompat` * `net.sourceforge.pmd.properties.BooleanMultiProperty` * `net.sourceforge.pmd.properties.BooleanProperty` * `net.sourceforge.pmd.properties.CharacterMultiProperty` * `net.sourceforge.pmd.properties.CharacterProperty` * `net.sourceforge.pmd.properties.DoubleMultiProperty` * `net.sourceforge.pmd.properties.DoubleProperty` * `net.sourceforge.pmd.properties.EnumeratedMultiProperty` * `net.sourceforge.pmd.properties.EnumeratedProperty` * `net.sourceforge.pmd.properties.EnumeratedPropertyDescriptor` * `net.sourceforge.pmd.properties.FileProperty` (note: without replacement) * `net.sourceforge.pmd.properties.FloatMultiProperty` * `net.sourceforge.pmd.properties.FloatProperty` * `net.sourceforge.pmd.properties.IntegerMultiProperty` * `net.sourceforge.pmd.properties.IntegerProperty` * `net.sourceforge.pmd.properties.LongMultiProperty` * `net.sourceforge.pmd.properties.LongProperty` * `net.sourceforge.pmd.properties.MultiValuePropertyDescriptor` * `net.sourceforge.pmd.properties.NumericPropertyDescriptor` * `net.sourceforge.pmd.properties.PropertyDescriptorField` * `net.sourceforge.pmd.properties.RegexProperty` * `net.sourceforge.pmd.properties.SingleValuePropertyDescriptor` * `net.sourceforge.pmd.properties.StringMultiProperty` * `net.sourceforge.pmd.properties.StringProperty` * `net.sourceforge.pmd.properties.ValueParser` * `net.sourceforge.pmd.properties.ValueParserConstants` * `net.sourceforge.pmd.properties.builders.MultiNumericPropertyBuilder` * `net.sourceforge.pmd.properties.builders.MultiPackagedPropertyBuilder` * `net.sourceforge.pmd.properties.builders.MultiValuePropertyBuilder` * `net.sourceforge.pmd.properties.builders.PropertyDescriptorBuilder` * `net.sourceforge.pmd.properties.builders.PropertyDescriptorBuilderConversionWrapper` * `net.sourceforge.pmd.properties.builders.PropertyDescriptorExternalBuilder` * `net.sourceforge.pmd.properties.builders.SingleNumericPropertyBuilder` * `net.sourceforge.pmd.properties.builders.SinglePackagedPropertyBuilder` * `net.sourceforge.pmd.properties.builders.SingleValuePropertyBuilder` * `net.sourceforge.pmd.properties.modules.EnumeratedPropertyModule` * `net.sourceforge.pmd.properties.modules.NumericPropertyModule` The following previously deprecated methods have been removed: * pmd-core * `net.sourceforge.pmd.properties.PropertyBuilder.GenericCollectionPropertyBuilder#delim(char)` * `net.sourceforge.pmd.properties.PropertySource#setProperty(...)` * `net.sourceforge.pmd.properties.internal.PropertyTypeId#factoryFor(...)` * `net.sourceforge.pmd.properties.internal.PropertyTypeId#typeIdFor(...)` * `net.sourceforge.pmd.properties.PropertyDescriptor`: removed methods errorFor, type, isMultiValue, uiOrder, compareTo, isDefinedExternally, valueFrom, asDelimitedString The following methods have been removed: * pmd-core * CPDConfiguration * `#sourceCodeFor(File)`, `#postConstruct()`, `#tokenizer()`, `#filenameFilter()` removed * Mark * `#getSourceSlice()`, `#setLineCount(int)`, `#getLineCount()`, `#setSourceCode(SourceCode)` removed * `#getBeginColumn()`, `#getBeginLine()`, `#getEndLine()`, `#getEndColumn()` removed ➑️ use getLocation instead * Match * `#LABEL_COMPARATOR` removed * `#setMarkSet(...)`, `#setLabel(...)`, `#getLabel()`, `#addTokenEntry(...)` removed * `#getSourceCodeSlice()` removed ➑️ use CPDReport#getSourceCodeSlice instead * TokenEntry * `#getEOF()`, `#clearImages()`, `#getIdentifier()`, `#getIndex()`, `#setHashCode(int)` removed * `#EOF` removed ➑️ use isEof instead * Parser.ParserTask * `#getFileDisplayName()` removed ➑️ use getFileId instead (`getFileId().getAbsolutePath()`) The following classes have been removed: * pmd-core * `net.sourceforge.pmd.cpd.AbstractLanguage` * `net.sourceforge.pmd.cpd.AnyLanguage` * `net.sourceforge.pmd.cpd.Language` * `net.sourceforge.pmd.cpd.LanguageFactory` * `net.sourceforge.pmd.cpd.MatchAlgorithm` (now package private) * `net.sourceforge.pmd.cpd.MatchCollector` (now package private) * `net.sourceforge.pmd.cpd.SourceCode` (and all inner classes like `FileCodeLoader`, ...) * `net.sourceforge.pmd.cpd.token.TokenFilter` ##### Moved packages * pmd-core * NumericConstraints (old package: `net.sourceforge.pmd.properties.constraints.NumericConstraints`) * PropertyConstraint (old package: `net.sourceforge.pmd.properties.constraints.PropertyConstraint`) * not experimental anymore * ReportException (old package: `net.sourceforge.pmd.cpd`, moved to module `pmd-ant`) * it is now a RuntimeException * CPDReportRenderer (old package: `net.sourceforge.pmd.cpd.renderer`) * AntlrTokenFilter (old package: `net.sourceforge.pmd.cpd.token`) * BaseTokenFilter (old package: `net.sourceforge.pmd.cpd.token.internal`) * JavaCCTokenFilter (old package: `net.sourceforge.pmd.cpd.token`) ##### Changed types and other changes * pmd-core * PropertyDescriptor is now a class (was an interface) and it is not comparable anymore. * AbstractConfiguration#setSourceEncoding * previously this method took a simple String for the encoding. * PmdConfiguration and CPDConfiguration * many getters and setters have been moved to the parent class AbstractConfiguration * CPDListener#addedFile * no `File` parameter anymore * CPDReport#getNumberOfTokensPerFile returns a `Map` of `FileId,Integer` instead of `String` * CPDReport#filterMatches now takes a `java.util.function.Predicate` as parameter * Tokenizer * constants are now PropertyDescriptor instead of `String`, to be used as language properties * tokenize changed parameters. Now takes a TextDocument and a TokenFactory (instead of `SourceCode` and `Tokens`) * Language * method `#createProcessor(LanguagePropertyBundle)` moved to PmdCapableLanguage * StringUtil#linesWithTrimIndent now takes a `Chars` instead of a `String`. * All language modules (like pmd-apex, pmd-cpp, ...) * consistent package naming: `net.sourceforge.pmd.lang..cpd` * adapted to use CpdCapableLanguage * consistent static method `#getInstance()` * removed constants like `ID`, `TERSE_NAME` or `NAME`. Use `getInstance().getName()` etc. instead ##### Internal APIs * Tokens * PropertyTypeId ##### Deprecated API * Language#getTerseName ➑️ use getId instead * The method ASTPattern#getParenthesisDepth has been deprecated and will be removed. It was introduced for supporting parenthesized patterns, but that was removed with Java 21. It is only used when parsing code as java-19-preview. ##### Experimental APIs * To support the Java preview language features "String Templates" and "Unnamed Patterns and Variables", the following AST nodes have been introduced as experimental: * ASTTemplateExpression * ASTTemplate * ASTTemplateFragment * ASTUnnamedPattern * The AST nodes for supporting "Record Patterns" and "Pattern Matching for switch" are not experimental anymore: * ASTRecordPattern * ASTPatternList (Note: it was renamed from `ASTComponentPatternList`) * ast (Note: it was renamed from `ASTSwitchGuard`) #### External Contributions * [#4528](https://github.com/pmd/pmd/pull/4528): \[apex] Update to apexlink - [Kevin Jones](https://github.com/nawforce) (@nawforce) * [#4637](https://github.com/pmd/pmd/pull/4637): \[java] fix #4634 - JUnit4TestShouldUseTestAnnotation false positive with TestNG - [Krystian Dabrowski](https://github.com/krdabrowski) (@krdabrowski) * [#4649](https://github.com/pmd/pmd/pull/4649): \[apex] Add SObjectType and SObjectField to list of injectable SOQL variable types - [Richard Corfield](https://github.com/rcorfieldffdc) (@rcorfieldffdc) * [#4651](https://github.com/pmd/pmd/pull/4651): \[doc] Add "Tencent Cloud Code Analysis" in Tools / Integrations - [yale](https://github.com/cyw3) (@cyw3) * [#4664](https://github.com/pmd/pmd/pull/4664): \[cli] CPD: Fix NPE when only `--file-list` is specified - [Wener](https://github.com/wener-tiobe) (@wener-tiobe) * [#4665](https://github.com/pmd/pmd/pull/4665): \[java] Doc: Fix references AutoClosable -> AutoCloseable - [Andrey Bozhko](https://github.com/AndreyBozhko) (@AndreyBozhko) ### πŸš€ Major Features and Enhancements #### New official logo The new official logo of PMD: ![New PMD Logo](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/images/logo/pmd-logo-300px.png) #### Revamped Java module * Java grammar substantially refactored - more correct regarding the Java Language Specification (JLS) * Built-in rules have been upgraded for the changed AST * Rewritten type resolution framework and symbol table correctly implements the JLS * AST exposes more semantic information (method calls, field accesses) For more information, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_release_notes_pmd7.html#revamped-java). Contributors: [ClΓ©ment Fournier](https://github.com/oowekyala) (@oowekyala), [Andreas Dangel](https://github.com/adangel) (@adangel), [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) #### Revamped Command Line Interface * unified and consistent Command Line Interface for both Linux/Unix and Windows across our different utilities * single script `pmd` (`pmd.bat` for Windows) to launch the different utilities: * `pmd check` to run PMD rules and analyze a project * `pmd cpd` to run CPD (copy paste detector) * `pmd designer` to run the PMD Rule Designer * progress bar support for `pmd check` * shell completion ![Demo](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/images/userdocs/pmd-demo.gif) For more information, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_release_notes_pmd7.html). Contributors: [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) #### Full Antlr support * [Antlr](https://www.antlr.org/) based grammars can now be used to build full-fledged PMD rules. * Previously, Antlr grammar could only be used for CPD * New supported languages: Swift and Kotlin For more information, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_release_notes_pmd7.html). Contributors: [Lucas Soncini](https://github.com/lsoncini) (@lsoncini), [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga), [TomΓ‘s De Lucca](https://github.com/tomidelucca) (@tomidelucca) #### Updated PMD Designer This PMD release ships a new version of the pmd-designer. For the changes, see [PMD Designer Changelog](https://github.com/pmd/pmd-designer/releases/tag/7.0.0-rc1). #### 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](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/report-examples/cpdhtml-v2.html). ### πŸŽ‰ Language Related Changes Note that this is just a concise listing of the highlight. For more information on the languages, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_release_notes_pmd7.html). #### New: Swift support * use PMD to analyze Swift code with PMD rules * initially 4 built-in rules Contributors: [Lucas Soncini](https://github.com/lsoncini) (@lsoncini), [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga), [TomΓ‘s De Lucca](https://github.com/tomidelucca) (@tomidelucca) #### New: Kotlin support (experimental) * use PMD to analyze Kotlin code with PMD rules * Support for Kotlin 1.8 grammar * initially 2 built-in rules #### 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](https://github.com/pguyot) (@pguyot) #### 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](https://github.com/wener-tiobe) (@wener-tiobe) #### 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](https://github.com/wener-tiobe) (@wener-tiobe) #### New: Java 21 Support This release of PMD brings support for Java 21. There are the following new standard language features, that are supported now: * [JEP 440: Record Patterns](https://openjdk.org/jeps/440) * [JEP 441: Pattern Matching for switch](https://openjdk.org/jeps/441) PMD also supports the following preview language features: * [JEP 430: String Templates (Preview)](https://openjdk.org/jeps/430) * [JEP 443: Unnamed Patterns and Variables (Preview)](https://openjdk.org/jeps/443) * [JEP 445: Unnamed Classes and Instance Main Methods (Preview)](https://openjdk.org/jeps/445) 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 `21-preview`: export PMD_JAVA_OPTS=--enable-preview pmd check --use-version java-21-preview ... Note: Support for Java 19 preview language features have been removed. The version "19-preview" is no longer available. #### Changed: JavaScript support * latest version supports ES6 and also some new constructs (see [Rhino](https://github.com/mozilla/rhino)]) * comments are retained #### Changed: Language versions * more predefined language versions for each supported language * can be used to limit rule execution for specific versions only with `minimumLanguageVersion` and `maximumLanguageVersion` attributes. #### Changed: CPP can now ignore identifiers in sequences (CPD) * new command line option for CPD: `--ignore-sequences`. * This option is used for CPP only: with the already existing option `--ignore-literal-sequences`, only literals were ignored. The new option additional ignores identifiers as well in sequences. * See [PR #4470](https://github.com/pmd/pmd/pull/4470) for details. #### Changed: Apex Jorje Updated With the new version of Apex Jorje, the new language constructs like User Mode Database Operations can be parsed now. PMD should now be able to parse Apex code up to version 59.0 (Winter '23). #### Changed: Rule properties * The old deprecated classes like `IntProperty` and `StringProperty` have been removed. Please use PropertyFactory to create properties. * All properties which accept multiple values now use a comma (`,`) as a delimiter. The previous default was a pipe character (`|`). The delimiter is not configurable anymore. If needed, the comma can be escaped with a backslash. * The `min` and `max` attributes in property definitions in the XML are now optional and can appear separately or be omitted. ### 🌟 New and changed rules #### New Rules **Apex** * [`UnusedMethod`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_apex_design.html#unusedmethod) finds unused methods in your code. **Java** * [`UnnecessaryBoxing`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_codestyle.html#unnecessaryboxing) reports boxing and unboxing conversions that may be made implicit. **Kotlin** * [`FunctionNameTooShort`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_kotlin_bestpractices.html#functionnametooshort) * [`OverrideBothEqualsAndHashcode`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_kotlin_errorprone.html#overridebothequalsandhashcode) **Swift** * [`ProhibitedInterfaceBuilder`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_swift_bestpractices.html#prohibitedinterfacebuilder) * [`UnavailableFunction`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_swift_bestpractices.html#unavailablefunction) * [`ForceCast`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_swift_errorprone.html#forcecast) * [`ForceTry`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_swift_errorprone.html#forcetry) #### Changed Rules **General changes** * All statistical rules (like ExcessiveClassLength, ExcessiveParameterList) have been simplified and unified. The properties `topscore` and `sigma` have been removed. The property `minimum` is still there, however the type is not a decimal number anymore but has been changed to an integer. This affects rules in the languages Apex, Java, PLSQL and Velocity Template Language (vm): * Apex: [`ExcessiveClassLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_apex_design.html#excessiveclasslength), [`ExcessiveParameterList`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_apex_design.html#excessiveparameterlist), [`ExcessivePublicCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_apex_design.html#excessivepubliccount), [`NcssConstructorCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_apex_design.html#ncssconstructorcount), [`NcssMethodCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_apex_design.html#ncssmethodcount), [`NcssTypeCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_apex_design.html#ncsstypecount) * Java: [`ExcessiveImports`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_design.html#excessiveimports), [`ExcessiveParameterList`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_design.html#excessiveparameterlist), [`ExcessivePublicCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_design.html#excessivepubliccount), [`SwitchDensity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_design.html#switchdensity) * PLSQL: [`ExcessiveMethodLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_plsql_design.html#excessivemethodlength), [`ExcessiveObjectLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_plsql_design.html#excessiveobjectlength), [`ExcessivePackageBodyLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_plsql_design.html#excessivepackagebodylength), [`ExcessivePackageSpecificationLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_plsql_design.html#excessivepackagespecificationlength), [`ExcessiveParameterList`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_plsql_design.html#excessiveparameterlist), [`ExcessiveTypeLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_plsql_design.html#excessivetypelength), [`NcssMethodCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_plsql_design.html#ncssmethodcount), [`NcssObjectCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_plsql_design.html#ncssobjectcount), [`NPathComplexity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_plsql_design.html#npathcomplexity) * VM: [`ExcessiveTemplateLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_vm_design.html#excessivetemplatelength) * The general property `violationSuppressXPath` which is available for all rules to [suppress warnings](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_userdocs_suppressing_warnings.html) now uses XPath version 3.1 by default. This version of the XPath language is mostly identical to XPath 2.0. In PMD 6, XPath 1.0 has been used. If you upgrade from PMD 6, you need to verify your `violationSuppressXPath` properties. **Apex General changes** * The properties `cc_categories`, `cc_remediation_points_multiplier`, `cc_block_highlighting` have been removed from all rules. These properties have been deprecated since PMD 6.13.0. See [issue #1648](https://github.com/pmd/pmd/issues/1648) for more details. **Java General changes** * Violations reported on methods or classes previously reported the line range of the entire method or class. With PMD 7.0.0, the reported location is now just the identifier of the method or class. This affects various rules, e.g. [`CognitiveComplexity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_design.html#cognitivecomplexity). The report location is controlled by the overrides of the method getReportLocation in different node types. See [issue #4439](https://github.com/pmd/pmd/issues/4439) and [issue #730](https://github.com/pmd/pmd/issues/730) for more details. **Java Best Practices** * [`ArrayIsStoredDirectly`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_bestpractices.html#arrayisstoreddirectly): Violations are now reported on the assignment and not anymore on the formal parameter. The reported line numbers will probably move. * [`AvoidReassigningLoopVariables`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_bestpractices.html#avoidreassigningloopvariables): This rule might not report anymore all reassignments of the control variable in for-loops when the property `forReassign` is set to `skip`. See [issue #4500](https://github.com/pmd/pmd/issues/4500) for more details. * [`LooseCoupling`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_bestpractices.html#loosecoupling): The rule has a new property to allow some types to be coupled to (`allowedTypes`). * [`UnusedLocalVariable`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_bestpractices.html#unusedlocalvariable): This rule has some important false-negatives fixed and finds many more cases now. For details see issues [#2130](https://github.com/pmd/pmd/issues/2130), [#4516](https://github.com/pmd/pmd/issues/4516), and [#4517](https://github.com/pmd/pmd/issues/4517). **Java Codestyle** * [`MethodNamingConventions`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_codestyle.html#methodnamingconventions): The property `checkNativeMethods` has been removed. The property was deprecated since PMD 6.3.0. Use the property `nativePattern` to control whether native methods should be considered or not. * [`ShortVariable`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_codestyle.html#shortvariable): This rule now also reports short enum constant names. * [`UseDiamondOperator`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_codestyle.html#usediamondoperator): The property `java7Compatibility` has been removed. The rule now handles Java 7 properly without a property. * [`UnnecessaryFullyQualifiedName`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_codestyle.html#unnecessaryfullyqualifiedname): The rule has two new properties, to selectively disable reporting on static field and method qualifiers. The rule also has been improved to be more precise. * [`UselessParentheses`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_codestyle.html#uselessparentheses): The rule has two new properties which control how strict the rule should be applied. With `ignoreClarifying` (default: true) parentheses that are strictly speaking not necessary are allowed, if they separate expressions of different precedence. The other property `ignoreBalancing` (default: true) is similar, in that it allows parentheses that help reading and understanding the expressions. **Java Design** * [`CyclomaticComplexity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_design.html#cyclomaticcomplexity): The property `reportLevel` has been removed. The property was deprecated since PMD 6.0.0. The report level can now be configured separated for classes and methods using `classReportLevel` and `methodReportLevel` instead. * [`ImmutableField`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_design.html#immutablefield): The property `ignoredAnnotations` has been removed. The property was deprecated since PMD 6.52.0. * [`LawOfDemeter`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_design.html#lawofdemeter): The rule has a new property `trustRadius`. This defines the maximum degree of trusted data. The default of 1 is the most restrictive. * [`NPathComplexity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_design.html#npathcomplexity): The property `minimum` has been removed. It was deprecated since PMD 6.0.0. Use the property `reportLevel` instead. * [`SingularField`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_design.html#singularfield): The properties `checkInnerClasses` and `disallowNotAssignment` have been removed. The rule is now more precise and will check these cases properly. * [`UseUtilityClass`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_design.html#useutilityclass): The property `ignoredAnnotations` has been removed. **Java Documentation** * [`CommentContent`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_documentation.html#commentcontent): The properties `caseSensitive` and `disallowedTerms` are removed. The new property `forbiddenRegex` can be used now to define the disallowed terms with a single regular expression. * [`CommentRequired`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_documentation.html#commentrequired): * Overridden methods are now detected even without the `@Override` annotation. This is relevant for the property `methodWithOverrideCommentRequirement`. See also [pull request #3757](https://github.com/pmd/pmd/pull/3757). * Elements in annotation types are now detected as well. This might lead to an increased number of violations for missing public method comments. * [`CommentSize`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_documentation.html#commentsize): When determining the line-length of a comment, the leading comment prefix markers (e.g. `*` or `//`) are ignored and don't add up to the line-length. See also [pull request #4369](https://github.com/pmd/pmd/pull/4369). **Java Error Prone** * [`AvoidDuplicateLiterals`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_errorprone.html#avoidduplicateliterals): The property `exceptionfile` has been removed. The property was deprecated since PMD 6.10.0. Use the property `exceptionList` instead. * [`DontImportSun`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_errorprone.html#dontimportsun): `sun.misc.Signal` is not special-cased anymore. * [`EmptyCatchBlock`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_errorprone.html#emptycatchblock): `CloneNotSupportedException` and `InterruptedException` are not special-cased anymore. Rename the exception parameter to `ignored` to ignore them. * [`ImplicitSwitchFallThrough`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_errorprone.html#implicitswitchfallthrough): Violations are now reported on the case statements rather than on the switch statements. This is more accurate but might result in more violations now. #### Removed Rules Many rules, that were previously deprecated have been finally removed. See [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_release_notes_pmd7.html) for the complete list. ### 🚨 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. Also, there are some improvement and changes in different areas. For the detailed description of the changes listed here, see [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_release_notes_pmd7.html). * Miscellaneous smaller changes and cleanups * XPath 3.1 support for XPath-based rules * Node stream API for AST traversal * Metrics framework * Testing framework * Language Lifecycle and Language Properties * Rule Properties * New Programmatic API for CPD ### πŸ’₯ Compatibility and migration notes A detailed documentation of required changes are available in the [Migration Guide for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_userdocs_migrating_to_pmd7.html). See also [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_release_notes_pmd7.html). ### πŸ› Fixed Issues * miscellaneous * [#881](https://github.com/pmd/pmd/issues/881): \[all] Breaking API changes for 7.0.0 * [#896](https://github.com/pmd/pmd/issues/896): \[all] Use slf4j * [#1431](https://github.com/pmd/pmd/pull/1431): \[ui] Remove old GUI applications (designerold, bgastviewer) * [#1451](https://github.com/pmd/pmd/issues/1451): \[core] RulesetFactoryCompatibility stores the whole ruleset file in memory as a string * [#2496](https://github.com/pmd/pmd/issues/2496): Update PMD 7 Logo on landing page * [#2497](https://github.com/pmd/pmd/issues/2497): PMD 7 Logo page * [#2498](https://github.com/pmd/pmd/issues/2498): Update PMD 7 Logo in documentation * [#3797](https://github.com/pmd/pmd/issues/3797): \[all] Use JUnit5 * [#4462](https://github.com/pmd/pmd/issues/4462): Provide Software Bill of Materials (SBOM) * [#4460](https://github.com/pmd/pmd/pull/4460): Fix assembly-plugin warnings * [#4582](https://github.com/pmd/pmd/issues/4582): \[dist] Download link broken * [#4691](https://github.com/pmd/pmd/issues/4691): \[CVEs] Critical and High CEVs reported on PMD and PMD dependencies * ant * [#4080](https://github.com/pmd/pmd/issues/4080): \[ant] Split off Ant integration into a new submodule * core * [#880](https://github.com/pmd/pmd/issues/880): \[core] Make visitors generic * [#1204](https://github.com/pmd/pmd/issues/1204): \[core] Allow numeric properties in XML to be within an unbounded range * [#1622](https://github.com/pmd/pmd/pull/1622): \[core] NodeStream API * [#1687](https://github.com/pmd/pmd/issues/1687): \[core] Deprecate and Remove XPath 1.0 support * [#1785](https://github.com/pmd/pmd/issues/1785): \[core] Allow abstract node types to be valid rulechain visits * [#1825](https://github.com/pmd/pmd/pull/1825): \[core] Support NoAttribute for XPath * [#2038](https://github.com/pmd/pmd/issues/2038): \[core] Remove DCD * [#2218](https://github.com/pmd/pmd/issues/2218): \[core] `isFindBoundary` should not be an attribute * [#2234](https://github.com/pmd/pmd/issues/2234): \[core] Consolidate PMD CLI into a single command * [#2239](https://github.com/pmd/pmd/issues/2239): \[core] Merging Javacc build scripts * [#2500](https://github.com/pmd/pmd/issues/2500): \[core] Clarify API for ANTLR based languages * [#2518](https://github.com/pmd/pmd/issues/2518): \[core] Language properties * [#2602](https://github.com/pmd/pmd/issues/2602): \[core] Remove ParserOptions * [#2614](https://github.com/pmd/pmd/pull/2614): \[core] Upgrade Saxon, add XPath 3.1, remove Jaxen * [#2696](https://github.com/pmd/pmd/pull/2696): \[core] Remove DFA * [#2821](https://github.com/pmd/pmd/issues/2821): \[core] Rule processing error filenames are missing paths * [#2873](https://github.com/pmd/pmd/issues/2873): \[core] Utility classes in pmd 7 * [#2885](https://github.com/pmd/pmd/issues/2885): \[core] Error recovery mode * [#3203](https://github.com/pmd/pmd/issues/3203): \[core] Replace RuleViolationFactory implementations with ViolationDecorator * [#3692](https://github.com/pmd/pmd/pull/3692): \[core] Analysis listeners * [#3782](https://github.com/pmd/pmd/issues/3782): \[core] Language lifecycle * [#3815](https://github.com/pmd/pmd/issues/3815): \[core] Update Saxon HE to 10.7 * [#3893](https://github.com/pmd/pmd/pull/3893): \[core] Text documents * [#3902](https://github.com/pmd/pmd/issues/3902): \[core] Violation decorators * [#3918](https://github.com/pmd/pmd/issues/3918): \[core] Make LanguageRegistry non static * [#3919](https://github.com/pmd/pmd/issues/3919): \[core] Merge CPD and PMD language * [#3922](https://github.com/pmd/pmd/pull/3922): \[core] Better error reporting for the ruleset parser * [#4035](https://github.com/pmd/pmd/issues/4035): \[core] ConcurrentModificationException in DefaultRuleViolationFactory * [#4120](https://github.com/pmd/pmd/issues/4120): \[core] Explicitly name all language versions * [#4204](https://github.com/pmd/pmd/issues/4204): \[core] Provide a CpdAnalysis class as a programmatic entry point into CPD * [#4301](https://github.com/pmd/pmd/issues/4301): \[core] Remove deprecated property concrete classes * [#4302](https://github.com/pmd/pmd/issues/4302): \[core] Migrate Property Framework API to Java 8 * [#4323](https://github.com/pmd/pmd/issues/4323): \[core] Refactor CPD integration * [#4353](https://github.com/pmd/pmd/pull/4353): \[core] Micro optimizations for Node API * [#4365](https://github.com/pmd/pmd/pull/4365): \[core] Improve benchmarking * [#4397](https://github.com/pmd/pmd/pull/4397): \[core] Refactor CPD * [#4420](https://github.com/pmd/pmd/pull/4420): \[core] Remove PMD.EOL * [#4425](https://github.com/pmd/pmd/pull/4425): \[core] Replace TextFile::pathId * [#4454](https://github.com/pmd/pmd/issues/4454): \[core] "Unknown option: '-min'" but is referenced in documentation * [#4611](https://github.com/pmd/pmd/pull/4611): \[core] Fix loading language properties from env vars * [#4621](https://github.com/pmd/pmd/issues/4621): \[core] Make `ClasspathClassLoader::getResource` child first * cli * [#2234](https://github.com/pmd/pmd/issues/2234): \[core] Consolidate PMD CLI into a single command * [#3828](https://github.com/pmd/pmd/issues/3828): \[core] Progress reporting * [#4079](https://github.com/pmd/pmd/issues/4079): \[cli] Split off CLI implementation into a pmd-cli submodule * [#4423](https://github.com/pmd/pmd/pull/4423): \[cli] Fix NPE when only `--file-list` is specified * [#4482](https://github.com/pmd/pmd/issues/4482): \[cli] pmd.bat can only be executed once * [#4484](https://github.com/pmd/pmd/issues/4484): \[cli] ast-dump with no properties produce an NPE * doc * [#2501](https://github.com/pmd/pmd/issues/2501): \[doc] Verify ANTLR Documentation * [#4294](https://github.com/pmd/pmd/issues/4294): \[doc] Migration Guide for upgrading PMD 6 ➑️ 7 * [#4303](https://github.com/pmd/pmd/issues/4303): \[doc] Document new property framework * [#4438](https://github.com/pmd/pmd/issues/4438): \[doc] Documentation links in VS Code are outdated * [#4521](https://github.com/pmd/pmd/issues/4521): \[doc] Website is not mobile friendly * testing * [#2435](https://github.com/pmd/pmd/issues/2435): \[test] Remove duplicated Dummy language module * [#4234](https://github.com/pmd/pmd/issues/4234): \[test] Tests that change the logging level do not work Language specific fixes: * apex * [#1937](https://github.com/pmd/pmd/issues/1937): \[apex] Apex should only have a single RootNode * [#1648](https://github.com/pmd/pmd/issues/1648): \[apex,vf] Remove CodeClimate dependency * [#1750](https://github.com/pmd/pmd/pull/1750): \[apex] Remove apex statistical rules * [#2836](https://github.com/pmd/pmd/pull/2836): \[apex] Remove Apex ProjectMirror * [#3973](https://github.com/pmd/pmd/issues/3973): \[apex] Update parser to support new 'as user' keywords (User Mode for Database Operations) * [#4427](https://github.com/pmd/pmd/issues/4427): \[apex] ApexBadCrypto test failing to detect inline code * [#4453](https://github.com/pmd/pmd/issues/4453): \[apex] \[7.0-rc1] Exception while initializing Apexlink (Index 34812 out of bounds for length 34812) * apex-design * [#2667](https://github.com/pmd/pmd/issues/2667): \[apex] Integrate nawforce/ApexLink to build robust Unused rule * [#4509](https://github.com/pmd/pmd/issues/4509): \[apex] ExcessivePublicCount doesn't consider inner classes correctly * [#4596](https://github.com/pmd/pmd/issues/4596): \[apex] ExcessivePublicCount ignores properties * apex-security * [#4646](https://github.com/pmd/pmd/issues/4646): \[apex] ApexSOQLInjection does not recognise SObjectType or SObjectField as safe variable types * java * [#520](https://github.com/pmd/pmd/issues/520): \[java] Allow `@SuppressWarnings` with constants instead of literals * [#864](https://github.com/pmd/pmd/issues/864): \[java] Similar/duplicated implementations for determining FQCN * [#905](https://github.com/pmd/pmd/issues/905): \[java] Add new node for anonymous class declaration * [#910](https://github.com/pmd/pmd/issues/910): \[java] AST inconsistency between primitive and reference type arrays * [#997](https://github.com/pmd/pmd/issues/997): \[java] Java8 parsing corner case with annotated array types * [#998](https://github.com/pmd/pmd/issues/998): \[java] AST inconsistencies around FormalParameter * [#1019](https://github.com/pmd/pmd/issues/1019): \[java] Breaking Java Grammar changes for PMD 7.0.0 * [#1124](https://github.com/pmd/pmd/issues/1124): \[java] ImmutableList implementation in the qname codebase * [#1128](https://github.com/pmd/pmd/issues/1128): \[java] Improve ASTLocalVariableDeclaration * [#1150](https://github.com/pmd/pmd/issues/1150): \[java] ClassOrInterfaceType AST improvements * [#1207](https://github.com/pmd/pmd/issues/1207): \[java] Resolve explicit types using FQCNs, without hitting the classloader * [#1367](https://github.com/pmd/pmd/issues/1367): \[java] Parsing error on annotated inner class * [#1661](https://github.com/pmd/pmd/issues/1661): \[java] About operator nodes * [#2366](https://github.com/pmd/pmd/pull/2366): \[java] Remove qualified names * [#2819](https://github.com/pmd/pmd/issues/2819): \[java] GLB bugs in pmd 7 * [#3642](https://github.com/pmd/pmd/issues/3642): \[java] Parse error on rare extra dimensions on method return type on annotation methods * [#3763](https://github.com/pmd/pmd/issues/3763): \[java] Ambiguous reference error in valid code * [#3749](https://github.com/pmd/pmd/issues/3749): \[java] Improve `isOverridden` in ASTMethodDeclaration * [#3750](https://github.com/pmd/pmd/issues/3750): \[java] Make symbol table support instanceof pattern bindings * [#3752](https://github.com/pmd/pmd/issues/3752): \[java] Expose annotations in symbol API * [#4237](https://github.com/pmd/pmd/pull/4237): \[java] Cleanup handling of Java comments * [#4317](https://github.com/pmd/pmd/issues/4317): \[java] Some AST nodes should not be TypeNodes * [#4359](https://github.com/pmd/pmd/issues/4359): \[java] Type resolution fails with NPE when the scope is not a type declaration * [#4367](https://github.com/pmd/pmd/issues/4367): \[java] Move testrule TypeResTest into internal * [#4383](https://github.com/pmd/pmd/issues/4383): \[java] IllegalStateException: Object is not an array type! * [#4401](https://github.com/pmd/pmd/issues/4401): \[java] PMD 7 fails to build under Java 19 * [#4405](https://github.com/pmd/pmd/issues/4405): \[java] Processing error with ArrayIndexOutOfBoundsException * [#4583](https://github.com/pmd/pmd/issues/4583): \[java] Support JDK 21 (LTS) * java-bestpractices * [#342](https://github.com/pmd/pmd/issues/342): \[java] AccessorMethodGeneration: Name clash with another public field not properly handled * [#755](https://github.com/pmd/pmd/issues/755): \[java] AccessorClassGeneration false positive for private constructors * [#770](https://github.com/pmd/pmd/issues/770): \[java] UnusedPrivateMethod yields false positive for counter-variant arguments * [#807](https://github.com/pmd/pmd/issues/807): \[java] AccessorMethodGeneration false positive with overloads * [#833](https://github.com/pmd/pmd/issues/833): \[java] ForLoopCanBeForeach should consider iterating on this * [#1189](https://github.com/pmd/pmd/issues/1189): \[java] UnusedPrivateMethod false positive from inner class via external class * [#1205](https://github.com/pmd/pmd/issues/1205): \[java] Improve ConstantsInInterface message to mention alternatives * [#1212](https://github.com/pmd/pmd/issues/1212): \[java] Don't raise JUnitTestContainsTooManyAsserts on JUnit 5's assertAll * [#1422](https://github.com/pmd/pmd/issues/1422): \[java] JUnitTestsShouldIncludeAssert false positive with inherited @Rule field * [#1455](https://github.com/pmd/pmd/issues/1455): \[java] JUnitTestsShouldIncludeAssert: False positives for assert methods named "check" and "verify" * [#1563](https://github.com/pmd/pmd/issues/1563): \[java] ForLoopCanBeForeach false positive with method call using index variable * [#1565](https://github.com/pmd/pmd/issues/1565): \[java] JUnitAssertionsShouldIncludeMessage false positive with AssertJ * [#1747](https://github.com/pmd/pmd/issues/1747): \[java] PreserveStackTrace false-positive * [#1969](https://github.com/pmd/pmd/issues/1969): \[java] MissingOverride false-positive triggered by package-private method overwritten in another package by extending class * [#1998](https://github.com/pmd/pmd/issues/1998): \[java] AccessorClassGeneration false-negative: subclass calls private constructor * [#2130](https://github.com/pmd/pmd/issues/2130): \[java] UnusedLocalVariable: false-negative with array * [#2147](https://github.com/pmd/pmd/issues/2147): \[java] JUnitTestsShouldIncludeAssert - false positives with lambdas and static methods * [#2464](https://github.com/pmd/pmd/issues/2464): \[java] LooseCoupling must ignore class literals: ArrayList.class * [#2542](https://github.com/pmd/pmd/issues/2542): \[java] UseCollectionIsEmpty can not detect the case `foo.bar().size()` * [#2650](https://github.com/pmd/pmd/issues/2650): \[java] UseTryWithResources false positive when AutoCloseable helper used * [#2796](https://github.com/pmd/pmd/issues/2796): \[java] UnusedAssignment false positive with call chains * [#2797](https://github.com/pmd/pmd/issues/2797): \[java] MissingOverride long-standing issues * [#2806](https://github.com/pmd/pmd/issues/2806): \[java] SwitchStmtsShouldHaveDefault false-positive with Java 14 switch non-fallthrough branches * [#2822](https://github.com/pmd/pmd/issues/2822): \[java] LooseCoupling rule: Extend to cover user defined implementations and interfaces * [#2843](https://github.com/pmd/pmd/pull/2843): \[java] Fix UnusedAssignment FP with field accesses * [#2882](https://github.com/pmd/pmd/issues/2882): \[java] UseTryWithResources - false negative for explicit close * [#2883](https://github.com/pmd/pmd/issues/2883): \[java] JUnitAssertionsShouldIncludeMessage false positive with method call * [#2890](https://github.com/pmd/pmd/issues/2890): \[java] UnusedPrivateMethod false positive with generics * [#2946](https://github.com/pmd/pmd/issues/2946): \[java] SwitchStmtsShouldHaveDefault false positive on enum inside enums * [#3672](https://github.com/pmd/pmd/pull/3672): \[java] LooseCoupling - fix false positive with generics * [#3675](https://github.com/pmd/pmd/pull/3675): \[java] MissingOverride - fix false positive with mixing type vars * [#3858](https://github.com/pmd/pmd/issues/3858): \[java] UseCollectionIsEmpty should infer local variable type from method invocation * [#4433](https://github.com/pmd/pmd/issues/4433): \[java] \[7.0-rc1] ReplaceHashtableWithMap on java.util.Properties * [#4492](https://github.com/pmd/pmd/issues/4492): \[java] GuardLogStatement gives false positive when argument is a Java method reference * [#4503](https://github.com/pmd/pmd/issues/4503): \[java] JUnitTestsShouldIncludeAssert: false negative with TestNG * [#4516](https://github.com/pmd/pmd/issues/4516): \[java] UnusedLocalVariable: false-negative with try-with-resources * [#4517](https://github.com/pmd/pmd/issues/4517): \[java] UnusedLocalVariable: false-negative with compound assignments * [#4518](https://github.com/pmd/pmd/issues/4518): \[java] UnusedLocalVariable: false-positive with multiple for-loop indices * [#4634](https://github.com/pmd/pmd/issues/4634): \[java] JUnit4TestShouldUseTestAnnotation false positive with TestNG * java-codestyle * [#1208](https://github.com/pmd/pmd/issues/1208): \[java] PrematureDeclaration rule false-positive on variable declared to measure time * [#1429](https://github.com/pmd/pmd/issues/1429): \[java] PrematureDeclaration as result of method call (false positive) * [#1480](https://github.com/pmd/pmd/issues/1480): \[java] IdenticalCatchBranches false positive with return expressions * [#1673](https://github.com/pmd/pmd/issues/1673): \[java] UselessParentheses false positive with conditional operator * [#1790](https://github.com/pmd/pmd/issues/1790): \[java] UnnecessaryFullyQualifiedName false positive with enum constant * [#1918](https://github.com/pmd/pmd/issues/1918): \[java] UselessParentheses false positive with boolean operators * [#2134](https://github.com/pmd/pmd/issues/2134): \[java] PreserveStackTrace not handling `Throwable.addSuppressed(...)` * [#2299](https://github.com/pmd/pmd/issues/2299): \[java] UnnecessaryFullyQualifiedName false positive with similar package name * [#2391](https://github.com/pmd/pmd/issues/2391): \[java] UseDiamondOperator FP when expected type and constructed type have a different parameterization * [#2528](https://github.com/pmd/pmd/issues/2528): \[java] MethodNamingConventions - JUnit 5 method naming not support ParameterizedTest * [#2739](https://github.com/pmd/pmd/issues/2739): \[java] UselessParentheses false positive for string concatenation * [#2748](https://github.com/pmd/pmd/issues/2748): \[java] UnnecessaryCast false positive with unchecked cast * [#2973](https://github.com/pmd/pmd/issues/2973): \[java] New rule: UnnecessaryBoxing * [#3195](https://github.com/pmd/pmd/pull/3195): \[java] Improve rule UnnecessaryReturn to detect more cases * [#3218](https://github.com/pmd/pmd/pull/3218): \[java] Generalize UnnecessaryCast to flag all unnecessary casts * [#3221](https://github.com/pmd/pmd/issues/3221): \[java] PrematureDeclaration false positive for unused variables * [#3238](https://github.com/pmd/pmd/issues/3238): \[java] Improve ExprContext, fix FNs of UnnecessaryCast * [#3500](https://github.com/pmd/pmd/pull/3500): \[java] UnnecessaryBoxing - check for Integer.valueOf(String) calls * [#4268](https://github.com/pmd/pmd/issues/4268): \[java] CommentDefaultAccessModifier: false positive with TestNG annotations * [#4273](https://github.com/pmd/pmd/issues/4273): \[java] CommentDefaultAccessModifier ignoredAnnotations should include "org.junit.jupiter.api.extension.RegisterExtension" by default * [#4357](https://github.com/pmd/pmd/pull/4357): \[java] Fix IllegalStateException in UseDiamondOperator rule * [#4432](https://github.com/pmd/pmd/issues/4432): \[java] \[7.0-rc1] UnnecessaryImport - Unused static import is being used * [#4455](https://github.com/pmd/pmd/issues/4455): \[java] FieldNamingConventions: false positive with lombok's @UtilityClass * [#4487](https://github.com/pmd/pmd/issues/4487): \[java] UnnecessaryConstructor: false-positive with @Inject and @Autowired * [#4511](https://github.com/pmd/pmd/issues/4511): \[java] LocalVariableCouldBeFinal shouldn't report unused variables * [#4512](https://github.com/pmd/pmd/issues/4512): \[java] MethodArgumentCouldBeFinal shouldn't report unused parameters * [#4557](https://github.com/pmd/pmd/issues/4557): \[java] UnnecessaryImport FP with static imports of overloaded methods * java-design * [#1014](https://github.com/pmd/pmd/issues/1014): \[java] LawOfDemeter: False positive with lambda expression * [#1605](https://github.com/pmd/pmd/issues/1605): \[java] LawOfDemeter: False positive for standard UTF-8 charset name * [#2160](https://github.com/pmd/pmd/issues/2160): \[java] Issues with Law of Demeter * [#2175](https://github.com/pmd/pmd/issues/2175): \[java] LawOfDemeter: False positive for chained methods with generic method call * [#2179](https://github.com/pmd/pmd/issues/2179): \[java] LawOfDemeter: False positive with static property access - should treat class-level property as global object, not dot-accessed property * [#2180](https://github.com/pmd/pmd/issues/2180): \[java] LawOfDemeter: False positive with Thread and ThreadLocalRandom * [#2182](https://github.com/pmd/pmd/issues/2182): \[java] LawOfDemeter: False positive with package-private access * [#2188](https://github.com/pmd/pmd/issues/2188): \[java] LawOfDemeter: False positive with fields assigned to local vars * [#2536](https://github.com/pmd/pmd/issues/2536): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal can't detect inner class * [#3668](https://github.com/pmd/pmd/pull/3668): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal - fix FP with inner private classes * [#3754](https://github.com/pmd/pmd/issues/3754): \[java] SingularField false positive with read in while condition * [#3786](https://github.com/pmd/pmd/issues/3786): \[java] SimplifyBooleanReturns should consider operator precedence * [#3840](https://github.com/pmd/pmd/issues/3840): \[java] LawOfDemeter disallows method call on locally created object * [#4238](https://github.com/pmd/pmd/pull/4238): \[java] Make LawOfDemeter not use the rulechain * [#4254](https://github.com/pmd/pmd/issues/4254): \[java] ImmutableField - false positive with Lombok @Setter * [#4434](https://github.com/pmd/pmd/issues/4434): \[java] \[7.0-rc1] ExceptionAsFlowControl when simply propagating * [#4456](https://github.com/pmd/pmd/issues/4456): \[java] FinalFieldCouldBeStatic: false positive with lombok's @UtilityClass * [#4477](https://github.com/pmd/pmd/issues/4477): \[java] SignatureDeclareThrowsException: false-positive with TestNG annotations * [#4490](https://github.com/pmd/pmd/issues/4490): \[java] ImmutableField - false negative with Lombok @Getter * [#4549](https://github.com/pmd/pmd/pull/4549): \[java] Make LawOfDemeter results deterministic * java-documentation * [#4369](https://github.com/pmd/pmd/pull/4369): \[java] Improve CommentSize * [#4416](https://github.com/pmd/pmd/pull/4416): \[java] Fix reported line number in CommentContentRule * java-errorprone * [#659](https://github.com/pmd/pmd/issues/659): \[java] MissingBreakInSwitch - last default case does not contain a break * [#1005](https://github.com/pmd/pmd/issues/1005): \[java] CloneMethodMustImplementCloneable triggers for interfaces * [#1669](https://github.com/pmd/pmd/issues/1669): \[java] NullAssignment - FP with ternay and null as constructor argument * [#1899](https://github.com/pmd/pmd/issues/1899): \[java] Recognize @SuppressWanings("fallthrough") for MissingBreakInSwitch * [#2320](https://github.com/pmd/pmd/issues/2320): \[java] NullAssignment - FP with ternary and null as method argument * [#2532](https://github.com/pmd/pmd/issues/2532): \[java] AvoidDecimalLiteralsInBigDecimalConstructor can not detect the case `new BigDecimal(Expression)` * [#2579](https://github.com/pmd/pmd/issues/2579): \[java] MissingBreakInSwitch detects the lack of break in the last case * [#2880](https://github.com/pmd/pmd/issues/2880): \[java] CompareObjectsWithEquals - false negative with type res * [#2893](https://github.com/pmd/pmd/issues/2893): \[java] Remove special cases from rule EmptyCatchBlock * [#2894](https://github.com/pmd/pmd/issues/2894): \[java] Improve MissingBreakInSwitch * [#3071](https://github.com/pmd/pmd/issues/3071): \[java] BrokenNullCheck FP with PMD 6.30.0 * [#3087](https://github.com/pmd/pmd/issues/3087): \[java] UnnecessaryBooleanAssertion overlaps with SimplifiableTestAssertion * [#3100](https://github.com/pmd/pmd/issues/3100): \[java] UseCorrectExceptionLogging FP in 6.31.0 * [#3173](https://github.com/pmd/pmd/issues/3173): \[java] UseProperClassLoader false positive * [#3351](https://github.com/pmd/pmd/issues/3351): \[java] ConstructorCallsOverridableMethod ignores abstract methods * [#3400](https://github.com/pmd/pmd/issues/3400): \[java] AvoidUsingOctalValues FN with underscores * [#3843](https://github.com/pmd/pmd/issues/3843): \[java] UseEqualsToCompareStrings should consider return type * [#4063](https://github.com/pmd/pmd/issues/4063): \[java] AvoidBranchingStatementAsLastInLoop: False-negative about try/finally block * [#4356](https://github.com/pmd/pmd/pull/4356): \[java] Fix NPE in CloseResourceRule * [#4449](https://github.com/pmd/pmd/issues/4449): \[java] AvoidAccessibilityAlteration: Possible false positive in AvoidAccessibilityAlteration rule when using Lambda expression * [#4457](https://github.com/pmd/pmd/issues/4457): \[java] OverrideBothEqualsAndHashcode: false negative with anonymous classes * [#4493](https://github.com/pmd/pmd/issues/4493): \[java] MissingStaticMethodInNonInstantiatableClass: false-positive about @Inject * [#4505](https://github.com/pmd/pmd/issues/4505): \[java] ImplicitSwitchFallThrough NPE in PMD 7.0.0-rc1 * [#4510](https://github.com/pmd/pmd/issues/4510): \[java] ConstructorCallsOverridableMethod: false positive with lombok's @Value * [#4513](https://github.com/pmd/pmd/issues/4513): \[java] UselessOperationOnImmutable various false negatives with String * [#4514](https://github.com/pmd/pmd/issues/4514): \[java] AvoidLiteralsInIfCondition false positive and negative for String literals when ignoreExpressions=true * [#4546](https://github.com/pmd/pmd/issues/4546): \[java] OverrideBothEqualsAndHashCode ignores records * java-multithreading * [#2537](https://github.com/pmd/pmd/issues/2537): \[java] DontCallThreadRun can't detect the case that call run() in `this.run()` * [#2538](https://github.com/pmd/pmd/issues/2538): \[java] DontCallThreadRun can't detect the case that call run() in `foo.bar.run()` * [#2577](https://github.com/pmd/pmd/issues/2577): \[java] UseNotifyAllInsteadOfNotify falsely detect a special case with argument: `foo.notify(bar)` * [#4483](https://github.com/pmd/pmd/issues/4483): \[java] NonThreadSafeSingleton false positive with double-checked locking * java-performance * [#1224](https://github.com/pmd/pmd/issues/1224): \[java] InefficientEmptyStringCheck false negative in anonymous class * [#2587](https://github.com/pmd/pmd/issues/2587): \[java] AvoidArrayLoops could also check for list copy through iterated List.add() * [#2712](https://github.com/pmd/pmd/issues/2712): \[java] SimplifyStartsWith false-positive with AssertJ * [#3486](https://github.com/pmd/pmd/pull/3486): \[java] InsufficientStringBufferDeclaration: Fix NPE * [#3848](https://github.com/pmd/pmd/issues/3848): \[java] StringInstantiation: false negative when using method result * [#4070](https://github.com/pmd/pmd/issues/4070): \[java] A false positive about the rule RedundantFieldInitializer * [#4458](https://github.com/pmd/pmd/issues/4458): \[java] RedundantFieldInitializer: false positive with lombok's @Value * kotlin * [#419](https://github.com/pmd/pmd/issues/419): \[kotlin] Add support for Kotlin * [#4389](https://github.com/pmd/pmd/pull/4389): \[kotlin] Update grammar to version 1.8 * swift * [#1877](https://github.com/pmd/pmd/pull/1877): \[swift] Feature/swift rules * [#1882](https://github.com/pmd/pmd/pull/1882): \[swift] UnavailableFunction Swift rule * xml * [#1800](https://github.com/pmd/pmd/pull/1800): \[xml] Unimplement org.w3c.dom.Node from the XmlNodeWrapper ### ✨ External Contributions * [#1658](https://github.com/pmd/pmd/pull/1658): \[core] Node support for Antlr-based languages - [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga) * [#1698](https://github.com/pmd/pmd/pull/1698): \[core] [swift] Antlr Base Parser adapter and Swift Implementation - [Lucas Soncini](https://github.com/lsoncini) (@lsoncini) * [#1774](https://github.com/pmd/pmd/pull/1774): \[core] Antlr visitor rules - [Lucas Soncini](https://github.com/lsoncini) (@lsoncini) * [#1877](https://github.com/pmd/pmd/pull/1877): \[swift] Feature/swift rules - [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga) * [#1881](https://github.com/pmd/pmd/pull/1881): \[doc] Add ANTLR documentation - [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga) * [#1882](https://github.com/pmd/pmd/pull/1882): \[swift] UnavailableFunction Swift rule - [TomΓ‘s de Lucca](https://github.com/tomidelucca) (@tomidelucca) * [#2830](https://github.com/pmd/pmd/pull/2830): \[apex] Apexlink POC - [Kevin Jones](https://github.com/nawforce) (@nawforce) * [#3866](https://github.com/pmd/pmd/pull/3866): \[core] Add CLI Progress Bar - [@JerritEic](https://github.com/JerritEic) (@JerritEic) * [#4402](https://github.com/pmd/pmd/pull/4402): \[javascript] CPD: add support for Typescript using antlr4 grammar - [Paul Guyot](https://github.com/pguyot) (@pguyot) * [#4403](https://github.com/pmd/pmd/pull/4403): \[julia] CPD: Add support for Julia code duplication - [Wener](https://github.com/wener-tiobe) (@wener-tiobe) * [#4412](https://github.com/pmd/pmd/pull/4412): \[doc] Added new error msg to ConstantsInInterface - [David Ljunggren](https://github.com/dague1) (@dague1) * [#4426](https://github.com/pmd/pmd/pull/4426): \[cpd] New XML to HTML XLST report format for PMD CPD - [mohan-chinnappan-n](https://github.com/mohan-chinnappan-n) (@mohan-chinnappan-n) * [#4428](https://github.com/pmd/pmd/pull/4428): \[apex] ApexBadCrypto bug fix for #4427 - inline detection of hard coded values - [Steven Stearns](https://github.com/sfdcsteve) (@sfdcsteve) * [#4431](https://github.com/pmd/pmd/pull/4431): \[coco] CPD: Coco support for code duplication detection - [Wener](https://github.com/wener-tiobe) (@wener-tiobe) * [#4444](https://github.com/pmd/pmd/pull/4444): \[java] CommentDefaultAccessModifier - ignore org.junit.jupiter.api.extension.RegisterExtension by default - [Nirvik Patel](https://github.com/nirvikpatel) (@nirvikpatel) * [#4450](https://github.com/pmd/pmd/pull/4450): \[java] Fix #4449 AvoidAccessibilityAlteration: Correctly handle Lambda expressions in PrivilegedAction scenarios - [Seren](https://github.com/mohui1999) (@mohui1999) * [#4452](https://github.com/pmd/pmd/pull/4452): \[doc] Update PMD_APEX_ROOT_DIRECTORY documentation reference - [nwcm](https://github.com/nwcm) (@nwcm) * [#4470](https://github.com/pmd/pmd/pull/4470): \[cpp] CPD: Added strings as literal and ignore identifiers in sequences - [Wener](https://github.com/wener-tiobe) (@wener-tiobe) * [#4474](https://github.com/pmd/pmd/pull/4474): \[java] ImmutableField: False positive with lombok (fixes #4254) - [Pim van der Loos](https://github.com/PimvanderLoos) (@PimvanderLoos) * [#4488](https://github.com/pmd/pmd/pull/4488): \[java] Fix #4477: A false-positive about SignatureDeclareThrowsException - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4494](https://github.com/pmd/pmd/pull/4494): \[java] Fix #4487: A false-positive about UnnecessaryConstructor and @Inject and @Autowired - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4495](https://github.com/pmd/pmd/pull/4495): \[java] Fix #4493: false-positive about MissingStaticMethodInNonInstantiatableClass and @Inject - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4507](https://github.com/pmd/pmd/pull/4507): \[java] Fix #4503: A false negative about JUnitTestsShouldIncludeAssert and testng - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4520](https://github.com/pmd/pmd/pull/4520): \[doc] Fix typo: missing closing quotation mark after CPD-END - [JoΓ£o Dinis Ferreira](https://github.com/joaodinissf) (@joaodinissf) * [#4528](https://github.com/pmd/pmd/pull/4528): \[apex] Update to apexlink - [Kevin Jones](https://github.com/nawforce) (@nawforce) * [#4533](https://github.com/pmd/pmd/pull/4533): \[java] Fix #4063: False-negative about try/catch block in Loop - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4536](https://github.com/pmd/pmd/pull/4536): \[java] Fix #4268: CommentDefaultAccessModifier - false positive with TestNG's @Test annotation - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4537](https://github.com/pmd/pmd/pull/4537): \[java] Fix #4455: A false positive about FieldNamingConventions and UtilityClass - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4538](https://github.com/pmd/pmd/pull/4538): \[java] Fix #4456: A false positive about FinalFieldCouldBeStatic and UtilityClass - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4540](https://github.com/pmd/pmd/pull/4540): \[java] Fix #4457: false negative about OverrideBothEqualsAndHashcode - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4541](https://github.com/pmd/pmd/pull/4541): \[java] Fix #4458: A false positive about RedundantFieldInitializer and @Value - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4542](https://github.com/pmd/pmd/pull/4542): \[java] Fix #4510: A false positive about ConstructorCallsOverridableMethod and @Value - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4553](https://github.com/pmd/pmd/pull/4553): \[java] Fix #4492: GuardLogStatement gives false positive when argument is a Java method reference - [Anastasiia Koba](https://github.com/anastasiia-koba) (@anastasiia-koba) * [#4637](https://github.com/pmd/pmd/pull/4637): \[java] fix #4634 - JUnit4TestShouldUseTestAnnotation false positive with TestNG - [Krystian Dabrowski](https://github.com/krdabrowski) (@krdabrowski) * [#4649](https://github.com/pmd/pmd/pull/4649): \[apex] Add SObjectType and SObjectField to list of injectable SOQL variable types - [Richard Corfield](https://github.com/rcorfieldffdc) (@rcorfieldffdc) * [#4651](https://github.com/pmd/pmd/pull/4651): \[doc] Add "Tencent Cloud Code Analysis" in Tools / Integrations - [yale](https://github.com/cyw3) (@cyw3) * [#4664](https://github.com/pmd/pmd/pull/4664): \[cli] CPD: Fix NPE when only `--file-list` is specified - [Wener](https://github.com/wener-tiobe) (@wener-tiobe) * [#4665](https://github.com/pmd/pmd/pull/4665): \[java] Doc: Fix references AutoClosable -> AutoCloseable - [Andrey Bozhko](https://github.com/AndreyBozhko) (@AndreyBozhko) ### πŸ“ˆ Stats * 5007 commits * 658 closed tickets & PRs * Days since last release: 122 ## 30-May-2023 - 7.0.0-rc3 We're excited to bring you the next major version of PMD! Since this is a big release, we provide here only a concise version of the release notes. We prepared a separate page with the full [Detailed Release Notes for PMD 7.0.0](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_release_notes_pmd7.html).
ℹ️ Release Candidates

PMD 7.0.0 is finally almost ready. In order to gather feedback, we are going to ship a couple of release candidates. These are officially available on GitHub and Maven Central and can be used as usual (e.g. as a dependency). We encourage you to try out the new features, but keep in mind that we may introduce API breaking changes between the release candidates. It should be stable enough if you don't use custom rules.

We have still some tasks planned for the next release candidates. You can see the progress in PMD 7 Tracking Issue #3898.

If you find any problem or difficulty while updating from PMD 6, please provide feedback via our issue tracker. That way we can improve the experience for all.

### Table Of Contents * [Changes since 7.0.0-rc2](#changes-since-7.0.0-rc2) * [New CPD report format cpdhtml-v2.xslt](#new-cpd-report-format-cpdhtml-v2.xslt) * [Fixed issues](#fixed-issues) * [API Changes](#api-changes) * [External Contributions](#external-contributions) * [πŸš€ Major Features and Enhancements](#πŸš€-major-features-and-enhancements) * [New official logo](#new-official-logo) * [Revamped Java module](#revamped-java-module) * [Revamped Command Line Interface](#revamped-command-line-interface) * [Full Antlr support](#full-antlr-support) * [Updated PMD Designer](#updated-pmd-designer) * [New CPD report format cpdhtml-v2.xslt](#new-cpd-report-format-cpdhtml-v2.xslt) * [πŸŽ‰ Language Related Changes](#πŸŽ‰-language-related-changes) * [New: Swift support](#new:-swift-support) * [New: Kotlin support (experimental)](#new:-kotlin-support-(experimental)) * [New: CPD support for TypeScript](#new:-cpd-support-for-typescript) * [New: CPD support for Julia](#new:-cpd-support-for-julia) * [New: CPD support for Coco](#new:-cpd-support-for-coco) * [Changed: JavaScript support](#changed:-javascript-support) * [Changed: Language versions](#changed:-language-versions) * [Changed: CPP can now ignore identifiers in sequences (CPD)](#changed:-cpp-can-now-ignore-identifiers-in-sequences-(cpd)) * [🌟 New and changed rules](#🌟-new-and-changed-rules) * [New Rules](#new-rules) * [Changed Rules](#changed-rules) * [Removed Rules](#removed-rules) * [🚨 API](#🚨-api) * [πŸ’₯ Compatibility and migration notes](#πŸ’₯-compatibility-and-migration-notes) * [πŸ› Fixed Issues](#πŸ›-fixed-issues) * [✨ External Contributions](#✨-external-contributions) * [πŸ“ˆ Stats](#πŸ“ˆ-stats) ### Changes since 7.0.0-rc2 This section lists the most important changes from the last release candidate. The remaining section describes the complete release notes for 7.0.0. #### 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](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/report-examples/cpdhtml-v2.html). #### Fixed issues * miscellaneous * [#4460](https://github.com/pmd/pmd/pull/4460): Fix assembly-plugin warnings * core * [#4425](https://github.com/pmd/pmd/pull/4425): \[core] Replace TextFile::pathId * [#4454](https://github.com/pmd/pmd/issues/4454): \[core] "Unknown option: '-min'" but is referenced in documentation * java-bestpractices * [#4433](https://github.com/pmd/pmd/issues/4433): \[java] \[7.0-rc1] ReplaceHashtableWithMap on java.util.Properties * [#4492](https://github.com/pmd/pmd/issues/4492): \[java] GuardLogStatement gives false positive when argument is a Java method reference * [#4503](https://github.com/pmd/pmd/issues/4503): \[java] JUnitTestsShouldIncludeAssert: false negative with TestNG * java-codestyle * [#4268](https://github.com/pmd/pmd/issues/4268): \[java] CommentDefaultAccessModifier: false positive with TestNG annotations * [#4432](https://github.com/pmd/pmd/issues/4432): \[java] \[7.0-rc1] UnnecessaryImport - Unused static import is being used * [#4455](https://github.com/pmd/pmd/issues/4455): \[java] FieldNamingConventions: false positive with lombok's @UtilityClass * [#4557](https://github.com/pmd/pmd/issues/4557): \[java] UnnecessaryImport FP with static imports of overloaded methods * java-design * [#4434](https://github.com/pmd/pmd/issues/4434): \[java] \[7.0-rc1] ExceptionAsFlowControl when simply propagating * [#4456](https://github.com/pmd/pmd/issues/4456): \[java] FinalFieldCouldBeStatic: false positive with lombok's @UtilityClass * [#4549](https://github.com/pmd/pmd/pull/4549): \[java] Make LawOfDemeter results deterministic * java-errorprone * [#4063](https://github.com/pmd/pmd/issues/4063): \[java] AvoidBranchingStatementAsLastInLoop: False-negative about try/finally block * [#4457](https://github.com/pmd/pmd/issues/4457): \[java] OverrideBothEqualsAndHashcode: false negative with anonymous classes * [#4510](https://github.com/pmd/pmd/issues/4510): \[java] ConstructorCallsOverridableMethod: false positive with lombok's @Value * [#4546](https://github.com/pmd/pmd/issues/4546): \[java] OverrideBothEqualsAndHashCode ignores records * java-performance * [#4458](https://github.com/pmd/pmd/issues/4458): \[java] RedundantFieldInitializer: false positive with lombok's @Value #### API Changes * The following previously deprecated classes have been removed: * pmd-core * `net.sourceforge.pmd.PMD` * `net.sourceforge.pmd.cli.PMDCommandLineInterface` * `net.sourceforge.pmd.cli.PMDParameters` * `net.sourceforge.pmd.cli.PmdParametersParseResult` * The asset filenames of PMD on [GitHub Releases](https://github.com/pmd/pmd/releases) are now `pmd-dist--bin.zip`, `pmd-dist--src.zip` and `pmd-dist--doc.zip`. Keep that in mind, if you have an automated download script. The structure inside the ZIP files stay the same, e.g. we still provide inside the binary distribution ZIP file the base directory `pmd-bin-`. * The CLI option `--stress` (or `-stress`) has been removed without replacement. * The CLI option `--minimum-priority` was changed with 7.0.0-rc1 to only take the following values: High, Medium High, Medium, Medium Low, Low. With 7.0.0-rc2 compatibility has been restored, so that the equivalent integer values (1 to 5) are supported as well. * Replaced `RuleViolation::getFilename` with new RuleViolation#getFileId, that returns a FileId. This is an identifier for a TextFile and could represent a path name. This allows to have a separate display name, e.g. renderers use FileNameRenderer to either display the full path name or a relative path name (see Renderer#setFileNameRenderer and ConfigurableFileNameRenderer). Many places where we used a simple String for a path-like name before have been adapted to use the new FileId. See [PR #4425](https://github.com/pmd/pmd/pull/4425) for details. #### External Contributions * [#4426](https://github.com/pmd/pmd/pull/4426): \[cpd] New XML to HTML XLST report format for PMD CPD - [mohan-chinnappan-n](https://github.com/mohan-chinnappan-n) (@mohan-chinnappan-n) * [#4431](https://github.com/pmd/pmd/pull/4431): \[coco] CPD: Coco support for code duplication detection - [Wener](https://github.com/wener-tiobe) (@wener-tiobe) * [#4470](https://github.com/pmd/pmd/pull/4470): \[cpp] CPD: Added strings as literal and ignore identifiers in sequences - [Wener](https://github.com/wener-tiobe) (@wener-tiobe) * [#4507](https://github.com/pmd/pmd/pull/4507): \[java] Fix #4503: A false negative about JUnitTestsShouldIncludeAssert and testng - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4533](https://github.com/pmd/pmd/pull/4533): \[java] Fix #4063: False-negative about try/catch block in Loop - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4536](https://github.com/pmd/pmd/pull/4536): \[java] Fix #4268: CommentDefaultAccessModifier - false positive with TestNG's @Test annotation - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4537](https://github.com/pmd/pmd/pull/4537): \[java] Fix #4455: A false positive about FieldNamingConventions and UtilityClass - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4538](https://github.com/pmd/pmd/pull/4538): \[java] Fix #4456: A false positive about FinalFieldCouldBeStatic and UtilityClass - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4540](https://github.com/pmd/pmd/pull/4540): \[java] Fix #4457: false negative about OverrideBothEqualsAndHashcode - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4541](https://github.com/pmd/pmd/pull/4541): \[java] Fix #4458: A false positive about RedundantFieldInitializer and @Value - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4542](https://github.com/pmd/pmd/pull/4542): \[java] Fix #4510: A false positive about ConstructorCallsOverridableMethod and @Value - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4553](https://github.com/pmd/pmd/pull/4553): \[java] Fix #4492: GuardLogStatement gives false positive when argument is a Java method reference - [Anastasiia Koba](https://github.com/anastasiia-koba) (@anastasiia-koba) ### πŸš€ Major Features and Enhancements #### New official logo The new official logo of PMD: ![New PMD Logo](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/images/logo/pmd-logo-300px.png) #### Revamped Java module * Java grammar substantially refactored - more correct regarding the Java Language Specification (JLS) * Built-in rules have been upgraded for the changed AST * Rewritten type resolution framework and symbol table correctly implements the JLS * AST exposes more semantic information (method calls, field accesses) For more information, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_release_notes_pmd7.html). Contributors: [ClΓ©ment Fournier](https://github.com/oowekyala) (@oowekyala), [Andreas Dangel](https://github.com/adangel) (@adangel), [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) #### Revamped Command Line Interface * unified and consistent Command Line Interface for both Linux/Unix and Windows across our different utilities * single script `pmd` (`pmd.bat` for Windows) to launch the different utilities: * `pmd check` to run PMD rules and analyze a project * `pmd cpd` to run CPD (copy paste detector) * `pmd designer` to run the PMD Rule Designer * progress bar support for `pmd check` * shell completion ![Demo](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/images/userdocs/pmd-demo.gif) For more information, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_release_notes_pmd7.html). Contributors: [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) #### Full Antlr support * [Antlr](https://www.antlr.org/) based grammars can now be used to build full-fledged PMD rules. * Previously, Antlr grammar could only be used for CPD * New supported languages: Swift and Kotlin For more information, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_release_notes_pmd7.html). Contributors: [Lucas Soncini](https://github.com/lsoncini) (@lsoncini), [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga), [TomΓ‘s De Lucca](https://github.com/tomidelucca) (@tomidelucca) #### Updated PMD Designer This PMD release ships a new version of the pmd-designer. For the changes, see [PMD Designer Changelog](https://github.com/pmd/pmd-designer/releases/tag/7.0.0-rc1). #### 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](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/report-examples/cpdhtml-v2.html). ### πŸŽ‰ Language Related Changes Note that this is just a concise listing of the highlight. For more information on the languages, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_release_notes_pmd7.html). #### New: Swift support * use PMD to analyze Swift code with PMD rules * initially 4 built-in rules Contributors: [Lucas Soncini](https://github.com/lsoncini) (@lsoncini), [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga), [TomΓ‘s De Lucca](https://github.com/tomidelucca) (@tomidelucca) #### New: Kotlin support (experimental) * use PMD to analyze Kotlin code with PMD rules * Support for Kotlin 1.8 grammar * initially 2 built-in rules #### 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](https://github.com/pguyot) (@pguyot) #### 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](https://github.com/wener-tiobe) (@wener-tiobe) #### 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](https://github.com/wener-tiobe) (@wener-tiobe) #### Changed: JavaScript support * latest version supports ES6 and also some new constructs (see [Rhino](https://github.com/mozilla/rhino)]) * comments are retained #### Changed: Language versions * more predefined language versions for each supported language * can be used to limit rule execution for specific versions only with `minimumLanguageVersion` and `maximumLanguageVersion` attributes. #### Changed: CPP can now ignore identifiers in sequences (CPD) * new command line option for CPD: `--ignore-sequences`. * This option is used for CPP only: with the already existing option `--ignore-literal-sequences`, only literals were ignored. The new option additional ignores identifiers as well in sequences. * See [PR #4470](https://github.com/pmd/pmd/pull/4470) for details. ### 🌟 New and changed rules #### New Rules **Apex** * [`UnusedMethod`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_apex_design.html#unusedmethod) finds unused methods in your code. **Java** * [`UnnecessaryBoxing`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_codestyle.html#unnecessaryboxing) reports boxing and unboxing conversions that may be made implicit. **Kotlin** * [`FunctionNameTooShort`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_kotlin_bestpractices.html#functionnametooshort) * [`OverrideBothEqualsAndHashcode`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_kotlin_errorprone.html#overridebothequalsandhashcode) **Swift** * [`ProhibitedInterfaceBuilder`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_swift_bestpractices.html#prohibitedinterfacebuilder) * [`UnavailableFunction`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_swift_bestpractices.html#unavailablefunction) * [`ForceCast`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_swift_errorprone.html#forcecast) * [`ForceTry`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_swift_errorprone.html#forcetry) #### Changed Rules **General changes** * All statistical rules (like ExcessiveClassLength, ExcessiveParameterList) have been simplified and unified. The properties `topscore` and `sigma` have been removed. The property `minimum` is still there, however the type is not a decimal number anymore but has been changed to an integer. This affects rules in the languages Apex, Java, PLSQL and Velocity Template Language (vm): * Apex: [`ExcessiveClassLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_apex_design.html#excessiveclasslength), [`ExcessiveParameterList`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_apex_design.html#excessiveparameterlist), [`ExcessivePublicCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_apex_design.html#excessivepubliccount), [`NcssConstructorCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_apex_design.html#ncssconstructorcount), [`NcssMethodCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_apex_design.html#ncssmethodcount), [`NcssTypeCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_apex_design.html#ncsstypecount) * Java: [`ExcessiveImports`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_design.html#excessiveimports), [`ExcessiveParameterList`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_design.html#excessiveparameterlist), [`ExcessivePublicCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_design.html#excessivepubliccount), [`SwitchDensity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_design.html#switchdensity) * PLSQL: [`ExcessiveMethodLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_plsql_design.html#excessivemethodlength), [`ExcessiveObjectLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_plsql_design.html#excessiveobjectlength), [`ExcessivePackageBodyLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_plsql_design.html#excessivepackagebodylength), [`ExcessivePackageSpecificationLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_plsql_design.html#excessivepackagespecificationlength), [`ExcessiveParameterList`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_plsql_design.html#excessiveparameterlist), [`ExcessiveTypeLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_plsql_design.html#excessivetypelength), [`NcssMethodCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_plsql_design.html#ncssmethodcount), [`NcssObjectCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_plsql_design.html#ncssobjectcount), [`NPathComplexity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_plsql_design.html#npathcomplexity) * VM: [`ExcessiveTemplateLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_vm_design.html#excessivetemplatelength) * The general property `violationSuppressXPath` which is available for all rules to [suppress warnings](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_userdocs_suppressing_warnings.html) now uses XPath version 3.1 by default. This version of the XPath language is mostly identical to XPath 2.0. In PMD 6, XPath 1.0 has been used. If you upgrade from PMD 6, you need to verify your `violationSuppressXPath` properties. **Apex General changes** * The properties `cc_categories`, `cc_remediation_points_multiplier`, `cc_block_highlighting` have been removed from all rules. These properties have been deprecated since PMD 6.13.0. See [issue #1648](https://github.com/pmd/pmd/issues/1648) for more details. **Java General changes** * Violations reported on methods or classes previously reported the line range of the entire method or class. With PMD 7.0.0, the reported location is now just the identifier of the method or class. This affects various rules, e.g. [`CognitiveComplexity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_design.html#cognitivecomplexity). The report location is controlled by the overrides of the method getReportLocation in different node types. See [issue #4439](https://github.com/pmd/pmd/issues/4439) and [issue #730](https://github.com/pmd/pmd/issues/730) for more details. **Java Best Practices** * [`ArrayIsStoredDirectly`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_bestpractices.html#arrayisstoreddirectly): Violations are now reported on the assignment and not anymore on the formal parameter. The reported line numbers will probably move. * [`AvoidReassigningLoopVariables`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_bestpractices.html#avoidreassigningloopvariables): This rule might not report anymore all reassignments of the control variable in for-loops when the property `forReassign` is set to `skip`. See [issue #4500](https://github.com/pmd/pmd/issues/4500) for more details. * [`LooseCoupling`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_bestpractices.html#loosecoupling): The rule has a new property to allow some types to be coupled to (`allowedTypes`). * [`UnusedLocalVariable`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_bestpractices.html#unusedlocalvariable): This rule has some important false-negatives fixed and finds many more cases now. For details see issues [#2130](https://github.com/pmd/pmd/issues/2130), [#4516](https://github.com/pmd/pmd/issues/4516), and [#4517](https://github.com/pmd/pmd/issues/4517). **Java Codestyle** * [`MethodNamingConventions`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_codestyle.html#methodnamingconventions): The property `checkNativeMethods` has been removed. The property was deprecated since PMD 6.3.0. Use the property `nativePattern` to control whether native methods should be considered or not. * [`ShortVariable`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_codestyle.html#shortvariable): This rule now also reports short enum constant names. * [`UseDiamondOperator`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_codestyle.html#usediamondoperator): The property `java7Compatibility` has been removed. The rule now handles Java 7 properly without a property. * [`UnnecessaryFullyQualifiedName`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_codestyle.html#unnecessaryfullyqualifiedname): The rule has two new properties, to selectively disable reporting on static field and method qualifiers. The rule also has been improved to be more precise. * [`UselessParentheses`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_codestyle.html#uselessparentheses): The rule has two new properties which control how strict the rule should be applied. With `ignoreClarifying` (default: true) parentheses that are strictly speaking not necessary are allowed, if they separate expressions of different precedence. The other property `ignoreBalancing` (default: true) is similar, in that it allows parentheses that help reading and understanding the expressions. **Java Design** * [`CyclomaticComplexity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_design.html#cyclomaticcomplexity): The property `reportLevel` has been removed. The property was deprecated since PMD 6.0.0. The report level can now be configured separated for classes and methods using `classReportLevel` and `methodReportLevel` instead. * [`ImmutableField`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_design.html#immutablefield): The property `ignoredAnnotations` has been removed. The property was deprecated since PMD 6.52.0. * [`LawOfDemeter`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_design.html#lawofdemeter): The rule has a new property `trustRadius`. This defines the maximum degree of trusted data. The default of 1 is the most restrictive. * [`NPathComplexity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_design.html#npathcomplexity): The property `minimum` has been removed. It was deprecated since PMD 6.0.0. Use the property `reportLevel` instead. * [`SingularField`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_design.html#singularfield): The properties `checkInnerClasses` and `disallowNotAssignment` have been removed. The rule is now more precise and will check these cases properly. * [`UseUtilityClass`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_design.html#useutilityclass): The property `ignoredAnnotations` has been removed. **Java Documentation** * [`CommentContent`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_documentation.html#commentcontent): The properties `caseSensitive` and `disallowedTerms` are removed. The new property `forbiddenRegex` can be used now to define the disallowed terms with a single regular expression. * [`CommentRequired`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_documentation.html#commentrequired): * Overridden methods are now detected even without the `@Override` annotation. This is relevant for the property `methodWithOverrideCommentRequirement`. See also [pull request #3757](https://github.com/pmd/pmd/pull/3757). * Elements in annotation types are now detected as well. This might lead to an increased number of violations for missing public method comments. * [`CommentSize`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_documentation.html#commentsize): When determining the line-length of a comment, the leading comment prefix markers (e.g. `*` or `//`) are ignored and don't add up to the line-length. See also [pull request #4369](https://github.com/pmd/pmd/pull/4369). **Java Error Prone** * [`AvoidDuplicateLiterals`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_errorprone.html#avoidduplicateliterals): The property `exceptionfile` has been removed. The property was deprecated since PMD 6.10.0. Use the property `exceptionList` instead. * [`DontImportSun`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_errorprone.html#dontimportsun): `sun.misc.Signal` is not special-cased anymore. * [`EmptyCatchBlock`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_errorprone.html#emptycatchblock): `CloneNotSupportedException` and `InterruptedException` are not special-cased anymore. Rename the exception parameter to `ignored` to ignore them. * [`ImplicitSwitchFallThrough`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_rules_java_errorprone.html#implicitswitchfallthrough): Violations are now reported on the case statements rather than on the switch statements. This is more accurate but might result in more violations now. #### Removed Rules Many rules, that were previously deprecated have been finally removed. See [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_release_notes_pmd7.html) for the complete list. ### 🚨 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. Also, there are some improvement and changes in different areas. For the detailed description of the changes listed here, see [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_release_notes_pmd7.html). * Miscellaneous smaller changes and cleanups * XPath 3.1 support for XPath-based rules * Node stream API for AST traversal * Metrics framework * Testing framework * Language Lifecycle and Language Properties ### πŸ’₯ Compatibility and migration notes See [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc3/pmd_release_notes_pmd7.html). ### πŸ› Fixed Issues * miscellaneous * [#881](https://github.com/pmd/pmd/issues/881): \[all] Breaking API changes for 7.0.0 * [#896](https://github.com/pmd/pmd/issues/896): \[all] Use slf4j * [#1431](https://github.com/pmd/pmd/pull/1431): \[ui] Remove old GUI applications (designerold, bgastviewer) * [#1451](https://github.com/pmd/pmd/issues/1451): \[core] RulesetFactoryCompatibility stores the whole ruleset file in memory as a string * [#2496](https://github.com/pmd/pmd/issues/2496): Update PMD 7 Logo on landing page * [#2497](https://github.com/pmd/pmd/issues/2497): PMD 7 Logo page * [#2498](https://github.com/pmd/pmd/issues/2498): Update PMD 7 Logo in documentation * [#3797](https://github.com/pmd/pmd/issues/3797): \[all] Use JUnit5 * [#4462](https://github.com/pmd/pmd/issues/4462): Provide Software Bill of Materials (SBOM) * [#4460](https://github.com/pmd/pmd/pull/4460): Fix assembly-plugin warnings * ant * [#4080](https://github.com/pmd/pmd/issues/4080): \[ant] Split off Ant integration into a new submodule * core * [#880](https://github.com/pmd/pmd/issues/880): \[core] Make visitors generic * [#1622](https://github.com/pmd/pmd/pull/1622): \[core] NodeStream API * [#1687](https://github.com/pmd/pmd/issues/1687): \[core] Deprecate and Remove XPath 1.0 support * [#1785](https://github.com/pmd/pmd/issues/1785): \[core] Allow abstract node types to be valid rulechain visits * [#1825](https://github.com/pmd/pmd/pull/1825): \[core] Support NoAttribute for XPath * [#2038](https://github.com/pmd/pmd/issues/2038): \[core] Remove DCD * [#2218](https://github.com/pmd/pmd/issues/2218): \[core] `isFindBoundary` should not be an attribute * [#2234](https://github.com/pmd/pmd/issues/2234): \[core] Consolidate PMD CLI into a single command * [#2239](https://github.com/pmd/pmd/issues/2239): \[core] Merging Javacc build scripts * [#2500](https://github.com/pmd/pmd/issues/2500): \[core] Clarify API for ANTLR based languages * [#2518](https://github.com/pmd/pmd/issues/2518): \[core] Language properties * [#2602](https://github.com/pmd/pmd/issues/2602): \[core] Remove ParserOptions * [#2614](https://github.com/pmd/pmd/pull/2614): \[core] Upgrade Saxon, add XPath 3.1, remove Jaxen * [#2696](https://github.com/pmd/pmd/pull/2696): \[core] Remove DFA * [#2821](https://github.com/pmd/pmd/issues/2821): \[core] Rule processing error filenames are missing paths * [#2873](https://github.com/pmd/pmd/issues/2873): \[core] Utility classes in pmd 7 * [#2885](https://github.com/pmd/pmd/issues/2885): \[core] Error recovery mode * [#3203](https://github.com/pmd/pmd/issues/3203): \[core] Replace RuleViolationFactory implementations with ViolationDecorator * [#3692](https://github.com/pmd/pmd/pull/3692): \[core] Analysis listeners * [#3782](https://github.com/pmd/pmd/issues/3782): \[core] Language lifecycle * [#3815](https://github.com/pmd/pmd/issues/3815): \[core] Update Saxon HE to 10.7 * [#3893](https://github.com/pmd/pmd/pull/3893): \[core] Text documents * [#3902](https://github.com/pmd/pmd/issues/3902): \[core] Violation decorators * [#3918](https://github.com/pmd/pmd/issues/3918): \[core] Make LanguageRegistry non static * [#3922](https://github.com/pmd/pmd/pull/3922): \[core] Better error reporting for the ruleset parser * [#4035](https://github.com/pmd/pmd/issues/4035): \[core] ConcurrentModificationException in DefaultRuleViolationFactory * [#4120](https://github.com/pmd/pmd/issues/4120): \[core] Explicitly name all language versions * [#4353](https://github.com/pmd/pmd/pull/4353): \[core] Micro optimizations for Node API * [#4365](https://github.com/pmd/pmd/pull/4365): \[core] Improve benchmarking * [#4420](https://github.com/pmd/pmd/pull/4420): \[core] Remove PMD.EOL * [#4425](https://github.com/pmd/pmd/pull/4425): \[core] Replace TextFile::pathId * [#4454](https://github.com/pmd/pmd/issues/4454): \[core] "Unknown option: '-min'" but is referenced in documentation * cli * [#2234](https://github.com/pmd/pmd/issues/2234): \[core] Consolidate PMD CLI into a single command * [#3828](https://github.com/pmd/pmd/issues/3828): \[core] Progress reporting * [#4079](https://github.com/pmd/pmd/issues/4079): \[cli] Split off CLI implementation into a pmd-cli submodule * [#4482](https://github.com/pmd/pmd/issues/4482): \[cli] pmd.bat can only be executed once * [#4484](https://github.com/pmd/pmd/issues/4484): \[cli] ast-dump with no properties produce an NPE * doc * [#2501](https://github.com/pmd/pmd/issues/2501): \[doc] Verify ANTLR Documentation * [#4438](https://github.com/pmd/pmd/issues/4438): \[doc] Documentation links in VS Code are outdated * testing * [#2435](https://github.com/pmd/pmd/issues/2435): \[test] Remove duplicated Dummy language module * [#4234](https://github.com/pmd/pmd/issues/4234): \[test] Tests that change the logging level do not work Language specific fixes: * apex * [#1937](https://github.com/pmd/pmd/issues/1937): \[apex] Apex should only have a single RootNode * [#1648](https://github.com/pmd/pmd/issues/1648): \[apex,vf] Remove CodeClimate dependency * [#1750](https://github.com/pmd/pmd/pull/1750): \[apex] Remove apex statistical rules * [#2836](https://github.com/pmd/pmd/pull/2836): \[apex] Remove Apex ProjectMirror * [#4427](https://github.com/pmd/pmd/issues/4427): \[apex] ApexBadCrypto test failing to detect inline code * apex-design * [#2667](https://github.com/pmd/pmd/issues/2667): \[apex] Integrate nawforce/ApexLink to build robust Unused rule * [#4509](https://github.com/pmd/pmd/issues/4509): \[apex] ExcessivePublicCount doesn't consider inner classes correctly * java * [#520](https://github.com/pmd/pmd/issues/520): \[java] Allow `@SuppressWarnings` with constants instead of literals * [#864](https://github.com/pmd/pmd/issues/864): \[java] Similar/duplicated implementations for determining FQCN * [#905](https://github.com/pmd/pmd/issues/905): \[java] Add new node for anonymous class declaration * [#910](https://github.com/pmd/pmd/issues/910): \[java] AST inconsistency between primitive and reference type arrays * [#997](https://github.com/pmd/pmd/issues/997): \[java] Java8 parsing corner case with annotated array types * [#998](https://github.com/pmd/pmd/issues/998): \[java] AST inconsistencies around FormalParameter * [#1019](https://github.com/pmd/pmd/issues/1019): \[java] Breaking Java Grammar changes for PMD 7.0.0 * [#1124](https://github.com/pmd/pmd/issues/1124): \[java] ImmutableList implementation in the qname codebase * [#1128](https://github.com/pmd/pmd/issues/1128): \[java] Improve ASTLocalVariableDeclaration * [#1150](https://github.com/pmd/pmd/issues/1150): \[java] ClassOrInterfaceType AST improvements * [#1207](https://github.com/pmd/pmd/issues/1207): \[java] Resolve explicit types using FQCNs, without hitting the classloader * [#1367](https://github.com/pmd/pmd/issues/1367): \[java] Parsing error on annotated inner class * [#1661](https://github.com/pmd/pmd/issues/1661): \[java] About operator nodes * [#2366](https://github.com/pmd/pmd/pull/2366): \[java] Remove qualified names * [#2819](https://github.com/pmd/pmd/issues/2819): \[java] GLB bugs in pmd 7 * [#3642](https://github.com/pmd/pmd/issues/3642): \[java] Parse error on rare extra dimensions on method return type on annotation methods * [#3763](https://github.com/pmd/pmd/issues/3763): \[java] Ambiguous reference error in valid code * [#3749](https://github.com/pmd/pmd/issues/3749): \[java] Improve `isOverridden` in ASTMethodDeclaration * [#3750](https://github.com/pmd/pmd/issues/3750): \[java] Make symbol table support instanceof pattern bindings * [#3752](https://github.com/pmd/pmd/issues/3752): \[java] Expose annotations in symbol API * [#4237](https://github.com/pmd/pmd/pull/4237): \[java] Cleanup handling of Java comments * [#4317](https://github.com/pmd/pmd/issues/4317): \[java] Some AST nodes should not be TypeNodes * [#4359](https://github.com/pmd/pmd/issues/4359): \[java] Type resolution fails with NPE when the scope is not a type declaration * [#4367](https://github.com/pmd/pmd/issues/4367): \[java] Move testrule TypeResTest into internal * [#4383](https://github.com/pmd/pmd/issues/4383): \[java] IllegalStateException: Object is not an array type! * [#4405](https://github.com/pmd/pmd/issues/4405): \[java] Processing error with ArrayIndexOutOfBoundsException * java-bestpractices * [#342](https://github.com/pmd/pmd/issues/342): \[java] AccessorMethodGeneration: Name clash with another public field not properly handled * [#755](https://github.com/pmd/pmd/issues/755): \[java] AccessorClassGeneration false positive for private constructors * [#770](https://github.com/pmd/pmd/issues/770): \[java] UnusedPrivateMethod yields false positive for counter-variant arguments * [#807](https://github.com/pmd/pmd/issues/807): \[java] AccessorMethodGeneration false positive with overloads * [#833](https://github.com/pmd/pmd/issues/833): \[java] ForLoopCanBeForeach should consider iterating on this * [#1189](https://github.com/pmd/pmd/issues/1189): \[java] UnusedPrivateMethod false positive from inner class via external class * [#1205](https://github.com/pmd/pmd/issues/1205): \[java] Improve ConstantsInInterface message to mention alternatives * [#1212](https://github.com/pmd/pmd/issues/1212): \[java] Don't raise JUnitTestContainsTooManyAsserts on JUnit 5's assertAll * [#1422](https://github.com/pmd/pmd/issues/1422): \[java] JUnitTestsShouldIncludeAssert false positive with inherited @Rule field * [#1455](https://github.com/pmd/pmd/issues/1455): \[java] JUnitTestsShouldIncludeAssert: False positives for assert methods named "check" and "verify" * [#1563](https://github.com/pmd/pmd/issues/1563): \[java] ForLoopCanBeForeach false positive with method call using index variable * [#1565](https://github.com/pmd/pmd/issues/1565): \[java] JUnitAssertionsShouldIncludeMessage false positive with AssertJ * [#1747](https://github.com/pmd/pmd/issues/1747): \[java] PreserveStackTrace false-positive * [#1969](https://github.com/pmd/pmd/issues/1969): \[java] MissingOverride false-positive triggered by package-private method overwritten in another package by extending class * [#1998](https://github.com/pmd/pmd/issues/1998): \[java] AccessorClassGeneration false-negative: subclass calls private constructor * [#2130](https://github.com/pmd/pmd/issues/2130): \[java] UnusedLocalVariable: false-negative with array * [#2147](https://github.com/pmd/pmd/issues/2147): \[java] JUnitTestsShouldIncludeAssert - false positives with lambdas and static methods * [#2464](https://github.com/pmd/pmd/issues/2464): \[java] LooseCoupling must ignore class literals: ArrayList.class * [#2542](https://github.com/pmd/pmd/issues/2542): \[java] UseCollectionIsEmpty can not detect the case `foo.bar().size()` * [#2650](https://github.com/pmd/pmd/issues/2650): \[java] UseTryWithResources false positive when AutoCloseable helper used * [#2796](https://github.com/pmd/pmd/issues/2796): \[java] UnusedAssignment false positive with call chains * [#2797](https://github.com/pmd/pmd/issues/2797): \[java] MissingOverride long-standing issues * [#2806](https://github.com/pmd/pmd/issues/2806): \[java] SwitchStmtsShouldHaveDefault false-positive with Java 14 switch non-fallthrough branches * [#2822](https://github.com/pmd/pmd/issues/2822): \[java] LooseCoupling rule: Extend to cover user defined implementations and interfaces * [#2843](https://github.com/pmd/pmd/pull/2843): \[java] Fix UnusedAssignment FP with field accesses * [#2882](https://github.com/pmd/pmd/issues/2882): \[java] UseTryWithResources - false negative for explicit close * [#2883](https://github.com/pmd/pmd/issues/2883): \[java] JUnitAssertionsShouldIncludeMessage false positive with method call * [#2890](https://github.com/pmd/pmd/issues/2890): \[java] UnusedPrivateMethod false positive with generics * [#2946](https://github.com/pmd/pmd/issues/2946): \[java] SwitchStmtsShouldHaveDefault false positive on enum inside enums * [#3672](https://github.com/pmd/pmd/pull/3672): \[java] LooseCoupling - fix false positive with generics * [#3675](https://github.com/pmd/pmd/pull/3675): \[java] MissingOverride - fix false positive with mixing type vars * [#3858](https://github.com/pmd/pmd/issues/3858): \[java] UseCollectionIsEmpty should infer local variable type from method invocation * [#4433](https://github.com/pmd/pmd/issues/4433): \[java] \[7.0-rc1] ReplaceHashtableWithMap on java.util.Properties * [#4492](https://github.com/pmd/pmd/issues/4492): \[java] GuardLogStatement gives false positive when argument is a Java method reference * [#4503](https://github.com/pmd/pmd/issues/4503): \[java] JUnitTestsShouldIncludeAssert: false negative with TestNG * [#4516](https://github.com/pmd/pmd/issues/4516): \[java] UnusedLocalVariable: false-negative with try-with-resources * [#4517](https://github.com/pmd/pmd/issues/4517): \[java] UnusedLocalVariable: false-negative with compound assignments * [#4518](https://github.com/pmd/pmd/issues/4518): \[java] UnusedLocalVariable: false-positive with multiple for-loop indices * java-codestyle * [#1208](https://github.com/pmd/pmd/issues/1208): \[java] PrematureDeclaration rule false-positive on variable declared to measure time * [#1429](https://github.com/pmd/pmd/issues/1429): \[java] PrematureDeclaration as result of method call (false positive) * [#1480](https://github.com/pmd/pmd/issues/1480): \[java] IdenticalCatchBranches false positive with return expressions * [#1673](https://github.com/pmd/pmd/issues/1673): \[java] UselessParentheses false positive with conditional operator * [#1790](https://github.com/pmd/pmd/issues/1790): \[java] UnnecessaryFullyQualifiedName false positive with enum constant * [#1918](https://github.com/pmd/pmd/issues/1918): \[java] UselessParentheses false positive with boolean operators * [#2134](https://github.com/pmd/pmd/issues/2134): \[java] PreserveStackTrace not handling `Throwable.addSuppressed(...)` * [#2299](https://github.com/pmd/pmd/issues/2299): \[java] UnnecessaryFullyQualifiedName false positive with similar package name * [#2391](https://github.com/pmd/pmd/issues/2391): \[java] UseDiamondOperator FP when expected type and constructed type have a different parameterization * [#2528](https://github.com/pmd/pmd/issues/2528): \[java] MethodNamingConventions - JUnit 5 method naming not support ParameterizedTest * [#2739](https://github.com/pmd/pmd/issues/2739): \[java] UselessParentheses false positive for string concatenation * [#2748](https://github.com/pmd/pmd/issues/2748): \[java] UnnecessaryCast false positive with unchecked cast * [#2973](https://github.com/pmd/pmd/issues/2973): \[java] New rule: UnnecessaryBoxing * [#3195](https://github.com/pmd/pmd/pull/3195): \[java] Improve rule UnnecessaryReturn to detect more cases * [#3218](https://github.com/pmd/pmd/pull/3218): \[java] Generalize UnnecessaryCast to flag all unnecessary casts * [#3221](https://github.com/pmd/pmd/issues/3221): \[java] PrematureDeclaration false positive for unused variables * [#3238](https://github.com/pmd/pmd/issues/3238): \[java] Improve ExprContext, fix FNs of UnnecessaryCast * [#3500](https://github.com/pmd/pmd/pull/3500): \[java] UnnecessaryBoxing - check for Integer.valueOf(String) calls * [#4268](https://github.com/pmd/pmd/issues/4268): \[java] CommentDefaultAccessModifier: false positive with TestNG annotations * [#4273](https://github.com/pmd/pmd/issues/4273): \[java] CommentDefaultAccessModifier ignoredAnnotations should include "org.junit.jupiter.api.extension.RegisterExtension" by default * [#4357](https://github.com/pmd/pmd/pull/4357): \[java] Fix IllegalStateException in UseDiamondOperator rule * [#4432](https://github.com/pmd/pmd/issues/4432): \[java] \[7.0-rc1] UnnecessaryImport - Unused static import is being used * [#4455](https://github.com/pmd/pmd/issues/4455): \[java] FieldNamingConventions: false positive with lombok's @UtilityClass * [#4487](https://github.com/pmd/pmd/issues/4487): \[java] UnnecessaryConstructor: false-positive with @Inject and @Autowired * [#4511](https://github.com/pmd/pmd/issues/4511): \[java] LocalVariableCouldBeFinal shouldn't report unused variables * [#4512](https://github.com/pmd/pmd/issues/4512): \[java] MethodArgumentCouldBeFinal shouldn't report unused parameters * [#4557](https://github.com/pmd/pmd/issues/4557): \[java] UnnecessaryImport FP with static imports of overloaded methods * java-design * [#1014](https://github.com/pmd/pmd/issues/1014): \[java] LawOfDemeter: False positive with lambda expression * [#1605](https://github.com/pmd/pmd/issues/1605): \[java] LawOfDemeter: False positive for standard UTF-8 charset name * [#2160](https://github.com/pmd/pmd/issues/2160): \[java] Issues with Law of Demeter * [#2175](https://github.com/pmd/pmd/issues/2175): \[java] LawOfDemeter: False positive for chained methods with generic method call * [#2179](https://github.com/pmd/pmd/issues/2179): \[java] LawOfDemeter: False positive with static property access - should treat class-level property as global object, not dot-accessed property * [#2180](https://github.com/pmd/pmd/issues/2180): \[java] LawOfDemeter: False positive with Thread and ThreadLocalRandom * [#2182](https://github.com/pmd/pmd/issues/2182): \[java] LawOfDemeter: False positive with package-private access * [#2188](https://github.com/pmd/pmd/issues/2188): \[java] LawOfDemeter: False positive with fields assigned to local vars * [#2536](https://github.com/pmd/pmd/issues/2536): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal can't detect inner class * [#3668](https://github.com/pmd/pmd/pull/3668): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal - fix FP with inner private classes * [#3754](https://github.com/pmd/pmd/issues/3754): \[java] SingularField false positive with read in while condition * [#3786](https://github.com/pmd/pmd/issues/3786): \[java] SimplifyBooleanReturns should consider operator precedence * [#3840](https://github.com/pmd/pmd/issues/3840): \[java] LawOfDemeter disallows method call on locally created object * [#4238](https://github.com/pmd/pmd/pull/4238): \[java] Make LawOfDemeter not use the rulechain * [#4254](https://github.com/pmd/pmd/issues/4254): \[java] ImmutableField - false positive with Lombok @Setter * [#4434](https://github.com/pmd/pmd/issues/4434): \[java] \[7.0-rc1] ExceptionAsFlowControl when simply propagating * [#4456](https://github.com/pmd/pmd/issues/4456): \[java] FinalFieldCouldBeStatic: false positive with lombok's @UtilityClass * [#4477](https://github.com/pmd/pmd/issues/4477): \[java] SignatureDeclareThrowsException: false-positive with TestNG annotations * [#4490](https://github.com/pmd/pmd/issues/4490): \[java] ImmutableField - false negative with Lombok @Getter * [#4549](https://github.com/pmd/pmd/pull/4549): \[java] Make LawOfDemeter results deterministic * java-documentation * [#4369](https://github.com/pmd/pmd/pull/4369): \[java] Improve CommentSize * [#4416](https://github.com/pmd/pmd/pull/4416): \[java] Fix reported line number in CommentContentRule * java-errorprone * [#659](https://github.com/pmd/pmd/issues/659): \[java] MissingBreakInSwitch - last default case does not contain a break * [#1005](https://github.com/pmd/pmd/issues/1005): \[java] CloneMethodMustImplementCloneable triggers for interfaces * [#1669](https://github.com/pmd/pmd/issues/1669): \[java] NullAssignment - FP with ternay and null as constructor argument * [#1899](https://github.com/pmd/pmd/issues/1899): \[java] Recognize @SuppressWanings("fallthrough") for MissingBreakInSwitch * [#2320](https://github.com/pmd/pmd/issues/2320): \[java] NullAssignment - FP with ternary and null as method argument * [#2532](https://github.com/pmd/pmd/issues/2532): \[java] AvoidDecimalLiteralsInBigDecimalConstructor can not detect the case `new BigDecimal(Expression)` * [#2579](https://github.com/pmd/pmd/issues/2579): \[java] MissingBreakInSwitch detects the lack of break in the last case * [#2880](https://github.com/pmd/pmd/issues/2880): \[java] CompareObjectsWithEquals - false negative with type res * [#2893](https://github.com/pmd/pmd/issues/2893): \[java] Remove special cases from rule EmptyCatchBlock * [#2894](https://github.com/pmd/pmd/issues/2894): \[java] Improve MissingBreakInSwitch * [#3071](https://github.com/pmd/pmd/issues/3071): \[java] BrokenNullCheck FP with PMD 6.30.0 * [#3087](https://github.com/pmd/pmd/issues/3087): \[java] UnnecessaryBooleanAssertion overlaps with SimplifiableTestAssertion * [#3100](https://github.com/pmd/pmd/issues/3100): \[java] UseCorrectExceptionLogging FP in 6.31.0 * [#3173](https://github.com/pmd/pmd/issues/3173): \[java] UseProperClassLoader false positive * [#3351](https://github.com/pmd/pmd/issues/3351): \[java] ConstructorCallsOverridableMethod ignores abstract methods * [#3400](https://github.com/pmd/pmd/issues/3400): \[java] AvoidUsingOctalValues FN with underscores * [#3843](https://github.com/pmd/pmd/issues/3843): \[java] UseEqualsToCompareStrings should consider return type * [#4063](https://github.com/pmd/pmd/issues/4063): \[java] AvoidBranchingStatementAsLastInLoop: False-negative about try/finally block * [#4356](https://github.com/pmd/pmd/pull/4356): \[java] Fix NPE in CloseResourceRule * [#4449](https://github.com/pmd/pmd/issues/4449): \[java] AvoidAccessibilityAlteration: Possible false positive in AvoidAccessibilityAlteration rule when using Lambda expression * [#4457](https://github.com/pmd/pmd/issues/4457): \[java] OverrideBothEqualsAndHashcode: false negative with anonymous classes * [#4493](https://github.com/pmd/pmd/issues/4493): \[java] MissingStaticMethodInNonInstantiatableClass: false-positive about @Inject * [#4505](https://github.com/pmd/pmd/issues/4505): \[java] ImplicitSwitchFallThrough NPE in PMD 7.0.0-rc1 * [#4510](https://github.com/pmd/pmd/issues/4510): \[java] ConstructorCallsOverridableMethod: false positive with lombok's @Value * [#4513](https://github.com/pmd/pmd/issues/4513): \[java] UselessOperationOnImmutable various false negatives with String * [#4514](https://github.com/pmd/pmd/issues/4514): \[java] AvoidLiteralsInIfCondition false positive and negative for String literals when ignoreExpressions=true * [#4546](https://github.com/pmd/pmd/issues/4546): \[java] OverrideBothEqualsAndHashCode ignores records * java-multithreading * [#2537](https://github.com/pmd/pmd/issues/2537): \[java] DontCallThreadRun can't detect the case that call run() in `this.run()` * [#2538](https://github.com/pmd/pmd/issues/2538): \[java] DontCallThreadRun can't detect the case that call run() in `foo.bar.run()` * [#2577](https://github.com/pmd/pmd/issues/2577): \[java] UseNotifyAllInsteadOfNotify falsely detect a special case with argument: `foo.notify(bar)` * [#4483](https://github.com/pmd/pmd/issues/4483): \[java] NonThreadSafeSingleton false positive with double-checked locking * java-performance * [#1224](https://github.com/pmd/pmd/issues/1224): \[java] InefficientEmptyStringCheck false negative in anonymous class * [#2587](https://github.com/pmd/pmd/issues/2587): \[java] AvoidArrayLoops could also check for list copy through iterated List.add() * [#2712](https://github.com/pmd/pmd/issues/2712): \[java] SimplifyStartsWith false-positive with AssertJ * [#3486](https://github.com/pmd/pmd/pull/3486): \[java] InsufficientStringBufferDeclaration: Fix NPE * [#3848](https://github.com/pmd/pmd/issues/3848): \[java] StringInstantiation: false negative when using method result * [#4070](https://github.com/pmd/pmd/issues/4070): \[java] A false positive about the rule RedundantFieldInitializer * [#4458](https://github.com/pmd/pmd/issues/4458): \[java] RedundantFieldInitializer: false positive with lombok's @Value * kotlin * [#419](https://github.com/pmd/pmd/issues/419): \[kotlin] Add support for Kotlin * [#4389](https://github.com/pmd/pmd/pull/4389): \[kotlin] Update grammar to version 1.8 * swift * [#1877](https://github.com/pmd/pmd/pull/1877): \[swift] Feature/swift rules * [#1882](https://github.com/pmd/pmd/pull/1882): \[swift] UnavailableFunction Swift rule * xml * [#1800](https://github.com/pmd/pmd/pull/1800): \[xml] Unimplement org.w3c.dom.Node from the XmlNodeWrapper ### ✨ External Contributions * [#1658](https://github.com/pmd/pmd/pull/1658): \[core] Node support for Antlr-based languages - [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga) * [#1698](https://github.com/pmd/pmd/pull/1698): \[core] [swift] Antlr Base Parser adapter and Swift Implementation - [Lucas Soncini](https://github.com/lsoncini) (@lsoncini) * [#1774](https://github.com/pmd/pmd/pull/1774): \[core] Antlr visitor rules - [Lucas Soncini](https://github.com/lsoncini) (@lsoncini) * [#1877](https://github.com/pmd/pmd/pull/1877): \[swift] Feature/swift rules - [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga) * [#1881](https://github.com/pmd/pmd/pull/1881): \[doc] Add ANTLR documentation - [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga) * [#1882](https://github.com/pmd/pmd/pull/1882): \[swift] UnavailableFunction Swift rule - [TomΓ‘s de Lucca](https://github.com/tomidelucca) (@tomidelucca) * [#2830](https://github.com/pmd/pmd/pull/2830): \[apex] Apexlink POC - [Kevin Jones](https://github.com/nawforce) (@nawforce) * [#3866](https://github.com/pmd/pmd/pull/3866): \[core] Add CLI Progress Bar - [@JerritEic](https://github.com/JerritEic) (@JerritEic) * [#4402](https://github.com/pmd/pmd/pull/4402): \[javascript] CPD: add support for Typescript using antlr4 grammar - [Paul Guyot](https://github.com/pguyot) (@pguyot) * [#4403](https://github.com/pmd/pmd/pull/4403): \[julia] CPD: Add support for Julia code duplication - [Wener](https://github.com/wener-tiobe) (@wener-tiobe) * [#4412](https://github.com/pmd/pmd/pull/4412): \[doc] Added new error msg to ConstantsInInterface - [David Ljunggren](https://github.com/dague1) (@dague1) * [#4426](https://github.com/pmd/pmd/pull/4426): \[cpd] New XML to HTML XLST report format for PMD CPD - [mohan-chinnappan-n](https://github.com/mohan-chinnappan-n) (@mohan-chinnappan-n) * [#4428](https://github.com/pmd/pmd/pull/4428): \[apex] ApexBadCrypto bug fix for #4427 - inline detection of hard coded values - [Steven Stearns](https://github.com/sfdcsteve) (@sfdcsteve) * [#4431](https://github.com/pmd/pmd/pull/4431): \[coco] CPD: Coco support for code duplication detection - [Wener](https://github.com/wener-tiobe) (@wener-tiobe) * [#4444](https://github.com/pmd/pmd/pull/4444): \[java] CommentDefaultAccessModifier - ignore org.junit.jupiter.api.extension.RegisterExtension by default - [Nirvik Patel](https://github.com/nirvikpatel) (@nirvikpatel) * [#4450](https://github.com/pmd/pmd/pull/4450): \[java] Fix #4449 AvoidAccessibilityAlteration: Correctly handle Lambda expressions in PrivilegedAction scenarios - [Seren](https://github.com/mohui1999) (@mohui1999) * [#4452](https://github.com/pmd/pmd/pull/4452): \[doc] Update PMD_APEX_ROOT_DIRECTORY documentation reference - [nwcm](https://github.com/nwcm) (@nwcm) * [#4470](https://github.com/pmd/pmd/pull/4470): \[cpp] CPD: Added strings as literal and ignore identifiers in sequences - [Wener](https://github.com/wener-tiobe) (@wener-tiobe) * [#4474](https://github.com/pmd/pmd/pull/4474): \[java] ImmutableField: False positive with lombok (fixes #4254) - [Pim van der Loos](https://github.com/PimvanderLoos) (@PimvanderLoos) * [#4488](https://github.com/pmd/pmd/pull/4488): \[java] Fix #4477: A false-positive about SignatureDeclareThrowsException - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4494](https://github.com/pmd/pmd/pull/4494): \[java] Fix #4487: A false-positive about UnnecessaryConstructor and @Inject and @Autowired - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4495](https://github.com/pmd/pmd/pull/4495): \[java] Fix #4493: false-positive about MissingStaticMethodInNonInstantiatableClass and @Inject - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4507](https://github.com/pmd/pmd/pull/4507): \[java] Fix #4503: A false negative about JUnitTestsShouldIncludeAssert and testng - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4520](https://github.com/pmd/pmd/pull/4520): \[doc] Fix typo: missing closing quotation mark after CPD-END - [JoΓ£o Dinis Ferreira](https://github.com/joaodinissf) (@joaodinissf) * [#4533](https://github.com/pmd/pmd/pull/4533): \[java] Fix #4063: False-negative about try/catch block in Loop - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4536](https://github.com/pmd/pmd/pull/4536): \[java] Fix #4268: CommentDefaultAccessModifier - false positive with TestNG's @Test annotation - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4537](https://github.com/pmd/pmd/pull/4537): \[java] Fix #4455: A false positive about FieldNamingConventions and UtilityClass - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4538](https://github.com/pmd/pmd/pull/4538): \[java] Fix #4456: A false positive about FinalFieldCouldBeStatic and UtilityClass - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4540](https://github.com/pmd/pmd/pull/4540): \[java] Fix #4457: false negative about OverrideBothEqualsAndHashcode - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4541](https://github.com/pmd/pmd/pull/4541): \[java] Fix #4458: A false positive about RedundantFieldInitializer and @Value - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4542](https://github.com/pmd/pmd/pull/4542): \[java] Fix #4510: A false positive about ConstructorCallsOverridableMethod and @Value - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4553](https://github.com/pmd/pmd/pull/4553): \[java] Fix #4492: GuardLogStatement gives false positive when argument is a Java method reference - [Anastasiia Koba](https://github.com/anastasiia-koba) (@anastasiia-koba) ### πŸ“ˆ Stats * 4694 commits * 617 closed tickets & PRs * Days since last release: 30 ## 29-April-2023 - 7.0.0-rc2 We're excited to bring you the next major version of PMD! Since this is a big release, we provide here only a concise version of the release notes. We prepared a separate page with the full [Detailed Release Notes for PMD 7.0.0](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_release_notes_pmd7.html).
ℹ️ Release Candidates

PMD 7.0.0 is finally almost ready. In order to gather feedback, we are going to ship a couple of release candidates. These are officially available on GitHub and Maven Central and can be used as usual (e.g. as a dependency). We encourage you to try out the new features, but keep in mind that we may introduce API breaking changes between the release candidates. It should be stable enough if you don't use custom rules.

We have still some tasks planned for the next release candidates. You can see the progress in PMD 7 Tracking Issue #3898.

If you find any problem or difficulty while updating from PMD 6, please provide feedback via our issue tracker. That way we can improve the experience for all.

### Table Of Contents * [Changes since 7.0.0-rc1](#changes-since-7.0.0-rc1) * [API Changes](#api-changes) * [Updated PMD Designer](#updated-pmd-designer) * [Language Related Changes](#language-related-changes) * [Rule Changes](#rule-changes) * [Fixed Issues](#fixed-issues) * [External contributions](#external-contributions) * [πŸš€ Major Features and Enhancements](#πŸš€-major-features-and-enhancements) * [New official logo](#new-official-logo) * [Revamped Java module](#revamped-java-module) * [Revamped Command Line Interface](#revamped-command-line-interface) * [Full Antlr support](#full-antlr-support) * [Updated PMD Designer](#updated-pmd-designer) * [πŸŽ‰ Language Related Changes](#πŸŽ‰-language-related-changes) * [New: Swift support](#new:-swift-support) * [New: Kotlin support (experimental)](#new:-kotlin-support-(experimental)) * [New: CPD support for TypeScript](#new:-cpd-support-for-typescript) * [New: CPD support for Julia](#new:-cpd-support-for-julia) * [Changed: JavaScript support](#changed:-javascript-support) * [Changed: Language versions](#changed:-language-versions) * [🌟 New and changed rules](#🌟-new-and-changed-rules) * [New Rules](#new-rules) * [Changed Rules](#changed-rules) * [Removed Rules](#removed-rules) * [🚨 API](#🚨-api) * [πŸ’₯ Compatibility and migration notes](#πŸ’₯-compatibility-and-migration-notes) * [πŸ› Fixed Issues](#πŸ›-fixed-issues) * [✨ External Contributions](#✨-external-contributions) * [πŸ“ˆ Stats](#πŸ“ˆ-stats) ### Changes since 7.0.0-rc1 This section lists the most important changes from the last release candidate. The remaining section describes the complete release notes for 7.0.0. #### API Changes * Moved the two classes AntlrTokenizer and JavaCCTokenizer from `internal` package into package net.sourceforge.pmd.cpd.impl. These two classes are part of the API and are base classes for CPD language implementations. * `AntlrBaseRule` is gone in favor of AbstractVisitorRule. * The classes KotlinInnerNode and SwiftInnerNode are package-private now. * The parameter order of addSourceFile has been swapped in order to have the same meaning as in 6.55.0. That will make it easier if you upgrade from 6.55.0 to 7.0.0. However, that means, that you need to change these method calls if you have migrated to 7.0.0-rc1 already. #### Updated PMD Designer This PMD release ships a new version of the pmd-designer. For the changes, see [PMD Designer Changelog](https://github.com/pmd/pmd-designer/releases/tag/7.0.0-rc1). #### Language Related Changes * New: CPD support for TypeScript * New: CPD support for Julia #### Rule Changes * [`ImmutableField`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_design.html#immutablefield): the property `ignoredAnnotations` has been removed. The property was deprecated since PMD 6.52.0. * [`SwitchDensity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_design.html#switchdensity): the type of the property `minimum` has been changed from decimal to integer for consistency with other statistical rules. #### Fixed Issues * cli * [#4482](https://github.com/pmd/pmd/issues/4482): \[cli] pmd.bat can only be executed once * [#4484](https://github.com/pmd/pmd/issues/4484): \[cli] ast-dump with no properties produce an NPE * core * [#2500](https://github.com/pmd/pmd/issues/2500): \[core] Clarify API for ANTLR based languages * doc * [#2501](https://github.com/pmd/pmd/issues/2501): \[doc] Verify ANTLR Documentation * [#4438](https://github.com/pmd/pmd/issues/4438): \[doc] Documentation links in VS Code are outdated * java-codestyle * [#4273](https://github.com/pmd/pmd/issues/4273): \[java] CommentDefaultAccessModifier ignoredAnnotations should include "org.junit.jupiter.api.extension.RegisterExtension" by default * [#4487](https://github.com/pmd/pmd/issues/4487): \[java] UnnecessaryConstructor: false-positive with @Inject and @Autowired * java-design * [#4254](https://github.com/pmd/pmd/issues/4254): \[java] ImmutableField - false positive with Lombok @Setter * [#4477](https://github.com/pmd/pmd/issues/4477): \[java] SignatureDeclareThrowsException: false-positive with TestNG annotations * [#4490](https://github.com/pmd/pmd/issues/4490): \[java] ImmutableField - false negative with Lombok @Getter * java-errorprone * [#4449](https://github.com/pmd/pmd/issues/4449): \[java] AvoidAccessibilityAlteration: Possible false positive in AvoidAccessibilityAlteration rule when using Lambda expression * [#4493](https://github.com/pmd/pmd/issues/4493): \[java] MissingStaticMethodInNonInstantiatableClass: false-positive about @Inject * [#4505](https://github.com/pmd/pmd/issues/4505): \[java] ImplicitSwitchFallThrough NPE in PMD 7.0.0-rc1 * java-multithreading * [#4483](https://github.com/pmd/pmd/issues/4483): \[java] NonThreadSafeSingleton false positive with double-checked locking * miscellaneous * [#4462](https://github.com/pmd/pmd/issues/4462): Provide Software Bill of Materials (SBOM) #### External contributions * [#4402](https://github.com/pmd/pmd/pull/4402): \[javascript] CPD: add support for Typescript using antlr4 grammar - [Paul Guyot](https://github.com/pguyot) (@pguyot) * [#4403](https://github.com/pmd/pmd/pull/4403): \[julia] CPD: Add support for Julia code duplication - [Wener](https://github.com/wener-tiobe) (@wener-tiobe) * [#4444](https://github.com/pmd/pmd/pull/4444): \[java] CommentDefaultAccessModifier - ignore org.junit.jupiter.api.extension.RegisterExtension by default - [Nirvik Patel](https://github.com/nirvikpatel) (@nirvikpatel) * [#4450](https://github.com/pmd/pmd/pull/4450): \[java] Fix #4449 AvoidAccessibilityAlteration: Correctly handle Lambda expressions in PrivilegedAction scenarios - [Seren](https://github.com/mohui1999) (@mohui1999) * [#4452](https://github.com/pmd/pmd/pull/4452): \[doc] Update PMD_APEX_ROOT_DIRECTORY documentation reference - [nwcm](https://github.com/nwcm) (@nwcm) * [#4474](https://github.com/pmd/pmd/pull/4474): \[java] ImmutableField: False positive with lombok (fixes #4254) - [Pim van der Loos](https://github.com/PimvanderLoos) (@PimvanderLoos) * [#4488](https://github.com/pmd/pmd/pull/4488): \[java] Fix #4477: A false-positive about SignatureDeclareThrowsException - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4494](https://github.com/pmd/pmd/pull/4494): \[java] Fix #4487: A false-positive about UnnecessaryConstructor and @Inject and @Autowired - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4495](https://github.com/pmd/pmd/pull/4495): \[java] Fix #4493: false-positive about MissingStaticMethodInNonInstantiatableClass and @Inject - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4520](https://github.com/pmd/pmd/pull/4520): \[doc] Fix typo: missing closing quotation mark after CPD-END - [JoΓ£o Dinis Ferreira](https://github.com/joaodinissf) (@joaodinissf) ### πŸš€ Major Features and Enhancements #### New official logo The new official logo of PMD: ![New PMD Logo](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/images/logo/pmd-logo-300px.png) #### Revamped Java module * Java grammar substantially refactored - more correct regarding the Java Language Specification (JLS) * Built-in rules have been upgraded for the changed AST * Rewritten type resolution framework and symbol table correctly implements the JLS * AST exposes more semantic information (method calls, field accesses) For more information, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_release_notes_pmd7.html). Contributors: [ClΓ©ment Fournier](https://github.com/oowekyala) (@oowekyala), [Andreas Dangel](https://github.com/adangel) (@adangel), [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) #### Revamped Command Line Interface * unified and consistent Command Line Interface for both Linux/Unix and Windows across our different utilities * single script `pmd` (`pmd.bat` for Windows) to launch the different utilities: * `pmd check` to run PMD rules and analyze a project * `pmd cpd` to run CPD (copy paste detector) * `pmd designer` to run the PMD Rule Designer * progress bar support for `pmd check` * shell completion ![Demo](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/images/userdocs/pmd-demo.gif) For more information, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_release_notes_pmd7.html). Contributors: [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) #### Full Antlr support * [Antlr](https://www.antlr.org/) based grammars can now be used to build full-fledged PMD rules. * Previously, Antlr grammar could only be used for CPD * New supported languages: Swift and Kotlin For more information, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_release_notes_pmd7.html). Contributors: [Lucas Soncini](https://github.com/lsoncini) (@lsoncini), [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga), [TomΓ‘s De Lucca](https://github.com/tomidelucca) (@tomidelucca) #### Updated PMD Designer This PMD release ships a new version of the pmd-designer. For the changes, see [PMD Designer Changelog](https://github.com/pmd/pmd-designer/releases/tag/7.0.0-rc1). ### πŸŽ‰ Language Related Changes Note that this is just a concise listing of the highlight. For more information on the languages, see the [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_release_notes_pmd7.html). #### New: Swift support * use PMD to analyze Swift code with PMD rules * initially 4 built-in rules Contributors: [Lucas Soncini](https://github.com/lsoncini) (@lsoncini), [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga), [TomΓ‘s De Lucca](https://github.com/tomidelucca) (@tomidelucca) #### New: Kotlin support (experimental) * use PMD to analyze Kotlin code with PMD rules * Support for Kotlin 1.8 grammar * initially 2 built-in rules #### 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](https://github.com/pguyot) (@pguyot) #### 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](https://github.com/wener-tiobe) (@wener-tiobe) #### Changed: JavaScript support * latest version supports ES6 and also some new constructs (see [Rhino](https://github.com/mozilla/rhino)]) * comments are retained #### Changed: Language versions * more predefined language versions for each supported language * can be used to limit rule execution for specific versions only with `minimumLanguageVersion` and `maximumLanguageVersion` attributes. ### 🌟 New and changed rules #### New Rules **Apex** * [`UnusedMethod`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_apex_design.html#unusedmethod) finds unused methods in your code. **Java** * [`UnnecessaryBoxing`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_codestyle.html#unnecessaryboxing) reports boxing and unboxing conversions that may be made implicit. **Kotlin** * [`FunctionNameTooShort`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_kotlin_bestpractices.html#functionnametooshort) * [`OverrideBothEqualsAndHashcode`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_kotlin_errorprone.html#overridebothequalsandhashcode) **Swift** * [`ProhibitedInterfaceBuilder`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_swift_bestpractices.html#prohibitedinterfacebuilder) * [`UnavailableFunction`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_swift_bestpractices.html#unavailablefunction) * [`ForceCast`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_swift_errorprone.html#forcecast) * [`ForceTry`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_swift_errorprone.html#forcetry) #### Changed Rules **General changes** * All statistical rules (like ExcessiveClassLength, ExcessiveParameterList) have been simplified and unified. The properties `topscore` and `sigma` have been removed. The property `minimum` is still there, however the type is not a decimal number anymore but has been changed to an integer. This affects rules in the languages Apex, Java, PLSQL and Velocity Template Language (vm): * Apex: [`ExcessiveClassLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_apex_design.html#excessiveclasslength), [`ExcessiveParameterList`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_apex_design.html#excessiveparameterlist), [`ExcessivePublicCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_apex_design.html#excessivepubliccount), [`NcssConstructorCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_apex_design.html#ncssconstructorcount), [`NcssMethodCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_apex_design.html#ncssmethodcount), [`NcssTypeCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_apex_design.html#ncsstypecount) * Java: [`ExcessiveImports`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_design.html#excessiveimports), [`ExcessiveParameterList`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_design.html#excessiveparameterlist), [`ExcessivePublicCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_design.html#excessivepubliccount), [`SwitchDensity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_design.html#switchdensity) * PLSQL: [`ExcessiveMethodLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_plsql_design.html#excessivemethodlength), [`ExcessiveObjectLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_plsql_design.html#excessiveobjectlength), [`ExcessivePackageBodyLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_plsql_design.html#excessivepackagebodylength), [`ExcessivePackageSpecificationLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_plsql_design.html#excessivepackagespecificationlength), [`ExcessiveParameterList`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_plsql_design.html#excessiveparameterlist), [`ExcessiveTypeLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_plsql_design.html#excessivetypelength), [`NcssMethodCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_plsql_design.html#ncssmethodcount), [`NcssObjectCount`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_plsql_design.html#ncssobjectcount), [`NPathComplexity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_plsql_design.html#npathcomplexity) * VM: [`ExcessiveTemplateLength`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_vm_design.html#excessivetemplatelength) * The general property `violationSuppressXPath` which is available for all rules to [suppress warnings](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_userdocs_suppressing_warnings.html) now uses XPath version 3.1 by default. This version of the XPath language is mostly identical to XPath 2.0. In PMD 6, XPath 1.0 has been used. If you upgrade from PMD 6, you need to verify your `violationSuppressXPath` properties. **Apex General changes** * The properties `cc_categories`, `cc_remediation_points_multiplier`, `cc_block_highlighting` have been removed from all rules. These properties have been deprecated since PMD 6.13.0. See [issue #1648](https://github.com/pmd/pmd/issues/1648) for more details. **Java General changes** * Violations reported on methods or classes previously reported the line range of the entire method or class. With PMD 7.0.0, the reported location is now just the identifier of the method or class. This affects various rules, e.g. [`CognitiveComplexity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_design.html#cognitivecomplexity). The report location is controlled by the overrides of the method getReportLocation in different node types. See [issue #4439](https://github.com/pmd/pmd/issues/4439) and [issue #730](https://github.com/pmd/pmd/issues/730) for more details. **Java Best Practices** * [`ArrayIsStoredDirectly`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_bestpractices.html#arrayisstoreddirectly): Violations are now reported on the assignment and not anymore on the formal parameter. The reported line numbers will probably move. * [`AvoidReassigningLoopVariables`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_bestpractices.html#avoidreassigningloopvariables): This rule might not report anymore all reassignments of the control variable in for-loops when the property `forReassign` is set to `skip`. See [issue #4500](https://github.com/pmd/pmd/issues/4500) for more details. * [`LooseCoupling`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_bestpractices.html#loosecoupling): The rule has a new property to allow some types to be coupled to (`allowedTypes`). * [`UnusedLocalVariable`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_bestpractices.html#unusedlocalvariable): This rule has some important false-negatives fixed and finds many more cases now. For details see issues [#2130](https://github.com/pmd/pmd/issues/2130), [#4516](https://github.com/pmd/pmd/issues/4516), and [#4517](https://github.com/pmd/pmd/issues/4517). **Java Codestyle** * [`MethodNamingConventions`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_codestyle.html#methodnamingconventions): The property `checkNativeMethods` has been removed. The property was deprecated since PMD 6.3.0. Use the property `nativePattern` to control whether native methods should be considered or not. * [`ShortVariable`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_codestyle.html#shortvariable): This rule now also reports short enum constant names. * [`UseDiamondOperator`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_codestyle.html#usediamondoperator): The property `java7Compatibility` has been removed. The rule now handles Java 7 properly without a property. * [`UnnecessaryFullyQualifiedName`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_codestyle.html#unnecessaryfullyqualifiedname): The rule has two new properties, to selectively disable reporting on static field and method qualifiers. The rule also has been improved to be more precise. * [`UselessParentheses`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_codestyle.html#uselessparentheses): The rule has two new properties which control how strict the rule should be applied. With `ignoreClarifying` (default: true) parentheses that are strictly speaking not necessary are allowed, if they separate expressions of different precedence. The other property `ignoreBalancing` (default: true) is similar, in that it allows parentheses that help reading and understanding the expressions. **Java Design** * [`CyclomaticComplexity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_design.html#cyclomaticcomplexity): The property `reportLevel` has been removed. The property was deprecated since PMD 6.0.0. The report level can now be configured separated for classes and methods using `classReportLevel` and `methodReportLevel` instead. * [`ImmutableField`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_design.html#immutablefield): The property `ignoredAnnotations` has been removed. The property was deprecated since PMD 6.52.0. * [`LawOfDemeter`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_design.html#lawofdemeter): The rule has a new property `trustRadius`. This defines the maximum degree of trusted data. The default of 1 is the most restrictive. * [`NPathComplexity`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_design.html#npathcomplexity): The property `minimum` has been removed. It was deprecated since PMD 6.0.0. Use the property `reportLevel` instead. * [`SingularField`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_design.html#singularfield): The properties `checkInnerClasses` and `disallowNotAssignment` have been removed. The rule is now more precise and will check these cases properly. * [`UseUtilityClass`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_design.html#useutilityclass): The property `ignoredAnnotations` has been removed. **Java Documentation** * [`CommentContent`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_documentation.html#commentcontent): The properties `caseSensitive` and `disallowedTerms` are removed. The new property `forbiddenRegex` can be used now to define the disallowed terms with a single regular expression. * [`CommentRequired`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_documentation.html#commentrequired): * Overridden methods are now detected even without the `@Override` annotation. This is relevant for the property `methodWithOverrideCommentRequirement`. See also [pull request #3757](https://github.com/pmd/pmd/pull/3757). * Elements in annotation types are now detected as well. This might lead to an increased number of violations for missing public method comments. * [`CommentSize`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_documentation.html#commentsize): When determining the line-length of a comment, the leading comment prefix markers (e.g. `*` or `//`) are ignored and don't add up to the line-length. See also [pull request #4369](https://github.com/pmd/pmd/pull/4369). **Java Error Prone** * [`AvoidDuplicateLiterals`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_errorprone.html#avoidduplicateliterals): The property `exceptionfile` has been removed. The property was deprecated since PMD 6.10.0. Use the property `exceptionList` instead. * [`DontImportSun`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_errorprone.html#dontimportsun): `sun.misc.Signal` is not special-cased anymore. * [`EmptyCatchBlock`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_errorprone.html#emptycatchblock): `CloneNotSupportedException` and `InterruptedException` are not special-cased anymore. Rename the exception parameter to `ignored` to ignore them. * [`ImplicitSwitchFallThrough`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_rules_java_errorprone.html#implicitswitchfallthrough): Violations are now reported on the case statements rather than on the switch statements. This is more accurate but might result in more violations now. #### Removed Rules Many rules, that were previously deprecated have been finally removed. See [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_release_notes_pmd7.html) for the complete list. ### 🚨 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. Also, there are some improvement and changes in different areas. For the detailed description of the changes listed here, see [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_release_notes_pmd7.html). * Miscellaneous smaller changes and cleanups * XPath 3.1 support for XPath-based rules * Node stream API for AST traversal * Metrics framework * Testing framework * Language Lifecycle and Language Properties ### πŸ’₯ Compatibility and migration notes See [Detailed Release Notes for PMD 7](https://docs.pmd-code.org/pmd-doc-7.0.0-rc2/pmd_release_notes_pmd7.html). ### πŸ› Fixed Issues * miscellaneous * [#881](https://github.com/pmd/pmd/issues/881): \[all] Breaking API changes for 7.0.0 * [#896](https://github.com/pmd/pmd/issues/896): \[all] Use slf4j * [#1431](https://github.com/pmd/pmd/pull/1431): \[ui] Remove old GUI applications (designerold, bgastviewer) * [#1451](https://github.com/pmd/pmd/issues/1451): \[core] RulesetFactoryCompatibility stores the whole ruleset file in memory as a string * [#2496](https://github.com/pmd/pmd/issues/2496): Update PMD 7 Logo on landing page * [#2497](https://github.com/pmd/pmd/issues/2497): PMD 7 Logo page * [#2498](https://github.com/pmd/pmd/issues/2498): Update PMD 7 Logo in documentation * [#3797](https://github.com/pmd/pmd/issues/3797): \[all] Use JUnit5 * [#4462](https://github.com/pmd/pmd/issues/4462): Provide Software Bill of Materials (SBOM) * ant * [#4080](https://github.com/pmd/pmd/issues/4080): \[ant] Split off Ant integration into a new submodule * core * [#880](https://github.com/pmd/pmd/issues/880): \[core] Make visitors generic * [#1622](https://github.com/pmd/pmd/pull/1622): \[core] NodeStream API * [#1687](https://github.com/pmd/pmd/issues/1687): \[core] Deprecate and Remove XPath 1.0 support * [#1785](https://github.com/pmd/pmd/issues/1785): \[core] Allow abstract node types to be valid rulechain visits * [#1825](https://github.com/pmd/pmd/pull/1825): \[core] Support NoAttribute for XPath * [#2038](https://github.com/pmd/pmd/issues/2038): \[core] Remove DCD * [#2218](https://github.com/pmd/pmd/issues/2218): \[core] `isFindBoundary` should not be an attribute * [#2234](https://github.com/pmd/pmd/issues/2234): \[core] Consolidate PMD CLI into a single command * [#2239](https://github.com/pmd/pmd/issues/2239): \[core] Merging Javacc build scripts * [#2500](https://github.com/pmd/pmd/issues/2500): \[core] Clarify API for ANTLR based languages * [#2518](https://github.com/pmd/pmd/issues/2518): \[core] Language properties * [#2602](https://github.com/pmd/pmd/issues/2602): \[core] Remove ParserOptions * [#2614](https://github.com/pmd/pmd/pull/2614): \[core] Upgrade Saxon, add XPath 3.1, remove Jaxen * [#2696](https://github.com/pmd/pmd/pull/2696): \[core] Remove DFA * [#2821](https://github.com/pmd/pmd/issues/2821): \[core] Rule processing error filenames are missing paths * [#2873](https://github.com/pmd/pmd/issues/2873): \[core] Utility classes in pmd 7 * [#2885](https://github.com/pmd/pmd/issues/2885): \[core] Error recovery mode * [#3203](https://github.com/pmd/pmd/issues/3203): \[core] Replace RuleViolationFactory implementations with ViolationDecorator * [#3692](https://github.com/pmd/pmd/pull/3692): \[core] Analysis listeners * [#3782](https://github.com/pmd/pmd/issues/3782): \[core] Language lifecycle * [#3815](https://github.com/pmd/pmd/issues/3815): \[core] Update Saxon HE to 10.7 * [#3893](https://github.com/pmd/pmd/pull/3893): \[core] Text documents * [#3902](https://github.com/pmd/pmd/issues/3902): \[core] Violation decorators * [#3918](https://github.com/pmd/pmd/issues/3918): \[core] Make LanguageRegistry non static * [#3922](https://github.com/pmd/pmd/pull/3922): \[core] Better error reporting for the ruleset parser * [#4035](https://github.com/pmd/pmd/issues/4035): \[core] ConcurrentModificationException in DefaultRuleViolationFactory * [#4120](https://github.com/pmd/pmd/issues/4120): \[core] Explicitly name all language versions * [#4353](https://github.com/pmd/pmd/pull/4353): \[core] Micro optimizations for Node API * [#4365](https://github.com/pmd/pmd/pull/4365): \[core] Improve benchmarking * [#4420](https://github.com/pmd/pmd/pull/4420): \[core] Remove PMD.EOL * cli * [#2234](https://github.com/pmd/pmd/issues/2234): \[core] Consolidate PMD CLI into a single command * [#3828](https://github.com/pmd/pmd/issues/3828): \[core] Progress reporting * [#4079](https://github.com/pmd/pmd/issues/4079): \[cli] Split off CLI implementation into a pmd-cli submodule * [#4482](https://github.com/pmd/pmd/issues/4482): \[cli] pmd.bat can only be executed once * [#4484](https://github.com/pmd/pmd/issues/4484): \[cli] ast-dump with no properties produce an NPE * doc * [#2501](https://github.com/pmd/pmd/issues/2501): \[doc] Verify ANTLR Documentation * [#4438](https://github.com/pmd/pmd/issues/4438): \[doc] Documentation links in VS Code are outdated * testing * [#2435](https://github.com/pmd/pmd/issues/2435): \[test] Remove duplicated Dummy language module * [#4234](https://github.com/pmd/pmd/issues/4234): \[test] Tests that change the logging level do not work Language specific fixes: * apex * [#1937](https://github.com/pmd/pmd/issues/1937): \[apex] Apex should only have a single RootNode * [#1648](https://github.com/pmd/pmd/issues/1648): \[apex,vf] Remove CodeClimate dependency * [#1750](https://github.com/pmd/pmd/pull/1750): \[apex] Remove apex statistical rules * [#2836](https://github.com/pmd/pmd/pull/2836): \[apex] Remove Apex ProjectMirror * [#4427](https://github.com/pmd/pmd/issues/4427): \[apex] ApexBadCrypto test failing to detect inline code * apex-design * [#2667](https://github.com/pmd/pmd/issues/2667): \[apex] Integrate nawforce/ApexLink to build robust Unused rule * [#4509](https://github.com/pmd/pmd/issues/4509): \[apex] ExcessivePublicCount doesn't consider inner classes correctly * java * [#520](https://github.com/pmd/pmd/issues/520): \[java] Allow `@SuppressWarnings` with constants instead of literals * [#864](https://github.com/pmd/pmd/issues/864): \[java] Similar/duplicated implementations for determining FQCN * [#905](https://github.com/pmd/pmd/issues/905): \[java] Add new node for anonymous class declaration * [#910](https://github.com/pmd/pmd/issues/910): \[java] AST inconsistency between primitive and reference type arrays * [#997](https://github.com/pmd/pmd/issues/997): \[java] Java8 parsing corner case with annotated array types * [#998](https://github.com/pmd/pmd/issues/998): \[java] AST inconsistencies around FormalParameter * [#1019](https://github.com/pmd/pmd/issues/1019): \[java] Breaking Java Grammar changes for PMD 7.0.0 * [#1124](https://github.com/pmd/pmd/issues/1124): \[java] ImmutableList implementation in the qname codebase * [#1128](https://github.com/pmd/pmd/issues/1128): \[java] Improve ASTLocalVariableDeclaration * [#1150](https://github.com/pmd/pmd/issues/1150): \[java] ClassOrInterfaceType AST improvements * [#1207](https://github.com/pmd/pmd/issues/1207): \[java] Resolve explicit types using FQCNs, without hitting the classloader * [#1367](https://github.com/pmd/pmd/issues/1367): \[java] Parsing error on annotated inner class * [#1661](https://github.com/pmd/pmd/issues/1661): \[java] About operator nodes * [#2366](https://github.com/pmd/pmd/pull/2366): \[java] Remove qualified names * [#2819](https://github.com/pmd/pmd/issues/2819): \[java] GLB bugs in pmd 7 * [#3642](https://github.com/pmd/pmd/issues/3642): \[java] Parse error on rare extra dimensions on method return type on annotation methods * [#3763](https://github.com/pmd/pmd/issues/3763): \[java] Ambiguous reference error in valid code * [#3749](https://github.com/pmd/pmd/issues/3749): \[java] Improve `isOverridden` in ASTMethodDeclaration * [#3750](https://github.com/pmd/pmd/issues/3750): \[java] Make symbol table support instanceof pattern bindings * [#3752](https://github.com/pmd/pmd/issues/3752): \[java] Expose annotations in symbol API * [#4237](https://github.com/pmd/pmd/pull/4237): \[java] Cleanup handling of Java comments * [#4317](https://github.com/pmd/pmd/issues/4317): \[java] Some AST nodes should not be TypeNodes * [#4359](https://github.com/pmd/pmd/issues/4359): \[java] Type resolution fails with NPE when the scope is not a type declaration * [#4367](https://github.com/pmd/pmd/issues/4367): \[java] Move testrule TypeResTest into internal * java-bestpractices * [#342](https://github.com/pmd/pmd/issues/342): \[java] AccessorMethodGeneration: Name clash with another public field not properly handled * [#755](https://github.com/pmd/pmd/issues/755): \[java] AccessorClassGeneration false positive for private constructors * [#770](https://github.com/pmd/pmd/issues/770): \[java] UnusedPrivateMethod yields false positive for counter-variant arguments * [#807](https://github.com/pmd/pmd/issues/807): \[java] AccessorMethodGeneration false positive with overloads * [#833](https://github.com/pmd/pmd/issues/833): \[java] ForLoopCanBeForeach should consider iterating on this * [#1189](https://github.com/pmd/pmd/issues/1189): \[java] UnusedPrivateMethod false positive from inner class via external class * [#1205](https://github.com/pmd/pmd/issues/1205): \[java] Improve ConstantsInInterface message to mention alternatives * [#1212](https://github.com/pmd/pmd/issues/1212): \[java] Don't raise JUnitTestContainsTooManyAsserts on JUnit 5's assertAll * [#1422](https://github.com/pmd/pmd/issues/1422): \[java] JUnitTestsShouldIncludeAssert false positive with inherited @Rule field * [#1455](https://github.com/pmd/pmd/issues/1455): \[java] JUnitTestsShouldIncludeAssert: False positives for assert methods named "check" and "verify" * [#1563](https://github.com/pmd/pmd/issues/1563): \[java] ForLoopCanBeForeach false positive with method call using index variable * [#1565](https://github.com/pmd/pmd/issues/1565): \[java] JUnitAssertionsShouldIncludeMessage false positive with AssertJ * [#1747](https://github.com/pmd/pmd/issues/1747): \[java] PreserveStackTrace false-positive * [#1969](https://github.com/pmd/pmd/issues/1969): \[java] MissingOverride false-positive triggered by package-private method overwritten in another package by extending class * [#1998](https://github.com/pmd/pmd/issues/1998): \[java] AccessorClassGeneration false-negative: subclass calls private constructor * [#2130](https://github.com/pmd/pmd/issues/2130): \[java] UnusedLocalVariable: false-negative with array * [#2147](https://github.com/pmd/pmd/issues/2147): \[java] JUnitTestsShouldIncludeAssert - false positives with lambdas and static methods * [#2464](https://github.com/pmd/pmd/issues/2464): \[java] LooseCoupling must ignore class literals: ArrayList.class * [#2542](https://github.com/pmd/pmd/issues/2542): \[java] UseCollectionIsEmpty can not detect the case `foo.bar().size()` * [#2650](https://github.com/pmd/pmd/issues/2650): \[java] UseTryWithResources false positive when AutoCloseable helper used * [#2796](https://github.com/pmd/pmd/issues/2796): \[java] UnusedAssignment false positive with call chains * [#2797](https://github.com/pmd/pmd/issues/2797): \[java] MissingOverride long-standing issues * [#2806](https://github.com/pmd/pmd/issues/2806): \[java] SwitchStmtsShouldHaveDefault false-positive with Java 14 switch non-fallthrough branches * [#2822](https://github.com/pmd/pmd/issues/2822): \[java] LooseCoupling rule: Extend to cover user defined implementations and interfaces * [#2843](https://github.com/pmd/pmd/pull/2843): \[java] Fix UnusedAssignment FP with field accesses * [#2882](https://github.com/pmd/pmd/issues/2882): \[java] UseTryWithResources - false negative for explicit close * [#2883](https://github.com/pmd/pmd/issues/2883): \[java] JUnitAssertionsShouldIncludeMessage false positive with method call * [#2890](https://github.com/pmd/pmd/issues/2890): \[java] UnusedPrivateMethod false positive with generics * [#2946](https://github.com/pmd/pmd/issues/2946): \[java] SwitchStmtsShouldHaveDefault false positive on enum inside enums * [#3672](https://github.com/pmd/pmd/pull/3672): \[java] LooseCoupling - fix false positive with generics * [#3675](https://github.com/pmd/pmd/pull/3675): \[java] MissingOverride - fix false positive with mixing type vars * [#3858](https://github.com/pmd/pmd/issues/3858): \[java] UseCollectionIsEmpty should infer local variable type from method invocation * [#4516](https://github.com/pmd/pmd/issues/4516): \[java] UnusedLocalVariable: false-negative with try-with-resources * [#4517](https://github.com/pmd/pmd/issues/4517): \[java] UnusedLocalVariable: false-negative with compound assignments * [#4518](https://github.com/pmd/pmd/issues/4518): \[java] UnusedLocalVariable: false-positive with multiple for-loop indices * java-codestyle * [#1208](https://github.com/pmd/pmd/issues/1208): \[java] PrematureDeclaration rule false-positive on variable declared to measure time * [#1429](https://github.com/pmd/pmd/issues/1429): \[java] PrematureDeclaration as result of method call (false positive) * [#1480](https://github.com/pmd/pmd/issues/1480): \[java] IdenticalCatchBranches false positive with return expressions * [#1673](https://github.com/pmd/pmd/issues/1673): \[java] UselessParentheses false positive with conditional operator * [#1790](https://github.com/pmd/pmd/issues/1790): \[java] UnnecessaryFullyQualifiedName false positive with enum constant * [#1918](https://github.com/pmd/pmd/issues/1918): \[java] UselessParentheses false positive with boolean operators * [#2134](https://github.com/pmd/pmd/issues/2134): \[java] PreserveStackTrace not handling `Throwable.addSuppressed(...)` * [#2299](https://github.com/pmd/pmd/issues/2299): \[java] UnnecessaryFullyQualifiedName false positive with similar package name * [#2391](https://github.com/pmd/pmd/issues/2391): \[java] UseDiamondOperator FP when expected type and constructed type have a different parameterization * [#2528](https://github.com/pmd/pmd/issues/2528): \[java] MethodNamingConventions - JUnit 5 method naming not support ParameterizedTest * [#2739](https://github.com/pmd/pmd/issues/2739): \[java] UselessParentheses false positive for string concatenation * [#2748](https://github.com/pmd/pmd/issues/2748): \[java] UnnecessaryCast false positive with unchecked cast * [#2973](https://github.com/pmd/pmd/issues/2973): \[java] New rule: UnnecessaryBoxing * [#3195](https://github.com/pmd/pmd/pull/3195): \[java] Improve rule UnnecessaryReturn to detect more cases * [#3218](https://github.com/pmd/pmd/pull/3218): \[java] Generalize UnnecessaryCast to flag all unnecessary casts * [#3221](https://github.com/pmd/pmd/issues/3221): \[java] PrematureDeclaration false positive for unused variables * [#3238](https://github.com/pmd/pmd/issues/3238): \[java] Improve ExprContext, fix FNs of UnnecessaryCast * [#3500](https://github.com/pmd/pmd/pull/3500): \[java] UnnecessaryBoxing - check for Integer.valueOf(String) calls * [#4273](https://github.com/pmd/pmd/issues/4273): \[java] CommentDefaultAccessModifier ignoredAnnotations should include "org.junit.jupiter.api.extension.RegisterExtension" by default * [#4357](https://github.com/pmd/pmd/pull/4357): \[java] Fix IllegalStateException in UseDiamondOperator rule * [#4487](https://github.com/pmd/pmd/issues/4487): \[java] UnnecessaryConstructor: false-positive with @Inject and @Autowired * [#4511](https://github.com/pmd/pmd/issues/4511): \[java] LocalVariableCouldBeFinal shouldn't report unused variables * [#4512](https://github.com/pmd/pmd/issues/4512): \[java] MethodArgumentCouldBeFinal shouldn't report unused parameters * java-design * [#1014](https://github.com/pmd/pmd/issues/1014): \[java] LawOfDemeter: False positive with lambda expression * [#1605](https://github.com/pmd/pmd/issues/1605): \[java] LawOfDemeter: False positive for standard UTF-8 charset name * [#2160](https://github.com/pmd/pmd/issues/2160): \[java] Issues with Law of Demeter * [#2175](https://github.com/pmd/pmd/issues/2175): \[java] LawOfDemeter: False positive for chained methods with generic method call * [#2179](https://github.com/pmd/pmd/issues/2179): \[java] LawOfDemeter: False positive with static property access - should treat class-level property as global object, not dot-accessed property * [#2180](https://github.com/pmd/pmd/issues/2180): \[java] LawOfDemeter: False positive with Thread and ThreadLocalRandom * [#2182](https://github.com/pmd/pmd/issues/2182): \[java] LawOfDemeter: False positive with package-private access * [#2188](https://github.com/pmd/pmd/issues/2188): \[java] LawOfDemeter: False positive with fields assigned to local vars * [#2536](https://github.com/pmd/pmd/issues/2536): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal can't detect inner class * [#3668](https://github.com/pmd/pmd/pull/3668): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal - fix FP with inner private classes * [#3754](https://github.com/pmd/pmd/issues/3754): \[java] SingularField false positive with read in while condition * [#3786](https://github.com/pmd/pmd/issues/3786): \[java] SimplifyBooleanReturns should consider operator precedence * [#4238](https://github.com/pmd/pmd/pull/4238): \[java] Make LawOfDemeter not use the rulechain * [#4254](https://github.com/pmd/pmd/issues/4254): \[java] ImmutableField - false positive with Lombok @Setter * [#4477](https://github.com/pmd/pmd/issues/4477): \[java] SignatureDeclareThrowsException: false-positive with TestNG annotations * [#4490](https://github.com/pmd/pmd/issues/4490): \[java] ImmutableField - false negative with Lombok @Getter * java-documentation * [#4369](https://github.com/pmd/pmd/pull/4369): \[java] Improve CommentSize * [#4416](https://github.com/pmd/pmd/pull/4416): \[java] Fix reported line number in CommentContentRule * java-errorprone * [#659](https://github.com/pmd/pmd/issues/659): \[java] MissingBreakInSwitch - last default case does not contain a break * [#1005](https://github.com/pmd/pmd/issues/1005): \[java] CloneMethodMustImplementCloneable triggers for interfaces * [#1669](https://github.com/pmd/pmd/issues/1669): \[java] NullAssignment - FP with ternay and null as constructor argument * [#1899](https://github.com/pmd/pmd/issues/1899): \[java] Recognize @SuppressWanings("fallthrough") for MissingBreakInSwitch * [#2320](https://github.com/pmd/pmd/issues/2320): \[java] NullAssignment - FP with ternary and null as method argument * [#2532](https://github.com/pmd/pmd/issues/2532): \[java] AvoidDecimalLiteralsInBigDecimalConstructor can not detect the case `new BigDecimal(Expression)` * [#2579](https://github.com/pmd/pmd/issues/2579): \[java] MissingBreakInSwitch detects the lack of break in the last case * [#2880](https://github.com/pmd/pmd/issues/2880): \[java] CompareObjectsWithEquals - false negative with type res * [#2893](https://github.com/pmd/pmd/issues/2893): \[java] Remove special cases from rule EmptyCatchBlock * [#2894](https://github.com/pmd/pmd/issues/2894): \[java] Improve MissingBreakInSwitch * [#3071](https://github.com/pmd/pmd/issues/3071): \[java] BrokenNullCheck FP with PMD 6.30.0 * [#3087](https://github.com/pmd/pmd/issues/3087): \[java] UnnecessaryBooleanAssertion overlaps with SimplifiableTestAssertion * [#3100](https://github.com/pmd/pmd/issues/3100): \[java] UseCorrectExceptionLogging FP in 6.31.0 * [#3173](https://github.com/pmd/pmd/issues/3173): \[java] UseProperClassLoader false positive * [#3351](https://github.com/pmd/pmd/issues/3351): \[java] ConstructorCallsOverridableMethod ignores abstract methods * [#3400](https://github.com/pmd/pmd/issues/3400): \[java] AvoidUsingOctalValues FN with underscores * [#3843](https://github.com/pmd/pmd/issues/3843): \[java] UseEqualsToCompareStrings should consider return type * [#4356](https://github.com/pmd/pmd/pull/4356): \[java] Fix NPE in CloseResourceRule * [#4449](https://github.com/pmd/pmd/issues/4449): \[java] AvoidAccessibilityAlteration: Possible false positive in AvoidAccessibilityAlteration rule when using Lambda expression * [#4493](https://github.com/pmd/pmd/issues/4493): \[java] MissingStaticMethodInNonInstantiatableClass: false-positive about @Inject * [#4505](https://github.com/pmd/pmd/issues/4505): \[java] ImplicitSwitchFallThrough NPE in PMD 7.0.0-rc1 * [#4513](https://github.com/pmd/pmd/issues/4513): \[java] UselessOperationOnImmutable various false negatives with String * [#4514](https://github.com/pmd/pmd/issues/4514): \[java] AvoidLiteralsInIfCondition false positive and negative for String literals when ignoreExpressions=true * java-multithreading * [#2537](https://github.com/pmd/pmd/issues/2537): \[java] DontCallThreadRun can't detect the case that call run() in `this.run()` * [#2538](https://github.com/pmd/pmd/issues/2538): \[java] DontCallThreadRun can't detect the case that call run() in `foo.bar.run()` * [#2577](https://github.com/pmd/pmd/issues/2577): \[java] UseNotifyAllInsteadOfNotify falsely detect a special case with argument: `foo.notify(bar)` * [#4483](https://github.com/pmd/pmd/issues/4483): \[java] NonThreadSafeSingleton false positive with double-checked locking * java-performance * [#1224](https://github.com/pmd/pmd/issues/1224): \[java] InefficientEmptyStringCheck false negative in anonymous class * [#2587](https://github.com/pmd/pmd/issues/2587): \[java] AvoidArrayLoops could also check for list copy through iterated List.add() * [#2712](https://github.com/pmd/pmd/issues/2712): \[java] SimplifyStartsWith false-positive with AssertJ * [#3486](https://github.com/pmd/pmd/pull/3486): \[java] InsufficientStringBufferDeclaration: Fix NPE * [#3848](https://github.com/pmd/pmd/issues/3848): \[java] StringInstantiation: false negative when using method result * kotlin * [#419](https://github.com/pmd/pmd/issues/419): \[kotlin] Add support for Kotlin * [#4389](https://github.com/pmd/pmd/pull/4389): \[kotlin] Update grammar to version 1.8 * swift * [#1877](https://github.com/pmd/pmd/pull/1877): \[swift] Feature/swift rules * [#1882](https://github.com/pmd/pmd/pull/1882): \[swift] UnavailableFunction Swift rule * xml * [#1800](https://github.com/pmd/pmd/pull/1800): \[xml] Unimplement org.w3c.dom.Node from the XmlNodeWrapper ### ✨ External Contributions * [#1658](https://github.com/pmd/pmd/pull/1658): \[core] Node support for Antlr-based languages - [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga) * [#1698](https://github.com/pmd/pmd/pull/1698): \[core] [swift] Antlr Base Parser adapter and Swift Implementation - [Lucas Soncini](https://github.com/lsoncini) (@lsoncini) * [#1774](https://github.com/pmd/pmd/pull/1774): \[core] Antlr visitor rules - [Lucas Soncini](https://github.com/lsoncini) (@lsoncini) * [#1877](https://github.com/pmd/pmd/pull/1877): \[swift] Feature/swift rules - [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga) * [#1881](https://github.com/pmd/pmd/pull/1881): \[doc] Add ANTLR documentation - [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga) * [#1882](https://github.com/pmd/pmd/pull/1882): \[swift] UnavailableFunction Swift rule - [TomΓ‘s de Lucca](https://github.com/tomidelucca) (@tomidelucca) * [#2830](https://github.com/pmd/pmd/pull/2830): \[apex] Apexlink POC - [Kevin Jones](https://github.com/nawforce) (@nawforce) * [#3866](https://github.com/pmd/pmd/pull/3866): \[core] Add CLI Progress Bar - [@JerritEic](https://github.com/JerritEic) (@JerritEic) * [#4402](https://github.com/pmd/pmd/pull/4402): \[javascript] CPD: add support for Typescript using antlr4 grammar - [Paul Guyot](https://github.com/pguyot) (@pguyot) * [#4403](https://github.com/pmd/pmd/pull/4403): \[julia] CPD: Add support for Julia code duplication - [Wener](https://github.com/wener-tiobe) (@wener-tiobe) * [#4412](https://github.com/pmd/pmd/pull/4412): \[doc] Added new error msg to ConstantsInInterface - [David Ljunggren](https://github.com/dague1) (@dague1) * [#4428](https://github.com/pmd/pmd/pull/4428): \[apex] ApexBadCrypto bug fix for #4427 - inline detection of hard coded values - [Steven Stearns](https://github.com/sfdcsteve) (@sfdcsteve) * [#4444](https://github.com/pmd/pmd/pull/4444): \[java] CommentDefaultAccessModifier - ignore org.junit.jupiter.api.extension.RegisterExtension by default - [Nirvik Patel](https://github.com/nirvikpatel) (@nirvikpatel) * [#4450](https://github.com/pmd/pmd/pull/4450): \[java] Fix #4449 AvoidAccessibilityAlteration: Correctly handle Lambda expressions in PrivilegedAction scenarios - [Seren](https://github.com/mohui1999) (@mohui1999) * [#4452](https://github.com/pmd/pmd/pull/4452): \[doc] Update PMD_APEX_ROOT_DIRECTORY documentation reference - [nwcm](https://github.com/nwcm) (@nwcm) * [#4474](https://github.com/pmd/pmd/pull/4474): \[java] ImmutableField: False positive with lombok (fixes #4254) - [Pim van der Loos](https://github.com/PimvanderLoos) (@PimvanderLoos) * [#4488](https://github.com/pmd/pmd/pull/4488): \[java] Fix #4477: A false-positive about SignatureDeclareThrowsException - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4494](https://github.com/pmd/pmd/pull/4494): \[java] Fix #4487: A false-positive about UnnecessaryConstructor and @Inject and @Autowired - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4495](https://github.com/pmd/pmd/pull/4495): \[java] Fix #4493: false-positive about MissingStaticMethodInNonInstantiatableClass and @Inject - [AnnaDev](https://github.com/LynnBroe) (@LynnBroe) * [#4520](https://github.com/pmd/pmd/pull/4520): \[doc] Fix typo: missing closing quotation mark after CPD-END - [JoΓ£o Dinis Ferreira](https://github.com/joaodinissf) (@joaodinissf) ### πŸ“ˆ Stats * 4557 commits * 572 closed tickets & PRs * Days since last release: 35 ## 25-March-2023 - 7.0.0-rc1 We're excited to bring you the next major version of PMD! Since this is a big release, we provide here only a concise version of the release notes. We prepared a separate page with the full [Detailed Release Notes for PMD 7.0.0](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_release_notes_pmd7.html).
ℹ️ Release Candidates

PMD 7.0.0 is finally almost ready. In order to gather feedback, we are going to ship a couple of release candidates. These are officially available on GitHub and Maven Central and can be used as usual (e.g. as a dependency). We encourage you to try out the new features, but keep in mind that we may introduce API breaking changes between the release candidates. It should be stable enough if you don't use custom rules.

We have still some tasks planned for the next release candidates. You can see the progress in PMD 7 Tracking Issue #3898.

If you find any problem or difficulty while updating from PMD 6, please provide feedback via our issue tracker. That way we can improve the experience for all.

### Table Of Contents * [πŸš€ Major Features and Enhancements](#πŸš€-major-features-and-enhancements) * [New official logo](#new-official-logo) * [Revamped Java module](#revamped-java-module) * [Revamped Command Line Interface](#revamped-command-line-interface) * [Full Antlr support](#full-antlr-support) * [πŸŽ‰ Language Related Changes](#πŸŽ‰-language-related-changes) * [New: Swift support](#new:-swift-support) * [New: Kotlin support (experimental)](#new:-kotlin-support-(experimental)) * [Changed: JavaScript support](#changed:-javascript-support) * [Changed: Language versions](#changed:-language-versions) * [🌟 New and changed rules](#🌟-new-and-changed-rules) * [New Rules](#new-rules) * [Changed Rules](#changed-rules) * [Removed Rules](#removed-rules) * [🚨 API](#🚨-api) * [πŸ’₯ Compatibility and migration notes](#πŸ’₯-compatibility-and-migration-notes) * [πŸ› Fixed Issues](#πŸ›-fixed-issues) * [✨ External Contributions](#✨-external-contributions) * [πŸ“ˆ Stats](#πŸ“ˆ-stats) ### πŸš€ Major Features and Enhancements #### New official logo The new official logo of PMD: ![New PMD Logo](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/images/logo/pmd-logo-300px.png) #### Revamped Java module * Java grammar substantially refactored - more correct regarding the Java Language Specification (JLS) * Built-in rules have been upgraded for the changed AST * Rewritten type resolution framework and symbol table correctly implements the JLS * AST exposes more semantic information (method calls, field accesses) For more information, see the [Detailed Release Notes for PMD 7](pmd_release_notes_pmd7.html). Contributors: [ClΓ©ment Fournier](https://github.com/oowekyala) (@oowekyala), [Andreas Dangel](https://github.com/adangel) (@adangel), [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) #### Revamped Command Line Interface * unified and consistent Command Line Interface for both Linux/Unix and Windows across our different utilities * single script `pmd` (`pmd.bat` for Windows) to launch the different utilities: * `pmd check` to run PMD rules and analyze a project * `pmd cpd` to run CPD (copy paste detector) * `pmd designer` to run the PMD Rule Designer * progress bar support for `pmd check` * shell completion ![Demo](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/images/userdocs/pmd-demo.gif) For more information, see the [Detailed Release Notes for PMD 7](pmd_release_notes_pmd7.html). Contributors: [Juan MartΓ­n Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) #### Full Antlr support * [Antlr](https://www.antlr.org/) based grammars can now be used to build full-fledged PMD rules. * Previously, Antlr grammar could only be used for CPD * New supported languages: Swift and Kotlin For more information, see the [Detailed Release Notes for PMD 7](pmd_release_notes_pmd7.html). Contributors: [Lucas Soncini](https://github.com/lsoncini) (@lsoncini), [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga), [TomΓ‘s De Lucca](https://github.com/tomidelucca) (@tomidelucca) ### πŸŽ‰ Language Related Changes Note that this is just a concise listing of the highlight. For more information on the languages, see the [Detailed Release Notes for PMD 7](pmd_release_notes_pmd7.html). #### New: Swift support * use PMD to analyze Swift code with PMD rules * initially 4 built-in rules Contributors: [Lucas Soncini](https://github.com/lsoncini) (@lsoncini), [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga), [TomΓ‘s De Lucca](https://github.com/tomidelucca) (@tomidelucca) #### New: Kotlin support (experimental) * use PMD to analyze Kotlin code with PMD rules * Support for Kotlin 1.8 grammar * initially 2 built-in rules #### Changed: JavaScript support * latest version supports ES6 and also some new constructs (see [Rhino](https://github.com/mozilla/rhino)]) * comments are retained #### Changed: Language versions * more predefined language versions for each supported language * can be used to limit rule execution for specific versions only with `minimumLanguageVersion` and `maximumLanguageVersion` attributes. ### 🌟 New and changed rules #### New Rules **Apex** * [`UnusedMethod`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_apex_design.html#unusedmethod) finds unused methods in your code. **Java** * [`UnnecessaryBoxing`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_java_codestyle.html#unnecessaryboxing) reports boxing and unboxing conversions that may be made implicit. **Kotlin** * [`FunctionNameTooShort`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_kotlin_bestpractices.html#functionnametooshort) * [`OverrideBothEqualsAndHashcode`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_kotlin_errorprone.html#overridebothequalsandhashcode) **Swift** * [`ProhibitedInterfaceBuilder`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_swift_bestpractices.html#prohibitedinterfacebuilder) * [`UnavailableFunction`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_swift_bestpractices.html#unavailablefunction) * [`ForceCast`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_swift_errorprone.html#forcecast) * [`ForceTry`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_swift_errorprone.html#forcetry) #### Changed Rules **Java** * [`UnnecessaryFullyQualifiedName`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_java_codestyle.html#unnecessaryfullyqualifiedname): the rule has two new properties, to selectively disable reporting on static field and method qualifiers. The rule also has been improved to be more precise. * [`UselessParentheses`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_java_codestyle.html#uselessparentheses): the rule has two new properties which control how strict the rule should be applied. With `ignoreClarifying` (default: true) parentheses that are strictly speaking not necessary are allowed, if they separate expressions of different precedence. The other property `ignoreBalancing` (default: true) is similar, in that it allows parentheses that help reading and understanding the expressions. * [`LooseCoupling`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_java_bestpractices.html#loosecoupling): the rule has a new property to allow some types to be coupled to (`allowedTypes`). * [`EmptyCatchBlock`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_java_errorprone.html#emptycatchblock): `CloneNotSupportedException` and `InterruptedException` are not special-cased anymore. Rename the exception parameter to `ignored` to ignore them. * [`DontImportSun`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_java_errorprone.html#dontimportsun): `sun.misc.Signal` is not special-cased anymore. * [`UseDiamondOperator`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_java_codestyle.html#usediamondoperator): the property `java7Compatibility` is removed. The rule now handles Java 7 properly without a property. * [`SingularField`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_java_design.html#singularfield): Properties `checkInnerClasses` and `disallowNotAssignment` are removed. The rule is now more precise and will check these cases properly. * [`UseUtilityClass`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_java_design.html#useutilityclass): The property `ignoredAnnotations` has been removed. * [`LawOfDemeter`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_java_design.html#lawofdemeter): the rule has a new property `trustRadius`. This defines the maximum degree of trusted data. The default of 1 is the most restrictive. * [`CommentContent`](https://docs.pmd-code.org/pmd-doc-7.0.0-rc1/pmd_rules_java_documentation.html#commentcontent): The properties `caseSensitive` and `disallowedTerms` are removed. The new property `fobiddenRegex` can be used now to define the disallowed terms with a single regular expression. #### Removed Rules Many rules, that were previously deprecated have been finally removed. See [Detailed Release Notes for PMD 7](pmd_release_notes_pmd7.html) for the complete list. ### 🚨 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. Also, there are some improvement and changes in different areas. For the detailed description of the changes listed here, see [Detailed Release Notes for PMD 7](pmd_release_notes_pmd7.html). * Miscellaneous smaller changes and cleanups * XPath 3.1 support for XPath-based rules * Node stream API for AST traversal * Metrics framework * Testing framework * Language Lifecycle and Language Properties ### πŸ’₯ Compatibility and migration notes See [Detailed Release Notes for PMD 7](pmd_release_notes_pmd7.html). ### πŸ› Fixed Issues * miscellaneous * [#881](https://github.com/pmd/pmd/issues/881): \[all] Breaking API changes for 7.0.0 * [#896](https://github.com/pmd/pmd/issues/896): \[all] Use slf4j * [#1431](https://github.com/pmd/pmd/pull/1431): \[ui] Remove old GUI applications (designerold, bgastviewer) * [#1451](https://github.com/pmd/pmd/issues/1451): \[core] RulesetFactoryCompatibility stores the whole ruleset file in memory as a string * [#2496](https://github.com/pmd/pmd/issues/2496): Update PMD 7 Logo on landing page * [#2497](https://github.com/pmd/pmd/issues/2497): PMD 7 Logo page * [#2498](https://github.com/pmd/pmd/issues/2498): Update PMD 7 Logo in documentation * [#3797](https://github.com/pmd/pmd/issues/3797): \[all] Use JUnit5 * ant * [#4080](https://github.com/pmd/pmd/issues/4080): \[ant] Split off Ant integration into a new submodule * core * [#880](https://github.com/pmd/pmd/issues/880): \[core] Make visitors generic * [#1622](https://github.com/pmd/pmd/pull/1622): \[core] NodeStream API * [#1687](https://github.com/pmd/pmd/issues/1687): \[core] Deprecate and Remove XPath 1.0 support * [#1785](https://github.com/pmd/pmd/issues/1785): \[core] Allow abstract node types to be valid rulechain visits * [#1825](https://github.com/pmd/pmd/pull/1825): \[core] Support NoAttribute for XPath * [#2038](https://github.com/pmd/pmd/issues/2038): \[core] Remove DCD * [#2218](https://github.com/pmd/pmd/issues/2218): \[core] `isFindBoundary` should not be an attribute * [#2234](https://github.com/pmd/pmd/issues/2234): \[core] Consolidate PMD CLI into a single command * [#2239](https://github.com/pmd/pmd/issues/2239): \[core] Merging Javacc build scripts * [#2518](https://github.com/pmd/pmd/issues/2518): \[core] Language properties * [#2602](https://github.com/pmd/pmd/issues/2602): \[core] Remove ParserOptions * [#2614](https://github.com/pmd/pmd/pull/2614): \[core] Upgrade Saxon, add XPath 3.1, remove Jaxen * [#2696](https://github.com/pmd/pmd/pull/2696): \[core] Remove DFA * [#2821](https://github.com/pmd/pmd/issues/2821): \[core] Rule processing error filenames are missing paths * [#2873](https://github.com/pmd/pmd/issues/2873): \[core] Utility classes in pmd 7 * [#2885](https://github.com/pmd/pmd/issues/2885): \[core] Error recovery mode * [#3203](https://github.com/pmd/pmd/issues/3203): \[core] Replace RuleViolationFactory implementations with ViolationDecorator * [#3692](https://github.com/pmd/pmd/pull/3692): \[core] Analysis listeners * [#3782](https://github.com/pmd/pmd/issues/3782): \[core] Language lifecycle * [#3815](https://github.com/pmd/pmd/issues/3815): \[core] Update Saxon HE to 10.7 * [#3893](https://github.com/pmd/pmd/pull/3893): \[core] Text documents * [#3902](https://github.com/pmd/pmd/issues/3902): \[core] Violation decorators * [#3918](https://github.com/pmd/pmd/issues/3918): \[core] Make LanguageRegistry non static * [#3922](https://github.com/pmd/pmd/pull/3922): \[core] Better error reporting for the ruleset parser * [#4035](https://github.com/pmd/pmd/issues/4035): \[core] ConcurrentModificationException in DefaultRuleViolationFactory * [#4120](https://github.com/pmd/pmd/issues/4120): \[core] Explicitly name all language versions * [#4353](https://github.com/pmd/pmd/pull/4353): \[core] Micro optimizations for Node API * [#4365](https://github.com/pmd/pmd/pull/4365): \[core] Improve benchmarking * [#4420](https://github.com/pmd/pmd/pull/4420): \[core] Remove PMD.EOL * cli * [#2234](https://github.com/pmd/pmd/issues/2234): \[core] Consolidate PMD CLI into a single command * [#3828](https://github.com/pmd/pmd/issues/3828): \[core] Progress reporting * [#4079](https://github.com/pmd/pmd/issues/4079): \[cli] Split off CLI implementation into a pmd-cli submodule * testing * [#2435](https://github.com/pmd/pmd/issues/2435): \[test] Remove duplicated Dummy language module * [#4234](https://github.com/pmd/pmd/issues/4234): \[test] Tests that change the logging level do not work Language specific fixes: * apex * [#1937](https://github.com/pmd/pmd/issues/1937): \[apex] Apex should only have a single RootNode * [#1648](https://github.com/pmd/pmd/issues/1648): \[apex,vf] Remove CodeClimate dependency * [#1750](https://github.com/pmd/pmd/pull/1750): \[apex] Remove apex statistical rules * [#2836](https://github.com/pmd/pmd/pull/2836): \[apex] Remove Apex ProjectMirror * [#4427](https://github.com/pmd/pmd/issues/4427): \[apex] ApexBadCrypto test failing to detect inline code * apex-design * [#2667](https://github.com/pmd/pmd/issues/2667): \[apex] Integrate nawforce/ApexLink to build robust Unused rule * java * [#520](https://github.com/pmd/pmd/issues/520): \[java] Allow `@SuppressWarnings` with constants instead of literals * [#864](https://github.com/pmd/pmd/issues/864): \[java] Similar/duplicated implementations for determining FQCN * [#905](https://github.com/pmd/pmd/issues/905): \[java] Add new node for anonymous class declaration * [#910](https://github.com/pmd/pmd/issues/910): \[java] AST inconsistency between primitive and reference type arrays * [#997](https://github.com/pmd/pmd/issues/997): \[java] Java8 parsing corner case with annotated array types * [#998](https://github.com/pmd/pmd/issues/998): \[java] AST inconsistencies around FormalParameter * [#1019](https://github.com/pmd/pmd/issues/1019): \[java] Breaking Java Grammar changes for PMD 7.0.0 * [#1124](https://github.com/pmd/pmd/issues/1124): \[java] ImmutableList implementation in the qname codebase * [#1128](https://github.com/pmd/pmd/issues/1128): \[java] Improve ASTLocalVariableDeclaration * [#1150](https://github.com/pmd/pmd/issues/1150): \[java] ClassOrInterfaceType AST improvements * [#1207](https://github.com/pmd/pmd/issues/1207): \[java] Resolve explicit types using FQCNs, without hitting the classloader * [#1367](https://github.com/pmd/pmd/issues/1367): \[java] Parsing error on annotated inner class * [#1661](https://github.com/pmd/pmd/issues/1661): \[java] About operator nodes * [#2366](https://github.com/pmd/pmd/pull/2366): \[java] Remove qualified names * [#2819](https://github.com/pmd/pmd/issues/2819): \[java] GLB bugs in pmd 7 * [#3763](https://github.com/pmd/pmd/issues/3763): \[java] Ambiguous reference error in valid code * [#3749](https://github.com/pmd/pmd/issues/3749): \[java] Improve `isOverridden` in ASTMethodDeclaration * [#3750](https://github.com/pmd/pmd/issues/3750): \[java] Make symbol table support instanceof pattern bindings * [#3752](https://github.com/pmd/pmd/issues/3752): \[java] Expose annotations in symbol API * [#4237](https://github.com/pmd/pmd/pull/4237): \[java] Cleanup handling of Java comments * [#4317](https://github.com/pmd/pmd/issues/4317): \[java] Some AST nodes should not be TypeNodes * [#4359](https://github.com/pmd/pmd/issues/4359): \[java] Type resolution fails with NPE when the scope is not a type declaration * [#4367](https://github.com/pmd/pmd/issues/4367): \[java] Move testrule TypeResTest into internal * java-bestpractices * [#342](https://github.com/pmd/pmd/issues/342): \[java] AccessorMethodGeneration: Name clash with another public field not properly handled * [#755](https://github.com/pmd/pmd/issues/755): \[java] AccessorClassGeneration false positive for private constructors * [#770](https://github.com/pmd/pmd/issues/770): \[java] UnusedPrivateMethod yields false positive for counter-variant arguments * [#807](https://github.com/pmd/pmd/issues/807): \[java] AccessorMethodGeneration false positive with overloads * [#833](https://github.com/pmd/pmd/issues/833): \[java] ForLoopCanBeForeach should consider iterating on this * [#1189](https://github.com/pmd/pmd/issues/1189): \[java] UnusedPrivateMethod false positive from inner class via external class * [#1205](https://github.com/pmd/pmd/issues/1205): \[java] Improve ConstantsInInterface message to mention alternatives * [#1212](https://github.com/pmd/pmd/issues/1212): \[java] Don't raise JUnitTestContainsTooManyAsserts on JUnit 5's assertAll * [#1422](https://github.com/pmd/pmd/issues/1422): \[java] JUnitTestsShouldIncludeAssert false positive with inherited @Rule field * [#1565](https://github.com/pmd/pmd/issues/1565): \[java] JUnitAssertionsShouldIncludeMessage false positive with AssertJ * [#1747](https://github.com/pmd/pmd/issues/1747): \[java] PreserveStackTrace false-positive * [#1969](https://github.com/pmd/pmd/issues/1969): \[java] MissingOverride false-positive triggered by package-private method overwritten in another package by extending class * [#1998](https://github.com/pmd/pmd/issues/1998): \[java] AccessorClassGeneration false-negative: subclass calls private constructor * [#2130](https://github.com/pmd/pmd/issues/2130): \[java] UnusedLocalVariable: false-negative with array * [#2147](https://github.com/pmd/pmd/issues/2147): \[java] JUnitTestsShouldIncludeAssert - false positives with lambdas and static methods * [#2464](https://github.com/pmd/pmd/issues/2464): \[java] LooseCoupling must ignore class literals: ArrayList.class * [#2542](https://github.com/pmd/pmd/issues/2542): \[java] UseCollectionIsEmpty can not detect the case `foo.bar().size()` * [#2650](https://github.com/pmd/pmd/issues/2650): \[java] UseTryWithResources false positive when AutoCloseable helper used * [#2796](https://github.com/pmd/pmd/issues/2796): \[java] UnusedAssignment false positive with call chains * [#2797](https://github.com/pmd/pmd/issues/2797): \[java] MissingOverride long-standing issues * [#2806](https://github.com/pmd/pmd/issues/2806): \[java] SwitchStmtsShouldHaveDefault false-positive with Java 14 switch non-fallthrough branches * [#2822](https://github.com/pmd/pmd/issues/2822): \[java] LooseCoupling rule: Extend to cover user defined implementations and interfaces * [#2843](https://github.com/pmd/pmd/pull/2843): \[java] Fix UnusedAssignment FP with field accesses * [#2882](https://github.com/pmd/pmd/issues/2882): \[java] UseTryWithResources - false negative for explicit close * [#2883](https://github.com/pmd/pmd/issues/2883): \[java] JUnitAssertionsShouldIncludeMessage false positive with method call * [#2890](https://github.com/pmd/pmd/issues/2890): \[java] UnusedPrivateMethod false positive with generics * [#2946](https://github.com/pmd/pmd/issues/2946): \[java] SwitchStmtsShouldHaveDefault false positive on enum inside enums * [#3672](https://github.com/pmd/pmd/pull/3672): \[java] LooseCoupling - fix false positive with generics * [#3675](https://github.com/pmd/pmd/pull/3675): \[java] MissingOverride - fix false positive with mixing type vars * java-codestyle * [#1208](https://github.com/pmd/pmd/issues/1208): \[java] PrematureDeclaration rule false-positive on variable declared to measure time * [#1429](https://github.com/pmd/pmd/issues/1429): \[java] PrematureDeclaration as result of method call (false positive) * [#1673](https://github.com/pmd/pmd/issues/1673): \[java] UselessParentheses false positive with conditional operator * [#1790](https://github.com/pmd/pmd/issues/1790): \[java] UnnecessaryFullyQualifiedName false positive with enum constant * [#1918](https://github.com/pmd/pmd/issues/1918): \[java] UselessParentheses false positive with boolean operators * [#2134](https://github.com/pmd/pmd/issues/2134): \[java] PreserveStackTrace not handling `Throwable.addSuppressed(...)` * [#2299](https://github.com/pmd/pmd/issues/2299): \[java] UnnecessaryFullyQualifiedName false positive with similar package name * [#2391](https://github.com/pmd/pmd/issues/2391): \[java] UseDiamondOperator FP when expected type and constructed type have a different parameterization * [#2528](https://github.com/pmd/pmd/issues/2528): \[java] MethodNamingConventions - JUnit 5 method naming not support ParameterizedTest * [#2739](https://github.com/pmd/pmd/issues/2739): \[java] UselessParentheses false positive for string concatenation * [#2748](https://github.com/pmd/pmd/issues/2748): \[java] UnnecessaryCast false positive with unchecked cast * [#2973](https://github.com/pmd/pmd/issues/2973): \[java] New rule: UnnecessaryBoxing * [#3195](https://github.com/pmd/pmd/pull/3195): \[java] Improve rule UnnecessaryReturn to detect more cases * [#3218](https://github.com/pmd/pmd/pull/3218): \[java] Generalize UnnecessaryCast to flag all unnecessary casts * [#3221](https://github.com/pmd/pmd/issues/3221): \[java] PrematureDeclaration false positive for unused variables * [#3238](https://github.com/pmd/pmd/issues/3238): \[java] Improve ExprContext, fix FNs of UnnecessaryCast * [#3500](https://github.com/pmd/pmd/pull/3500): \[java] UnnecessaryBoxing - check for Integer.valueOf(String) calls * [#4357](https://github.com/pmd/pmd/pull/4357): \[java] Fix IllegalStateException in UseDiamondOperator rule * java-design * [#1014](https://github.com/pmd/pmd/issues/1014): \[java] LawOfDemeter: False positive with lambda expression * [#1605](https://github.com/pmd/pmd/issues/1605): \[java] LawOfDemeter: False positive for standard UTF-8 charset name * [#2175](https://github.com/pmd/pmd/issues/2175): \[java] LawOfDemeter: False positive for chained methods with generic method call * [#2179](https://github.com/pmd/pmd/issues/2179): \[java] LawOfDemeter: False positive with static property access - should treat class-level property as global object, not dot-accessed property * [#2180](https://github.com/pmd/pmd/issues/2180): \[java] LawOfDemeter: False positive with Thread and ThreadLocalRandom * [#2182](https://github.com/pmd/pmd/issues/2182): \[java] LawOfDemeter: False positive with package-private access * [#2188](https://github.com/pmd/pmd/issues/2188): \[java] LawOfDemeter: False positive with fields assigned to local vars * [#2536](https://github.com/pmd/pmd/issues/2536): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal can't detect inner class * [#3668](https://github.com/pmd/pmd/pull/3668): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal - fix FP with inner private classes * [#3754](https://github.com/pmd/pmd/issues/3754): \[java] SingularField false positive with read in while condition * [#3786](https://github.com/pmd/pmd/issues/3786): \[java] SimplifyBooleanReturns should consider operator precedence * [#4238](https://github.com/pmd/pmd/pull/4238): \[java] Make LawOfDemeter not use the rulechain * java-documentation * [#4369](https://github.com/pmd/pmd/pull/4369): \[java] Improve CommentSize * [#4416](https://github.com/pmd/pmd/pull/4416): \[java] Fix reported line number in CommentContentRule * java-errorprone * [#659](https://github.com/pmd/pmd/issues/659): \[java] MissingBreakInSwitch - last default case does not contain a break * [#1005](https://github.com/pmd/pmd/issues/1005): \[java] CloneMethodMustImplementCloneable triggers for interfaces * [#1669](https://github.com/pmd/pmd/issues/1669): \[java] NullAssignment - FP with ternay and null as constructor argument * [#1899](https://github.com/pmd/pmd/issues/1899): \[java] Recognize @SuppressWanings("fallthrough") for MissingBreakInSwitch * [#2320](https://github.com/pmd/pmd/issues/2320): \[java] NullAssignment - FP with ternary and null as method argument * [#2532](https://github.com/pmd/pmd/issues/2532): \[java] AvoidDecimalLiteralsInBigDecimalConstructor can not detect the case `new BigDecimal(Expression)` * [#2579](https://github.com/pmd/pmd/issues/2579): \[java] MissingBreakInSwitch detects the lack of break in the last case * [#2880](https://github.com/pmd/pmd/issues/2880): \[java] CompareObjectsWithEquals - false negative with type res * [#2893](https://github.com/pmd/pmd/issues/2893): \[java] Remove special cases from rule EmptyCatchBlock * [#2894](https://github.com/pmd/pmd/issues/2894): \[java] Improve MissingBreakInSwitch * [#3071](https://github.com/pmd/pmd/issues/3071): \[java] BrokenNullCheck FP with PMD 6.30.0 * [#3087](https://github.com/pmd/pmd/issues/3087): \[java] UnnecessaryBooleanAssertion overlaps with SimplifiableTestAssertion * [#3100](https://github.com/pmd/pmd/issues/3100): \[java] UseCorrectExceptionLogging FP in 6.31.0 * [#3173](https://github.com/pmd/pmd/issues/3173): \[java] UseProperClassLoader false positive * [#3351](https://github.com/pmd/pmd/issues/3351): \[java] ConstructorCallsOverridableMethod ignores abstract methods * [#3400](https://github.com/pmd/pmd/issues/3400): \[java] AvoidUsingOctalValues FN with underscores * [#4356](https://github.com/pmd/pmd/pull/4356): \[java] Fix NPE in CloseResourceRule * java-multithreading * [#2537](https://github.com/pmd/pmd/issues/2537): \[java] DontCallThreadRun can't detect the case that call run() in `this.run()` * [#2538](https://github.com/pmd/pmd/issues/2538): \[java] DontCallThreadRun can't detect the case that call run() in `foo.bar.run()` * [#2577](https://github.com/pmd/pmd/issues/2577): \[java] UseNotifyAllInsteadOfNotify falsely detect a special case with argument: `foo.notify(bar)` * java-performance * [#1224](https://github.com/pmd/pmd/issues/1224): \[java] InefficientEmptyStringCheck false negative in anonymous class * [#2587](https://github.com/pmd/pmd/issues/2587): \[java] AvoidArrayLoops could also check for list copy through iterated List.add() * [#2712](https://github.com/pmd/pmd/issues/2712): \[java] SimplifyStartsWith false-positive with AssertJ * [#3486](https://github.com/pmd/pmd/pull/3486): \[java] InsufficientStringBufferDeclaration: Fix NPE * kotlin * [#419](https://github.com/pmd/pmd/issues/419): \[kotlin] Add support for Kotlin * [#4389](https://github.com/pmd/pmd/pull/4389): \[kotlin] Update grammar to version 1.8 * swift * [#1877](https://github.com/pmd/pmd/pull/1877): \[swift] Feature/swift rules * [#1882](https://github.com/pmd/pmd/pull/1882): \[swift] UnavailableFunction Swift rule * xml * [#1800](https://github.com/pmd/pmd/pull/1800): \[xml] Unimplement org.w3c.dom.Node from the XmlNodeWrapper ### ✨ External Contributions * [#1658](https://github.com/pmd/pmd/pull/1658): \[core] Node support for Antlr-based languages - [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga) * [#1698](https://github.com/pmd/pmd/pull/1698): \[core] [swift] Antlr Base Parser adapter and Swift Implementation - [Lucas Soncini](https://github.com/lsoncini) (@lsoncini) * [#1774](https://github.com/pmd/pmd/pull/1774): \[core] Antlr visitor rules - [Lucas Soncini](https://github.com/lsoncini) (@lsoncini) * [#1877](https://github.com/pmd/pmd/pull/1877): \[swift] Feature/swift rules - [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga) * [#1881](https://github.com/pmd/pmd/pull/1881): \[doc] Add ANTLR documentation - [MatΓ­as Fraga](https://github.com/matifraga) (@matifraga) * [#1882](https://github.com/pmd/pmd/pull/1882): \[swift] UnavailableFunction Swift rule - [TomΓ‘s de Lucca](https://github.com/tomidelucca) (@tomidelucca) * [#2830](https://github.com/pmd/pmd/pull/2830): \[apex] Apexlink POC - [Kevin Jones](https://github.com/nawforce) (@nawforce) * [#3866](https://github.com/pmd/pmd/pull/3866): \[core] Add CLI Progress Bar - [@JerritEic](https://github.com/JerritEic) (@JerritEic) * [#4412](https://github.com/pmd/pmd/pull/4412): \[doc] Added new error msg to ConstantsInInterface - [David Ljunggren](https://github.com/dague1) (@dague1) * [#4428](https://github.com/pmd/pmd/pull/4428): \[apex] ApexBadCrypto bug fix for #4427 - inline detection of hard coded values - [Steven Stearns](https://github.com/sfdcsteve) (@sfdcsteve) ### πŸ“ˆ Stats * 4416 commits * 464 closed tickets & PRs * Days since last release: 28 ## 25-February-2023 - 6.55.0 The PMD team is pleased to announce PMD 6.55.0. This is a minor release. ### Table Of Contents * [New and noteworthy](#new-and-noteworthy) * [PMD 7 Development](#pmd-7-development) * [Java 20 Support](#java-20-support) * [T-SQL support](#t-sql-support) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [Go](#go) * [Java](#java) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### PMD 7 Development This release is the last planned release of PMD 6. The first version 6.0.0 was released in December 2017. Over the course of more than 5 years we published almost every month a new minor version of PMD 6 with new features and improvements. Already in November 2018 we started in parallel the development of the next major version 7.0.0, and we are now in the process of finalizing the scope of the major version. We want to release a couple of release candidates before publishing the final version 7.0.0. We plan to release 7.0.0-rc1 soon. You can see the progress in [PMD 7 Tracking Issue #3898](https://github.com/pmd/pmd/issues/3898). #### Java 20 Support This release of PMD brings support for Java 20. There are no new standard language features. PMD supports [JEP 433: Pattern Matching for switch (Fourth Preview)](https://openjdk.org/jeps/433) and [JEP 432: Record Patterns (Second Preview)](https://openjdk.org/jeps/432) 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 `20-preview`: export PMD_JAVA_OPTS=--enable-preview ./run.sh pmd --use-version java-20-preview ... #### T-SQL support Thanks to the contribution from [Paul Guyot](https://github.com/pguyot) PMD now has CPD support for T-SQL (Transact-SQL). Being based on a proper Antlr grammar, CPD can: * ignore comments * honor [comment-based suppressions](pmd_userdocs_cpd.html#suppression) ### Fixed Issues * core * [#4395](https://github.com/pmd/pmd/issues/4395): \[core] Support environment variable CLASSPATH with pmd.bat under Windows * java * [#4333](https://github.com/pmd/pmd/issues/4333): \[java] Support JDK 20 * java-errorprone * [#4393](https://github.com/pmd/pmd/issues/4393): \[java] MissingStaticMethodInNonInstantiatableClass false-positive for Lombok's @UtilityClass for classes with non-private fields ### API Changes #### Go * The LanguageModule of Go, that only supports CPD execution, has been deprecated. This language is not fully supported by PMD, so having a language module does not make sense. The functionality of CPD is not affected by this change. The following class has been deprecated and will be removed with PMD 7.0.0: * GoLanguageModule #### Java * Support for Java 18 preview language features have been removed. The version "18-preview" is no longer available. * The experimental class `net.sourceforge.pmd.lang.java.ast.ASTGuardedPattern` has been removed. ### External Contributions * [#4384](https://github.com/pmd/pmd/pull/4384): \[swift] Add more swift 5.x support (#unavailable mainly) - [Richard B.](https://github.com/kenji21) (@kenji21) * [#4390](https://github.com/pmd/pmd/pull/4390): Add support for T-SQL using Antlr4 lexer - [Paul Guyot](https://github.com/pguyot) (@pguyot) * [#4392](https://github.com/pmd/pmd/pull/4392): \[java] Fix #4393 MissingStaticMethodInNonInstantiatableClass: Fix false-positive for field-only class - [Dawid Ciok](https://github.com/dawiddc) (@dawiddc) ### Stats * 40 commits * 11 closed tickets & PRs * Days since last release: 28 ## 28-January-2023 - 6.54.0 The PMD team is pleased to announce PMD 6.54.0. This is a minor release. ### Table Of Contents * [New and noteworthy](#new-and-noteworthy) * [New report format html-report-v2.xslt](#new-report-format-html-report-v2.xslt) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [PMD CLI](#pmd-cli) * [Deprecated APIs](#deprecated-apis) * [For removal](#for-removal) * [Internal APIs](#internal-apis) * [Experimental APIs](#experimental-apis) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### New report format html-report-v2.xslt Thanks to @mohan-chinnappan-n a new PMD report format has been added which features a data table with charting functions. It uses an XSLT stylesheet to convert PMD's XML format into HTML. See [the example report](report-examples/html-report-v2.html). ### Fixed Issues * apex-bestpractices * [#2669](https://github.com/pmd/pmd/issues/2669): \[apex] UnusedLocalVariable false positive in dynamic SOQL * core * [#4026](https://github.com/pmd/pmd/issues/4026): \[cli] Filenames printed as absolute paths in the report despite parameter `--short-names` * [#4279](https://github.com/pmd/pmd/issues/4279): \[core] Can not set ruleset property value to empty * [#4329](https://github.com/pmd/pmd/pull/4329): \[core] Refactor usage of snakeyaml * [#4340](https://github.com/pmd/pmd/issues/4340): \[core] Allow to filter found matches in CPDReport * java * [#4364](https://github.com/pmd/pmd/issues/4364): \[java] Parsing error with textblock containing quote followed by two backslashes * testing * [#4236](https://github.com/pmd/pmd/issues/4236): \[test] kotest logs look broken ### API Changes #### PMD CLI * PMD now supports a new `--relativize-paths-with` flag (or short `-z`), which replaces `--short-names`. It serves the same purpose: Shortening the pathnames in the reports. However, with the new flag it's possible to explicitly define one or more pathnames that should be used as the base when creating relative paths. The old flag `--short-names` is deprecated. #### Deprecated APIs ##### For removal * ApexRootNode#getApexVersion has been deprecated for removal. The version returned is always `Version.CURRENT`, as the apex compiler integration doesn't use additional information which Apex version actually is used. Therefore, this method can't be used to determine the Apex version of the project that is being analyzed. * CPDConfiguration#setEncoding and CPDConfiguration#getEncoding. Use the methods getSourceEncoding and setSourceEncoding instead. Both are available for `CPDConfiguration` which extends `AbstractConfiguration`. * BaseCLITest and BaseCPDCLITest have been deprecated for removal without replacement. CLI tests should be done in pmd-core only (and in PMD7 in pmd-cli). Individual language modules shouldn't need to test the CLI integration logic again. Instead, the individual language modules should test their functionality as unit tests. * CPDConfiguration.LanguageConverter * FileCollector#addZipFile has been deprecated. It is replaced by FileCollector#addZipFileWithContent which directly adds the content of the zip file for analysis. * PMDConfiguration#setReportShortNames and PMDConfiguration#isReportShortNames have been deprecated for removal. Use PMDConfiguration#addRelativizeRoot instead. ##### Internal APIs * CSVWriter * Some fields in AbstractAntTestHelper ##### Experimental APIs * CPDReport has a new method which limited mutation of a given report: * filterMatches creates a new CPD report with some matches removed with a given predicate based filter. ### External Contributions * [#4110](https://github.com/pmd/pmd/pull/4110): \[apex] Feature/unused variable bind false positive with dynamic SOQL - [Thomas Prouvot](https://github.com/tprouvot) (@tprouvot) * [#4125](https://github.com/pmd/pmd/pull/4125): \[core] New report format html-report-v2.xslt to provide html with datatable and chart features - [Mohan Chinnappan](https://github.com/mohan-chinnappan-n) - (@mohan-chinnappan-n) * [#4280](https://github.com/pmd/pmd/pull/4280): \[apex] Deprecate ApexRootNode.getApexVersion - [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google) * [#4285](https://github.com/pmd/pmd/pull/4285): \[java] CommentDefaultAccessModifier - add co.elastic.clients.util.VisibleForTesting as default suppressed annotation - [Matthew Luckam](https://github.com/mluckam) (@mluckam) ### Stats * 107 commits * 19 closed tickets & PRs * Days since last release: 27 ## 31-December-2022 - 6.53.0 The PMD team is pleased to announce PMD 6.53.0. This is a minor release. ### Table Of Contents * [New and noteworthy](#new-and-noteworthy) * [Modified rules](#modified-rules) * [Deprecated rules](#deprecated-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [Deprecated APIs](#deprecated-apis) * [For removal](#for-removal) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### Modified rules * The Java rule [`UnusedPrivateField`](https://pmd.github.io/pmd-6.53.0/pmd_rules_java_bestpractices.html#unusedprivatefield) has a new property `reportForAnnotations`. This is a list of fully qualified names of the annotation types that should be reported anyway. If an unused field has any of these annotations, then it is reported. If it has any other annotation, then it is still considered to be used and is not reported. #### Deprecated rules * The Java rules [`ExcessiveClassLength`](https://pmd.github.io/pmd-6.53.0/pmd_rules_java_design.html#excessiveclasslength) and [`ExcessiveMethodLength`](https://pmd.github.io/pmd-6.53.0/pmd_rules_java_design.html#excessivemethodlength) have been deprecated. The rule [`NcssCount`](https://pmd.github.io/pmd-6.53.0/pmd_rules_java_design.html#ncsscount) can be used instead. The deprecated rules will be removed with PMD 7.0.0. * The Java rule [`EmptyStatementNotInLoop`](https://pmd.github.io/pmd-6.53.0/pmd_rules_java_errorprone.html#emptystatementnotinloop) is deprecated. Use the rule [`UnnecessarySemicolon`](https://pmd.github.io/pmd-6.53.0/pmd_rules_java_codestyle.html#unnecessarysemicolon) instead. Note: Actually it was announced to be deprecated since 6.46.0 but the rule was not marked as deprecated yet. This has been done now. ### Fixed Issues * core * [#4248](https://github.com/pmd/pmd/issues/4248): \[core] Can't analyze sources in zip files * apex-security * [#4146](https://github.com/pmd/pmd/issues/4146): \[apex] ApexCRUDViolation: Recognize User Mode in SOQL + DML * java * [#4266](https://github.com/pmd/pmd/issues/4266): \[java] PMD fails to process a record with lambda in compact constructor * java-bestpractices * [#4166](https://github.com/pmd/pmd/issues/4166): \[java] UnusedPrivateField doesn't find annotated unused private fields anymore * [#4250](https://github.com/pmd/pmd/issues/4250): \[java] WhileLoopWithLiteralBoolean - false negative with complex expressions still occurs in PMD 6.52.0 * java-design * [#2127](https://github.com/pmd/pmd/issues/2127): \[java] Deprecate rules ExcessiveClassLength and ExcessiveMethodLength * java-errorprone * [#4164](https://github.com/pmd/pmd/issues/4164): \[java]\[doc] AvoidAssertAsIdentifier and AvoidEnumAsIdentifier - clarify use case * java-multithreading * [#4210](https://github.com/pmd/pmd/issues/4210): \[java] DoNotUseThreads report duplicate warnings ### API Changes #### Deprecated APIs ##### For removal These classes / APIs have been deprecated and will be removed with PMD 7.0.0. * ExcessiveLengthRule (Java) ### External Contributions * [#4244](https://github.com/pmd/pmd/pull/4244): \[apex] ApexCRUDViolation: user mode and system mode with test cases added - [Tarush Singh](https://github.com/Tarush-Singh35) (@Tarush-Singh35) * [#4274](https://github.com/pmd/pmd/pull/4274): \[java] Fix finding lambda scope in record compact constructor - [kdebski85](https://github.com/kdebski85) (@kdebski85) ### Stats * 43 commits * 17 closed tickets & PRs * Days since last release: 35 ## 26-November-2022 - 6.52.0 The PMD team is pleased to announce PMD 6.52.0. This is a minor release. ### Table Of Contents * [New and noteworthy](#new-and-noteworthy) * [New rules](#new-rules) * [Renamed rules](#renamed-rules) * [Modified rules](#modified-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [PMD CLI](#pmd-cli) * [CPD CLI](#cpd-cli) * [Linux run.sh parameters](#linux-run.sh-parameters) * [Deprecated API](#deprecated-api) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### New rules * The new Java rule [`InvalidJavaBean`](https://pmd.github.io/pmd-6.52.0/pmd_rules_java_design.html#invalidjavabean) identifies beans, that don't follow the [JavaBeans API specification](https://download.oracle.com/otndocs/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/), like beans with missing getters or setters. ```xml ``` #### Renamed rules * The Java rule [`BeanMembersShouldSerialize`](https://pmd.github.io/pmd-6.52.0/pmd_rules_java_errorprone.html#beanmembersshouldserialize) has been renamed to [`NonSerializableClass`](https://pmd.github.io/pmd-6.52.0/pmd_rules_java_errorprone.html#nonserializableclass). It has been revamped to only check for classes that are marked with `Serializable` and reports each field in it, that is not serializable. The property `prefix` has been deprecated, since in a serializable class all fields have to be serializable regardless of the name. #### Modified rules * The rule [`ClassNamingConventions`](https://pmd.github.io/pmd-6.52.0/pmd_rules_java_codestyle.html#classnamingconventions) has a new property `testClassPattern`, which is applied to test classes. By default, test classes should end with the suffix "Test". Test classes are top-level classes, that either inherit from JUnit 3 TestCase or have at least one method annotated with the Test annotations from JUnit4/5 or TestNG. * The property `ignoredAnnotations` of rule [`ImmutableField`](https://pmd.github.io/pmd-6.52.0/pmd_rules_java_design.html#immutablefield) has been deprecated and doesn't have any effect anymore. Since PMD 6.47.0, the rule only considers fields, that are initialized once and never changed. If the field is just declared but never explicitly initialized, it won't be reported. That's the typical case when a framework sets the field value by reflection. Therefore, the property is not needed anymore. If there is a special case where this rule misidentifies fields as immutable, then the rule should be suppressed for these fields explicitly. ### Fixed Issues * cli * [#4215](https://github.com/pmd/pmd/discussions/4215): NullPointerException when trying to open designer * doc * [#4207](https://github.com/pmd/pmd/pull/4207): \[doc] List all languages in rule doc * java * [#3643](https://github.com/pmd/pmd/issues/3643): \[java] More parser edge cases * [#4152](https://github.com/pmd/pmd/issues/4152): \[java] Parse error on array type annotations * java-codestyle * [#2867](https://github.com/pmd/pmd/issues/2867): \[java] Separate pattern for test classes in ClassNamingConventions rule for Java * [#4201](https://github.com/pmd/pmd/issues/4201): \[java] CommentDefaultAccessModifier should consider lombok's @Value * java-design * [#4175](https://github.com/pmd/pmd/issues/4175): \[java] ImmutableField - deprecate property `ignoredAnnotations` * [#4177](https://github.com/pmd/pmd/issues/4177): \[java] New Rule InvalidJavaBean * [#4188](https://github.com/pmd/pmd/issues/4188): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal false positive with Lombok's @NoArgsConstructor * [#4189](https://github.com/pmd/pmd/issues/4189): \[java] AbstractClassWithoutAnyMethod should consider lombok's @AllArgsConstructor * [#4200](https://github.com/pmd/pmd/issues/4200): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal should consider lombok's @Value * java-errorprone * [#1668](https://github.com/pmd/pmd/issues/1668): \[java] BeanMembersShouldSerialize is extremely noisy * [#4172](https://github.com/pmd/pmd/issues/4172): \[java] InvalidLogMessageFormat false positive on externally formatted strings * [#4174](https://github.com/pmd/pmd/issues/4174): \[java] MissingStaticMethodInNonInstantiatableClass does not consider nested builder class * [#4176](https://github.com/pmd/pmd/issues/4176): \[java] Rename BeanMembersShouldSerialize to NonSerializableClass * [#4185](https://github.com/pmd/pmd/issues/4185): \[java] InvalidLogMessageFormat rule produces a NPE * [#4224](https://github.com/pmd/pmd/issues/4224): \[java] MissingStaticMethodInNonInstantiatableClass should consider Lombok's @UtilityClass * [#4225](https://github.com/pmd/pmd/issues/4225): \[java] MissingStaticMethodInNonInstantiatableClass should consider Lombok's @NoArgsConstructor * java-performance * [#4183](https://github.com/pmd/pmd/issues/4183): \[java] AvoidArrayLoops regression: from false negative to false positive with final variables ### API Changes #### PMD CLI * PMD now supports a new `--use-version` flag, which receives a language-version pair (such as `java-8` or `apex-54`). This supersedes the usage of `-language` / `-l` and `-version` / `-v`, allowing for multiple versions to be set in a single run. PMD 7 will completely remove support for `-language` and `-version` in favor of this new flag. * Support for `-V` is being deprecated in favor of `--verbose` in preparation for PMD 7. In PMD 7, `-v` will enable verbose mode and `-V` will show the PMD version for consistency with most Unix/Linux tools. * Support for `-min` is being deprecated in favor of `--minimum-priority` for consistency with most Unix/Linux tools, where `-min` would be equivalent to `-m -i -n`. #### CPD CLI * CPD now supports using `-d` or `--dir` as an alias to `--files`, in favor of consistency with PMD. PMD 7 will remove support for `--files` in favor of these new flags. #### Linux run.sh parameters * Using `run.sh cpdgui` will now warn about it being deprecated. Use `run.sh cpd-gui` instead. * The old designer (`run.sh designerold`) is completely deprecated and will be removed in PMD 7. Switch to the new JavaFX designer: `run.sh designer`. * The old visual AST viewer (`run.sh bgastviewer`) is completely deprecated and will be removed in PMD 7. Switch to the new JavaFX designer: `run.sh designer` for a visual tool, or use `run.sh ast-dump` for a text-based alternative. #### Deprecated API * The following core APIs have been marked as deprecated for removal in PMD 7: - PMD and PMD.StatusCode - PMD 7 will ship with a revamped CLI split from pmd-core. To programmatically launch analysis you can use PmdAnalysis. - PMDConfiguration#getAllInputPaths - It is now superseded by PMDConfiguration#getInputPathList - PMDConfiguration#setInputPaths - It is now superseded by PMDConfiguration#setInputPathList - PMDConfiguration#addInputPath - It is now superseded by PMDConfiguration#addInputPath - PMDConfiguration#getInputFilePath - It is now superseded by PMDConfiguration#getInputFile - PMDConfiguration#getIgnoreFilePath - It is now superseded by PMDConfiguration#getIgnoreFile - PMDConfiguration#setInputFilePath - It is now superseded by PMDConfiguration#setInputFilePath - PMDConfiguration#setIgnoreFilePath - It is now superseded by PMDConfiguration#setIgnoreFilePath - PMDConfiguration#getInputUri - It is now superseded by PMDConfiguration#getUri - PMDConfiguration#setInputUri - It is now superseded by PMDConfiguration#setInputUri - PMDConfiguration#getReportFile - It is now superseded by PMDConfiguration#getReportFilePath - PMDConfiguration#setReportFile - It is now superseded by PMDConfiguration#setReportFile - PMDConfiguration#isStressTest and PMDConfiguration#setStressTest - Will be removed with no replacement. - PMDConfiguration#isBenchmark and PMDConfiguration#setBenchmark - Will be removed with no replacement, the CLI will still support it. - CPD and CPD.StatusCode - PMD 7 will ship with a revamped CLI split from pmd-core. An alterative to programatically launch CPD analysis will be added in due time. * In order to reduce the dependency on Apex Jorje classes, the method DataType#fromBasicType has been deprecated. The equivalent method fromTypeName should be used instead. ### External Contributions * [#4184](https://github.com/pmd/pmd/pull/4184): \[java]\[doc] TestClassWithoutTestCases - fix small typo in description - [Valery Yatsynovich](https://github.com/valfirst) (@valfirst) * [#4198](https://github.com/pmd/pmd/pull/4198): \[doc] Add supported CPD languages - [Jeroen van Wilgenburg](https://github.com/jvwilge) (@jvwilge) * [#4202](https://github.com/pmd/pmd/pull/4202): \[java] Fix #4200 and #4201: ClassWithOnlyPrivateConstructorsShouldBeFinal, CommentDefaultAccessModifier: Exclude lombok @Value annotation - [Lynn](https://github.com/LynnBroe) (@LynnBroe) * [#4205](https://github.com/pmd/pmd/pull/4205): \[doc] Clarify Scala support (no built-in rules) - [Eldrick Wega](https://github.com/Eldrick19) (@Eldrick19) * [#4226](https://github.com/pmd/pmd/pull/4226): \[visualforce] Replace uses of Jorje types in pmd-visualforce - [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-google) * [#4227](https://github.com/pmd/pmd/pull/4227): \[java] Fix #4225 MissingStaticMethodInNonInstantiatableClass: Exclude lombok's @NoArgsConstructor annotation - [Lynn](https://github.com/LynnBroe) (@LynnBroe) * [#4228](https://github.com/pmd/pmd/pull/4228): \[java] Fix #4224 MissingStaticMethodInNonInstantiatableClass: Exclude lombok's UtilityClass - [Lynn](https://github.com/LynnBroe) (@LynnBroe) * [#4232](https://github.com/pmd/pmd/pull/4232): \[doc] Fixing typos - [Andreas Deininger](https://github.com/deining) (@deining) ### Stats * 96 commits * 40 closed tickets & PRs * Days since last release: 28 ## 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-and-noteworthy) * [New Rules](#new-rules) * [Modified Rules](#modified-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### New Rules * The new Apex rule [`ApexUnitTestClassShouldHaveRunAs`](https://pmd.github.io/pmd-6.51.0/pmd_rules_apex_bestpractices.html#apexunittestclassshouldhaverunas) ensures that unit tests use [System.runAs()](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_tools_runas.htm) at least once. This makes the tests more robust, and independent from the user running it. ```xml ``` The rule is part of the quickstart.xml ruleset. #### Modified Rules * The Java rule [`TestClassWithoutTestCases`](https://pmd.github.io/pmd-6.51.0/pmd_rules_java_errorprone.html#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](https://github.com/pmd/pmd/issues/4149): \[apex] New rule: ApexUnitTestClassShouldHaveRunAs * doc * [#4144](https://github.com/pmd/pmd/pull/4144): \[doc] Update docs to reflect supported languages * [#4163](https://github.com/pmd/pmd/issues/4163): \[doc] Broken links on page "Architecture Decisions" * java-bestpractices * [#4140](https://github.com/pmd/pmd/issues/4140): \[java] \[doc] AccessorClassGeneration violations hidden with Java 11 * java-codestyle * [#4139](https://github.com/pmd/pmd/issues/4139): \[java] UnnecessaryFullyQualifiedName FP when the same simple class name exists in the current package * java-documentation * [#4141](https://github.com/pmd/pmd/issues/4141): \[java] UncommentedEmptyConstructor FP when constructor annotated with @Autowired * java-performance * [#1167](https://github.com/pmd/pmd/issues/1167): \[java] AvoidArrayLoops false positive on double assignment * [#2080](https://github.com/pmd/pmd/issues/2080): \[java] StringToString rule false-positive with field access * [#2692](https://github.com/pmd/pmd/issues/2692): \[java] \[doc] AvoidArrayLoops flags copy assignment in same array as sub-optimal * [#3437](https://github.com/pmd/pmd/issues/3437): \[java] StringToString doesn't trigger on Bar.class.getSimpleName().toString() * [#3681](https://github.com/pmd/pmd/issues/3681): \[java] StringToString doesn't trigger on string literals * [#3847](https://github.com/pmd/pmd/issues/3847): \[java] AvoidArrayLoops should consider final variables * [#3977](https://github.com/pmd/pmd/issues/3977): \[java] StringToString false-positive with local method name confusion * [#4091](https://github.com/pmd/pmd/issues/4091): \[java] AvoidArrayLoops false negative with do-while loops * [#4148](https://github.com/pmd/pmd/issues/4148): \[java] UseArrayListInsteadOfVector ignores Vector when other classes are imported * java-errorprone * [#929](https://github.com/pmd/pmd/issues/929): \[java] Inconsistent results with TestClassWithoutTestCases * [#2636](https://github.com/pmd/pmd/issues/2636): \[java] TestClassWithoutTestCases false positive with JUnit5 ParameterizedTest * javascript * [#4165](https://github.com/pmd/pmd/issues/4165): \[javascript] InaccurateNumericLiteral underscore separator notation false positive ### API Changes No changes. ### External Contributions * [#4142](https://github.com/pmd/pmd/pull/4142): \[java] fix #4141 Update UncommentedEmptyConstructor - ignore @Autowired annotations - [Lynn](https://github.com/LynnBroe) (@LynnBroe) * [#4147](https://github.com/pmd/pmd/pull/4147): \[java] Added support for Do-While for AvoidArrayLoops - [Yasar Shaikh](https://github.com/yasarshaikh) (@yasarshaikh) * [#4150](https://github.com/pmd/pmd/pull/4150): \[apex] New rule ApexUnitTestClassShouldHaveRunAs #4149 - [Thomas Prouvot](https://github.com/tprouvot) (@tprouvot) ### Stats * 63 commits * 28 closed tickets & PRs * Days since last release: 28 ## 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](#new-and-noteworthy) * [Lua now supports additionally Luau](#lua-now-supports-additionally-luau) * [Modified rules](#modified-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [CPD CLI](#cpd-cli) * [Financial Contributions](#financial-contributions) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### Lua now supports additionally Luau This release of PMD adds support for [Luau](https://github.com/Roblox/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`](https://pmd.github.io/pmd-6.50.0/pmd_rules_java_bestpractices.html#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`](https://pmd.github.io/pmd-6.50.0/pmd_rules_java_codestyle.html#commentdefaultaccessmodifier) now by default ignores JUnit5 annotated methods. This behavior can be customized using the property `ignoredAnnotations`. ### Fixed Issues * cli * [#4118](https://github.com/pmd/pmd/issues/4118): \[cli] run.sh designer reports "integer expression expected" * core * [#4116](https://github.com/pmd/pmd/pull/4116): \[core] Missing --file arg in TreeExport CLI example * doc * [#4072](https://github.com/pmd/pmd/pull/4072): \[doc] Add architecture decision records * [#4109](https://github.com/pmd/pmd/pull/4109): \[doc] Add page for 3rd party rulesets * [#4124](https://github.com/pmd/pmd/pull/4124): \[doc] Fix typos in Java rule docs * java * [#3431](https://github.com/pmd/pmd/issues/3431): \[java] Add sample java project to regression-tester which uses new language constructs * java-bestpractices * [#4033](https://github.com/pmd/pmd/issues/4033): \[java] UnusedPrivateField - false positive with Lombok @ToString.Include * [#4037](https://github.com/pmd/pmd/issues/4037): \[java] UnusedPrivateField - false positive with Spring @SpyBean * java-codestyle * [#3859](https://github.com/pmd/pmd/issues/3859): \[java] CommentDefaultAccessModifier is triggered in JUnit5 test class * [#4085](https://github.com/pmd/pmd/issues/4085): \[java] UnnecessaryFullyQualifiedName false positive when nested and non-nested classes with the same name and in the same package are used together * [#4133](https://github.com/pmd/pmd/issues/4133): \[java] UnnecessaryFullyQualifiedName - FP for inner class pkg.ClassA.Foo implementing pkg.Foo * java-design * [#4090](https://github.com/pmd/pmd/issues/4090): \[java] FinalFieldCouldBeStatic false positive with non-static synchronized block (regression in 6.48, worked with 6.47) * java-errorprone * [#1718](https://github.com/pmd/pmd/issues/1718): \[java] ConstructorCallsOverridableMethod false positive when calling super method * [#2348](https://github.com/pmd/pmd/issues/2348): \[java] ConstructorCallsOverridableMethod occurs when unused overloaded method is defined * [#4099](https://github.com/pmd/pmd/issues/4099): \[java] ConstructorCallsOverridableMethod should consider method calls with var access * scala * [#4138](https://github.com/pmd/pmd/pull/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: * [Oliver Siegmar](https://github.com/osiegmar) (@osiegmar) ### External Contributions * [#4066](https://github.com/pmd/pmd/pull/4066): \[lua] Add support for Luau syntax and skipping literal sequences in CPD - [Matt Hargett](https://github.com/matthargett) (@matthargett) * [#4100](https://github.com/pmd/pmd/pull/4100): \[java] Update UnusedPrivateFieldRule - ignore any annotations - [Lynn](https://github.com/LynnBroe) (@LynnBroe) * [#4116](https://github.com/pmd/pmd/pull/4116): \[core] Fix missing --file arg in TreeExport CLI example - [mohan-chinnappan-n](https://github.com/mohan-chinnappan-n) (@mohan-chinnappan-n) * [#4124](https://github.com/pmd/pmd/pull/4124): \[doc] Fix typos in Java rule docs - [Piotrek Ε»ygieΕ‚o](https://github.com/pzygielo) (@pzygielo) * [#4128](https://github.com/pmd/pmd/pull/4128): \[java] Fix False-positive UnnecessaryFullyQualifiedName when nested and non-nest… #4103 - [Oleg Andreych](https://github.com/OlegAndreych) (@OlegAndreych) * [#4130](https://github.com/pmd/pmd/pull/4130): \[ci] GitHub Workflows security hardening - [Alex](https://github.com/sashashura) (@sashashura) * [#4131](https://github.com/pmd/pmd/pull/4131): \[doc] TooFewBranchesForASwitchStatement - Use "if-else" instead of "if-then" - [Suvashri](https://github.com/Suvashri) (@Suvashri) * [#4137](https://github.com/pmd/pmd/pull/4137): \[java] Fixes 3859: Exclude junit5 test methods from the commentDefaultAccessModifierRule - [Luis Alcantar](https://github.com/lfalcantar) (@lfalcantar) ### Stats * 100 commits * 26 closed tickets & PRs * Days since last release: 29 ## 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](#new-and-noteworthy) * [Updated PMD Designer](#updated-pmd-designer) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [Deprecated API](#deprecated-api) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### Updated PMD Designer This PMD release ships a new version of the pmd-designer. For the changes, see [PMD Designer Changelog](https://github.com/pmd/pmd-designer/releases/tag/6.49.0). ### Fixed Issues * apex * [#4096](https://github.com/pmd/pmd/issues/4096): \[apex] ApexAssertionsShouldIncludeMessage and ApexUnitTestClassShouldHaveAsserts: support new Assert class (introduced with Apex v56.0) * core * [#3970](https://github.com/pmd/pmd/issues/3970): \[core] FileCollector.addFile ignores language parameter * java-codestyle * [#4082](https://github.com/pmd/pmd/issues/4082): \[java] UnnecessaryImport false positive for on-demand imports of nested classes ### API Changes #### Deprecated API * In order to reduce the dependency on Apex Jorje classes, the following methods have been deprecated. These methods all leaked internal Jorje enums. These enums have been replaced now by enums the PMD's AST package. * ASTAssignmentExpression#getOperator * ASTBinaryExpression#getOperator * ASTBooleanExpression#getOperator * ASTPostfixExpression#getOperator * ASTPrefixExpression#getOperator All these classes have now a new `getOp()` method. Existing code should be refactored to use this method instead. It returns the new enums, like AssignmentOperator, and avoids the dependency to Jorje. ### External Contributions * [#4081](https://github.com/pmd/pmd/pull/4081): \[apex] Remove Jorje leaks outside `ast` package - [@eklimo](https://github.com/eklimo) * [#4083](https://github.com/pmd/pmd/pull/4083): \[java] UnnecessaryImport false positive for on-demand imports of nested classes (fix for #4082) - [@abyss638](https://github.com/abyss638) * [#4092](https://github.com/pmd/pmd/pull/4092): \[apex] Implement ApexQualifiableNode for ASTUserEnum - [@aaronhurst-google](https://github.com/aaronhurst-google) * [#4095](https://github.com/pmd/pmd/pull/4095): \[core] CPD: Added begin and end token to XML reports - [@pacvz](https://github.com/pacvz) * [#4097](https://github.com/pmd/pmd/pull/4097): \[apex] ApexUnitTestClassShouldHaveAssertsRule: Support new Assert class (Apex v56.0) - [@tprouvot](https://github.com/tprouvot) * [#4104](https://github.com/pmd/pmd/pull/4104): \[doc] Add MegaLinter in the list of integrations - [@nvuillam](https://github.com/nvuillam) ### Stats * 49 commits * 10 closed tickets & PRs * Days since last release: 32 ## 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](#new-and-noteworthy) * [Java 19 Support](#java-19-support) * [Gherkin support](#gherkin-support) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [CPD CLI](#cpd-cli) * [Rule Test Framework](#rule-test-framework) * [Deprecated API](#deprecated-api) * [Experimental APIs](#experimental-apis) * [Internal API](#internal-api) * [Financial Contributions](#financial-contributions) * [External Contributions](#external-contributions) * [Stats](#stats) ### 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)](https://openjdk.org/jeps/427) and [JEP 405: Record Patterns (Preview)](https://openjdk.org/jeps/405) 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](https://github.com/ASBrouwers) PMD now has CPD support for the [Gherkin](https://cucumber.io/docs/gherkin/) language. It is used to defined test cases for the [Cucumber](https://cucumber.io/) testing tool for behavior-driven development. Being based on a proper Antlr grammar, CPD can: * ignore comments * honor [comment-based suppressions](pmd_userdocs_cpd.html#suppression) ### Fixed Issues * apex * [#4056](https://github.com/pmd/pmd/pull/4056): \[apex] ApexSOQLInjection: Add support count query * core * [#3796](https://github.com/pmd/pmd/issues/3796): \[core] CPD should also provide a `--debug` flag * [#4021](https://github.com/pmd/pmd/pull/4021): \[core] CPD: Add total number of tokens to XML reports * [#4031](https://github.com/pmd/pmd/issues/4031): \[core] If report is written to stdout, stdout should not be closed * [#4051](https://github.com/pmd/pmd/issues/4051): \[doc] Additional rulesets are not listed in documentation * [#4053](https://github.com/pmd/pmd/pull/4053): \[core] Allow building PMD under Java 18+ * java * [#4015](https://github.com/pmd/pmd/issues/4015): \[java] Support JDK 19 * java-bestpractices * [#3455](https://github.com/pmd/pmd/issues/3455): \[java] WhileLoopWithLiteralBoolean - false negative with complex expressions * java-design * [#3729](https://github.com/pmd/pmd/issues/3729): \[java] TooManyMethods ignores "real" methods which are named like getters or setters * [#3949](https://github.com/pmd/pmd/issues/3949): \[java] FinalFieldCouldBeStatic - false negative with unnecessary parenthesis * java-performance * [#3625](https://github.com/pmd/pmd/issues/3625): \[java] AddEmptyString - false negative with empty var * lua * [#4061](https://github.com/pmd/pmd/pull/4061): \[lua] Fix several related Lua parsing issues found when using CPD * test * [#3302](https://github.com/pmd/pmd/pull/3302): \[test] Improve xml test schema * [#3758](https://github.com/pmd/pmd/issues/3758): \[test] Move pmd-test to java 8 * [#3976](https://github.com/pmd/pmd/pull/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](pmd_userdocs_extending_testing.html) #### 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 * To support the Java preview language features "Pattern Matching for Switch" and "Record Patterns", the following AST nodes have been introduced as experimental: * ASTSwitchGuard * ASTRecordPattern * ASTComponentPatternList #### Internal API Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. You can identify them with the `@InternalApi` annotation. You'll also get a deprecation warning. * CPDConfiguration#setRenderer * CPDConfiguration#setCPDRenderer * CPDConfiguration#getRenderer * CPDConfiguration#getCPDRenderer * CPDConfiguration#getRendererFromString * CPDConfiguration#getCPDRendererFromString * CPDRendererAdapter ### Financial Contributions Many thanks to our sponsors: * [Matt Hargett](https://github.com/matthargett) (@matthargett) ### External Contributions * [#3984](https://github.com/pmd/pmd/pull/3984): \[java] Fix AddEmptyString false-negative issue - [@LiGaOg](https://github.com/LiGaOg) * [#3988](https://github.com/pmd/pmd/pull/3988): \[java] Modify WhileLoopWithLiteralBoolean to meet the missing case #3455 - [@VoidxHoshi](https://github.com/VoidxHoshi) * [#3992](https://github.com/pmd/pmd/pull/3992): \[java] FinalFieldCouldBeStatic - fix false negative with unnecessary parenthesis - [@dalizi007](https://github.com/dalizi007) * [#3994](https://github.com/pmd/pmd/pull/3994): \[java] TooManyMethods - improve getter/setter detection (#3729) - [@341816041](https://github.com/341816041) * [#4017](https://github.com/pmd/pmd/pull/4017): Add Gherkin support to CPD - [@ASBrouwers](https://github.com/ASBrouwers) * [#4021](https://github.com/pmd/pmd/pull/4021): \[core] CPD: Add total number of tokens to XML reports - [@maikelsteneker](https://github.com/maikelsteneker) * [#4056](https://github.com/pmd/pmd/pull/4056): \[apex] ApexSOQLInjection: Add support count query - [@gwilymatgearset](https://github.com/gwilymatgearset) * [#4061](https://github.com/pmd/pmd/pull/4061): \[lua] Fix several related Lua parsing issues found when using CPD - [@matthargett](https://github.com/matthargett) ### Stats * 102 commits * 26 closed tickets & PRs * Days since last release: 35 ## 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](#fixed-issues) * [API Changes](#api-changes) * [External Contributions](#external-contributions) * [Stats](#stats) ### Fixed Issues * core * [#3999](https://github.com/pmd/pmd/issues/3999): \[cli] All files are analyzed despite parameter `--file-list` * [#4009](https://github.com/pmd/pmd/issues/4009): \[core] Cannot build PMD with Temurin 17 * java-bestpractices * [#3824](https://github.com/pmd/pmd/issues/3824): \[java] UnusedPrivateField: Do not flag fields annotated with @Version * [#3825](https://github.com/pmd/pmd/issues/3825): \[java] UnusedPrivateField: Do not flag fields annotated with @Id or @EmbeddedId * java-design * [#3823](https://github.com/pmd/pmd/issues/3823): \[java] ImmutableField: Do not flag fields in @Entity * [#3981](https://github.com/pmd/pmd/issues/3981): \[java] ImmutableField reports fields annotated with @Value (Spring) * [#3998](https://github.com/pmd/pmd/issues/3998): \[java] ImmutableField reports fields annotated with @Captor (Mockito) * [#4004](https://github.com/pmd/pmd/issues/4004): \[java] ImmutableField reports fields annotated with @GwtMock (GwtMockito) and @Spy (Mockito) * [#4008](https://github.com/pmd/pmd/issues/4008): \[java] ImmutableField not reporting fields that are only initialized in the declaration * [#4011](https://github.com/pmd/pmd/issues/4011): \[java] ImmutableField: Do not flag fields annotated with @Inject * [#4020](https://github.com/pmd/pmd/issues/4020): \[java] ImmutableField reports fields annotated with @FindBy and @FindBys (Selenium) * java-errorprone * [#3936](https://github.com/pmd/pmd/issues/3936): \[java] AvoidFieldNameMatchingMethodName should consider enum class * [#3937](https://github.com/pmd/pmd/issues/3937): \[java] AvoidDuplicateLiterals - uncompilable test cases ### API Changes No changes. ### External Contributions * [#3985](https://github.com/pmd/pmd/pull/3985): \[java] Fix false negative problem about Enum in AvoidFieldNameMatchingMethodName #3936 - [@Scrsloota](https://github.com/Scrsloota) * [#3993](https://github.com/pmd/pmd/pull/3993): \[java] AvoidDuplicateLiterals - Add the method "buz" definition to test cases - [@dalizi007](https://github.com/dalizi007) * [#4002](https://github.com/pmd/pmd/pull/4002): \[java] ImmutableField - Ignore fields annotated with @Value (Spring) or @Captor (Mockito) - [@jjlharrison](https://github.com/jjlharrison) * [#4003](https://github.com/pmd/pmd/pull/4003): \[java] UnusedPrivateField - Ignore fields annotated with @Id/@EmbeddedId/@Version (JPA) or @Mock/@Spy/@MockBean (Mockito/Spring) - [@jjlharrison](https://github.com/jjlharrison) * [#4006](https://github.com/pmd/pmd/pull/4006): \[doc] Fix eclipse plugin update site URL - [@shiomiyan](https://github.com/shiomiyan) * [#4010](https://github.com/pmd/pmd/pull/4010): \[core] Bump kotlin to version 1.7.0 - [@maikelsteneker](https://github.com/maikelsteneker) ### Stats * 45 commits * 23 closed tickets & PRs * Days since last release: 27 ## 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](#new-and-noteworthy) * [CLI improvements](#cli-improvements) * [C# Improvements](#c#-improvements) * [New Rules](#new-rules) * [Deprecated Rules](#deprecated-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [Deprecated ruleset references](#deprecated-ruleset-references) * [Deprecated API](#deprecated-api) * [Internal API](#internal-api) * [External Contributions](#external-contributions) * [Stats](#stats) ### 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: ```shell 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 ```shell 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](https://github.com/pmd/pmd/pull/3974) for details. #### New Rules This release ships with 2 new Java rules. * [`EmptyControlStatement`](https://pmd.github.io/pmd-6.46.0/pmd_rules_java_codestyle.html#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. ```xml ``` The rule is part of the quickstart.xml ruleset. * [`UnnecessarySemicolon`](https://pmd.github.io/pmd-6.46.0/pmd_rules_java_codestyle.html#unnecessarysemicolon) reports semicolons that are unnecessary (so called "empty statements" and "empty declarations"). This new rule replaces the rule EmptyStatementNotInLoop. ```xml ``` The rule is part of the quickstart.xml ruleset. #### Deprecated Rules * The following Java rules are deprecated and removed from the quickstart ruleset, as the new rule [`EmptyControlStatement`](https://pmd.github.io/pmd-6.46.0/pmd_rules_java_codestyle.html#emptycontrolstatement) merges their functionality: * [`EmptyFinallyBlock`](https://pmd.github.io/pmd-6.46.0/pmd_rules_java_errorprone.html#emptyfinallyblock) * [`EmptyIfStmt`](https://pmd.github.io/pmd-6.46.0/pmd_rules_java_errorprone.html#emptyifstmt) * [`EmptyInitializer`](https://pmd.github.io/pmd-6.46.0/pmd_rules_java_errorprone.html#emptyinitializer) * [`EmptyStatementBlock`](https://pmd.github.io/pmd-6.46.0/pmd_rules_java_errorprone.html#emptystatementblock) * [`EmptySwitchStatements`](https://pmd.github.io/pmd-6.46.0/pmd_rules_java_errorprone.html#emptyswitchstatements) * [`EmptySynchronizedBlock`](https://pmd.github.io/pmd-6.46.0/pmd_rules_java_errorprone.html#emptysynchronizedblock) * [`EmptyTryBlock`](https://pmd.github.io/pmd-6.46.0/pmd_rules_java_errorprone.html#emptytryblock) * [`EmptyWhileStmt`](https://pmd.github.io/pmd-6.46.0/pmd_rules_java_errorprone.html#emptywhilestmt) * The Java rule [`EmptyStatementNotInLoop`](https://pmd.github.io/pmd-6.46.0/pmd_rules_java_errorprone.html#emptystatementnotinloop) is deprecated and removed from the quickstart ruleset. Use the new rule [`UnnecessarySemicolon`](https://pmd.github.io/pmd-6.46.0/pmd_rules_java_codestyle.html#unnecessarysemicolon) instead. ### Fixed Issues * cli * [#1445](https://github.com/pmd/pmd/issues/1445): \[core] Allow CLI to take globs as parameters * core * [#2352](https://github.com/pmd/pmd/issues/2352): \[core] Deprecate \-\ hyphen notation for ruleset references * [#3787](https://github.com/pmd/pmd/issues/3787): \[core] Internalize some methods in Ant Formatter * [#3835](https://github.com/pmd/pmd/issues/3835): \[core] Deprecate system properties of CPDCommandLineInterface * [#3942](https://github.com/pmd/pmd/issues/3942): \[core] common-io path traversal vulnerability (CVE-2021-29425) * cs (c#) * [#3974](https://github.com/pmd/pmd/pull/3974): \[cs] Add option to ignore C# attributes (annotations) * go * [#2752](https://github.com/pmd/pmd/issues/2752): \[go] Error parsing unicode values * html * [#3955](https://github.com/pmd/pmd/pull/3955): \[html] Improvements for handling text and comment nodes * [#3978](https://github.com/pmd/pmd/pull/3978): \[html] Add additional file extensions htm, xhtml, xht, shtml * java * [#3423](https://github.com/pmd/pmd/issues/3423): \[java] Error processing identifiers with Unicode * java-bestpractices * [#3954](https://github.com/pmd/pmd/issues/3954): \[java] NPE in UseCollectionIsEmptyRule when .size() is called in a record * java-design * [#3874](https://github.com/pmd/pmd/issues/3874): \[java] ImmutableField reports fields annotated with @Autowired (Spring) and @Mock (Mockito) * java-errorprone * [#3096](https://github.com/pmd/pmd/issues/3096): \[java] EmptyStatementNotInLoop FP in 6.30.0 with IfStatement * java-performance * [#3379](https://github.com/pmd/pmd/issues/3379): \[java] UseArraysAsList must ignore primitive arrays * [#3965](https://github.com/pmd/pmd/issues/3965): \[java] UseArraysAsList false positive with non-trivial loops * javascript * [#2605](https://github.com/pmd/pmd/issues/2605): \[js] Support unicode characters * [#3948](https://github.com/pmd/pmd/issues/3948): \[js] Invalid operator error for method property in object literal * python * [#2604](https://github.com/pmd/pmd/issues/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: - `-`, 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. - CPDCommandLineInterface has been internalized. In order to execute CPD either CPD#run or CPD#main should be used. - Several members of BaseCPDCLITest have been deprecated with replacements. - The methods Formatter#start, Formatter#end, Formatter#getRenderer, and Formatter#isNoOutputSupplied have been internalized. ### External Contributions * [#3961](https://github.com/pmd/pmd/pull/3961): \[java] Fix #3954 - NPE in UseCollectionIsEmptyRule with record - [@flyhard](https://github.com/flyhard) * [#3964](https://github.com/pmd/pmd/pull/3964): \[java] Fix #3874 - ImmutableField: fix mockito/spring false positives - [@lukelukes](https://github.com/lukelukes) * [#3974](https://github.com/pmd/pmd/pull/3974): \[cs] Add option to ignore C# attributes (annotations) - [@maikelsteneker](https://github.com/maikelsteneker) ### Stats * 92 commits * 30 closed tickets & PRs * Days since last release: 28 ## 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](#new-and-noteworthy) * [PMD User Survey](#pmd-user-survey) * [Support for HTML](#support-for-html) * [New rules](#new-rules) * [Modified rules](#modified-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [Experimental APIs](#experimental-apis) * [External Contributions](#external-contributions) * [Stats](#stats) ### 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 . 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](https://github.com/pmd/pmd/discussions). Please report missing features or bugs as new [issues](https://github.com/pmd/pmd/issues). #### New rules * The HTML rule [`AvoidInlineStyles`](https://pmd.github.io/pmd-6.45.0/pmd_rules_html_bestpractices.html#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. ```xml ``` * The HTML rule [`UnnecessaryTypeAttribute`](https://pmd.github.io/pmd-6.45.0/pmd_rules_html_bestpractices.html#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. ```xml ``` * The HTML rule [`UseAltAttributeForImages`](https://pmd.github.io/pmd-6.45.0/pmd_rules_html_bestpractices.html#usealtattributeforimages) finds "img" elements without an "alt" attribute. An alternate text should always be provided in order to help screen readers. ```xml ``` #### Modified rules * The Java rule [`UnusedPrivateField`](https://pmd.github.io/pmd-6.45.0/pmd_rules_java_bestpractices.html#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](https://github.com/pmd/pmd/issues/3792): \[core] Allow to filter violations in Report * [#3881](https://github.com/pmd/pmd/issues/3881): \[core] SARIF renderer depends on platform default encoding * [#3882](https://github.com/pmd/pmd/pull/3882): \[core] Fix AssertionError about exhaustive switch * [#3884](https://github.com/pmd/pmd/issues/3884): \[core] XML report via ant task contains XML header twice * [#3896](https://github.com/pmd/pmd/pull/3896): \[core] Fix ast-dump CLI when reading from stdin * doc * [#2505](https://github.com/pmd/pmd/issues/2505): \[doc] Improve side bar to show release date * java * [#3068](https://github.com/pmd/pmd/issues/3068): \[java] Some tests should not depend on real rules * [#3889](https://github.com/pmd/pmd/pull/3889): \[java] Catch LinkageError in UselessOverridingMethodRule * java-bestpractices * [#3910](https://github.com/pmd/pmd/pull/3910): \[java] UnusedPrivateField - Allow the ignored fieldnames to be configurable * [#1185](https://github.com/pmd/pmd/issues/1185): \[java] ArrayIsStoredDirectly false positive with field access * [#1474](https://github.com/pmd/pmd/issues/1474): \[java] ArrayIsStoredDirectly false positive with method call * [#3879](https://github.com/pmd/pmd/issues/3879) \[java] ArrayIsStoredDirectly reports duplicated violation * [#3929](https://github.com/pmd/pmd/issues/3929): \[java] ArrayIsStoredDirectly should report the assignment rather than formal parameter * java-design * [#3603](https://github.com/pmd/pmd/issues/3603): \[java] SimplifiedTernary: no violation for 'condition ? true : false' case * java-performance * [#3867](https://github.com/pmd/pmd/issues/3867): \[java] UseArraysAsList with method call * plsql * [#3687](https://github.com/pmd/pmd/issues/3687): \[plsql] Parsing exception EXECUTE IMMEDIATE l_sql BULK COLLECT INTO statement * [#3706](https://github.com/pmd/pmd/issues/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 * [#3883](https://github.com/pmd/pmd/pull/3883): \[doc] Improve side bar by Adding Release Date - [@jasonqiu98](https://github.com/jasonqiu98) * [#3910](https://github.com/pmd/pmd/pull/3910): \[java] UnusedPrivateField - Allow the ignored fieldnames to be configurable - [@laoseth](https://github.com/laoseth) * [#3928](https://github.com/pmd/pmd/pull/3928): \[plsql] Fix plsql parsing error in parenthesis groups - [@LiGaOg](https://github.com/LiGaOg) * [#3935](https://github.com/pmd/pmd/pull/3935): \[plsql] Fix parser exception in EXECUTE IMMEDIATE BULK COLLECT #3687 - [@Scrsloota](https://github.com/Scrsloota) * [#3938](https://github.com/pmd/pmd/pull/3938): \[java] Modify SimplifiedTernary to meet the missing case #3603 - [@VoidxHoshi](https://github.com/VoidxHoshi) * [#3943](https://github.com/pmd/pmd/pull/3943): chore: Set permissions for GitHub actions - [@naveensrinivasan](https://github.com/naveensrinivasan) ### Stats * 97 commits * 31 closed tickets & PRs * Days since last release: 33 ## 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](#new-and-noteworthy) * [PMD User Survey](#pmd-user-survey) * [Java 18 Support](#java-18-support) * [Better XML XPath support](#better-xml-xpath-support) * [New XPath functions](#new-xpath-functions) * [New programmatic API](#new-programmatic-api) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [Deprecated API](#deprecated-api) * [Experimental APIs](#experimental-apis) * [External Contributions](#external-contributions) * [Stats](#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 . 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 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: ```xml ``` 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](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 class. Programmatic execution of PMD should now be done with a PMDConfiguration and a PmdAnalysis, for instance: ```java 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](https://github.com/pmd/pmd/pull/3817): \[apex] Add designer bindings to display main attributes * apex-performance * [#3773](https://github.com/pmd/pmd/pull/3773): \[apex] EagerlyLoadedDescribeSObjectResult false positives with SObjectField.getDescribe() * core * [#2693](https://github.com/pmd/pmd/issues/2693): \[ci] Add integration tests with real open-source projects * [#3299](https://github.com/pmd/pmd/issues/3299): \[core] Deprecate system properties of PMDCommandLineInterface * java * [#3809](https://github.com/pmd/pmd/issues/3809): \[java] Support JDK 18 * doc * [#2504](https://github.com/pmd/pmd/issues/2504): \[doc] Improve "Edit me on github" button * [#3812](https://github.com/pmd/pmd/issues/3812): \[doc] Documentation website table of contents broken on pages with many subheadings * java-design * [#3850](https://github.com/pmd/pmd/issues/3850): \[java] ImmutableField - false negative when field assigned in constructor conditionally * [#3851](https://github.com/pmd/pmd/issues/3851): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal - false negative when a compilation unit contains two class declarations * xml * [#2766](https://github.com/pmd/pmd/issues/2766): \[xml] XMLNS prefix is not pre-declared in xpath query * [#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 have been newly deprecated, including: - `PMD#EOL`: use `System#lineSeparator()` - `PMD#SUPPRESS_MARKER`: use DEFAULT_SUPPRESS_MARKER - `PMD#processFiles`: use the [new programmatic API](#new-programmatic-api) - `PMD#getApplicableFiles`: is internal * PMDConfiguration#prependClasspath is deprecated in favour of prependAuxClasspath. * PMDConfiguration#setRuleSets and getRuleSets are deprecated. Use instead setRuleSets, addRuleSet, and getRuleSetPaths. * Several members of BaseCLITest have been deprecated with replacements. * Several members of PMDCommandLineInterface have been explicitly deprecated. The whole class however was deprecated long ago already with 6.30.0. It is internal API and should not be used. * In modelica, the rule classes AmbiguousResolutionRule and ConnectUsingNonConnector have been deprecated, since they didn't comply to the usual rule class naming conventions yet. The replacements are in the subpackage `bestpractices`. #### Experimental APIs * Together with the [new programmatic API](#new-programmatic-api) the interface TextFile has been added as *experimental*. It intends to replace DataSource and SourceCode in the long term. This interface will change in PMD 7 to support read/write operations and other things. You don't need to use it in PMD 6, as FileCollector decouples you from this. A file collector is available through PmdAnalysis#files. ### 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 ## 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](#new-and-noteworthy) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [Deprecated API](#deprecated-api) * [Internal API](#internal-api) * [Changed API](#changed-api) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy ### Fixed Issues * core * [#3427](https://github.com/pmd/pmd/issues/3427): \[core] Stop printing CLI usage text when exiting due to invalid parameters * [#3768](https://github.com/pmd/pmd/issues/3768): \[core] SARIF formatter reports multiple locations when it should report multiple results * doc * [#2502](https://github.com/pmd/pmd/issues/2502): \[doc] Add floating table-of-contents (toc) on the right * [#3807](https://github.com/pmd/pmd/pull/3807): \[doc] Document Ant Task parameter `threads` * java * [#3698](https://github.com/pmd/pmd/issues/3697): \[java] Parsing error with try-with-resources and qualified resource * java-bestpractices * [#3605](https://github.com/pmd/pmd/issues/3605): \[java] SwitchStmtsShouldHaveDefault triggered when default case is present * java-codestyle * [#278](https://github.com/pmd/pmd/issues/278): \[java] ConfusingTernary should treat `!= null` as positive condition * java-performance * [#3374](https://github.com/pmd/pmd/issues/3374): \[java] UseStringBufferForStringAppends: Wrong example in documentation * misc * [#3759](https://github.com/pmd/pmd/issues/3759): \[lang-test] Upgrade dokka maven plugin to 1.4.32 * plsql * [#3746](https://github.com/pmd/pmd/issues/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. - RuleSet: methods that serve to apply rules, including `apply`, `start`, `end`, `removeDysfunctionalRules` - AbstractAccumulatingRenderer#renderFileReport is internal API and should not be overridden in own renderers. #### Changed API It is now forbidden to report a violation: - 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 * [#3767](https://github.com/pmd/pmd/pull/3767): \[core] Update GUI.java - [Vyom Yadav](https://github.com/Vyom-Yadav) * [#3804](https://github.com/pmd/pmd/pull/3804): \[doc] Add floating table of contents (issue #2502) - [JerritEic](https://github.com/JerritEic) ### Stats * 49 commits * 22 closed tickets & PRs * Days since last release: 27 ## 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](#new-and-noteworthy) * [Javascript: Rhino updated to latest version 1.7.14](#javascript:-rhino-updated-to-latest-version-1.7.14) * [New rules](#new-rules) * [Modified rules](#modified-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### Javascript: Rhino updated to latest version 1.7.14 [Rhino](https://github.com/mozilla/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`](https://pmd.github.io/pmd-6.42.0/pmd_rules_java_codestyle.html#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. ```xml ``` The rule is part of the quickstart.xml ruleset. #### Modified rules * The Apex rule [`ApexDoc`](https://pmd.github.io/pmd-6.42.0/pmd_rules_apex_documentation.html#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](https://github.com/pmd/pmd/issues/3328): \[core] designer.bat errors when JAVAFX_HOME contains spaces * java * [#3698](https://github.com/pmd/pmd/issues/3698): \[java] Error resolving Symbol Table * java-bestpractices * [#3209](https://github.com/pmd/pmd/issues/3209): \[java] UnusedPrivateMethod false positive with static method and cast expression * [#3468](https://github.com/pmd/pmd/issues/3468): \[java] UnusedPrivateMethod false positive when outer class calls private static method on inner class * java-design * [#3679](https://github.com/pmd/pmd/issues/3679): \[java] Make FinalFieldCouldBeStatic detect constant variable * java-errorprone * [#3644](https://github.com/pmd/pmd/issues/3644): \[java] InvalidLogMessageFormat: false positives with logstash structured logging * [#3686](https://github.com/pmd/pmd/issues/3686): \[java] ReturnEmptyCollectionRatherThanNull - false negative with conditioned returns * [#3701](https://github.com/pmd/pmd/issues/3701): \[java] MissingStaticMethodInNonInstantiatableClass false positive with method inner classes * [#3721](https://github.com/pmd/pmd/issues/3721): \[java] ReturnEmptyCollectionRatherThanNull - false positive with stream and lambda * java-performance * [#3492](https://github.com/pmd/pmd/issues/3492): \[java] UselessStringValueOf: False positive when there is no initial String to append to * [#3639](https://github.com/pmd/pmd/issues/3639): \[java] UseStringBufferLength: false negative with empty string variable * [#3712](https://github.com/pmd/pmd/issues/3712): \[java] InsufficientStringBufferDeclaration false positive with StringBuilder.setLength(0) * javascript * [#3703](https://github.com/pmd/pmd/issues/3703): \[javascript] Error - no Node adapter class registered for XmlPropRef ### API Changes No changes. ### External Contributions * [#3631](https://github.com/pmd/pmd/pull/3631): \[java] Fixed False positive for UselessStringValueOf when there is no initial String to append to - [John Armgardt](https://github.com/johnra2) * [#3683](https://github.com/pmd/pmd/pull/3683): \[java] Fixed 3468 UnusedPrivateMethod false positive when outer class calls private static method on inner class - [John Armgardt](https://github.com/johnra2) * [#3688](https://github.com/pmd/pmd/pull/3688): \[java] Bump log4j to 2.16.0 - [Sergey Nuyanzin](https://github.com/snuyanzin) * [#3693](https://github.com/pmd/pmd/pull/3693): \[apex] ApexDoc: Add reportProperty property - [Steve Babula](https://github.com/babula) * [#3704](https://github.com/pmd/pmd/pull/3704): \[java] Fix for #3686 - Fix ReturnEmptyCollectionRatherThanNull - [Oleksii Dykov](https://github.com/dykov) * [#3713](https://github.com/pmd/pmd/pull/3713): \[java] Enhance UnnecessaryModifier to support records - [Vincent Galloy](https://github.com/vgalloy) * [#3719](https://github.com/pmd/pmd/pull/3719): \[java] Upgrade log4j to 2.17.1 - [Daniel Paul Searles](https://github.com/squaresurf) * [#3720](https://github.com/pmd/pmd/pull/3720): \[java] New rule: FinalParameterInAbstractMethod - [Vincent Galloy](https://github.com/vgalloy) * [#3724](https://github.com/pmd/pmd/pull/3724): \[java] Fix for #3679 - fix FinalFieldCouldBeStatic - [Oleksii Dykov](https://github.com/dykov) * [#3727](https://github.com/pmd/pmd/pull/3727): \[java] #3724 - fix FinalFieldCouldBeStatic: triggers only if the referenced name is static - [Oleksii Dykov](https://github.com/dykov) * [#3742](https://github.com/pmd/pmd/pull/3742): \[java] Fix #3701 - fix MissingStaticMethodInNonInstantiatableClass for method local classes - [Oleksii Dykov](https://github.com/dykov) * [#3744](https://github.com/pmd/pmd/pull/3744): \[core] Updated SaxonXPathRuleQueryTest.java - [Vyom Yadav](https://github.com/Vyom-Yadav) * [#3745](https://github.com/pmd/pmd/pull/3745): \[java] Fix #3712: InsufficientStringBufferDeclaration setLength false positive - [Daniel Gredler](https://github.com/gredler) * [#3747](https://github.com/pmd/pmd/pull/3747): \[visualforce] Updated DataType.java - [Vyom Yadav](https://github.com/Vyom-Yadav) ### Stats * 88 commits * 35 closed tickets & PRs * Days since last release: 62 ## 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](#new-and-noteworthy) * [GitHub Action for PMD](#github-action-for-pmd) * [Last release in 2021](#last-release-in-2021) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [Command Line Interface](#command-line-interface) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### GitHub Action for PMD PMD now has its own official GitHub Action: [GitHub Action for PMD](https://github.com/marketplace/actions/pmd). It can execute PMD with your own ruleset against your project. It creates a [SARIF](https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html) 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 . #### 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](https://github.com/pmd/pmd/issues/2954): Create GitHub Action for PMD * [#3424](https://github.com/pmd/pmd/issues/3424): \[core] Migrate CLI to using GNU-style long options * [#3425](https://github.com/pmd/pmd/issues/3425): \[core] Add a `--version` CLI option * [#3593](https://github.com/pmd/pmd/issues/3593): \[core] Ant task fails with Java17 * [#3635](https://github.com/pmd/pmd/issues/3635): \[ci] Update sample projects for regression tester * java-bestpractices * [#3595](https://github.com/pmd/pmd/issues/3595): \[java] PrimitiveWrapperInstantiation: no violation on 'new Boolean(val)' * [#3613](https://github.com/pmd/pmd/issues/3613): \[java] ArrayIsStoredDirectly doesn't consider nested classes * [#3614](https://github.com/pmd/pmd/issues/3614): \[java] JUnitTestsShouldIncludeAssert doesn't consider nested classes * [#3618](https://github.com/pmd/pmd/issues/3618): \[java] UnusedFormalParameter doesn't consider anonymous classes * [#3630](https://github.com/pmd/pmd/issues/3630): \[java] MethodReturnsInternalArray doesn't consider anonymous classes * java-design * [#3620](https://github.com/pmd/pmd/issues/3620): \[java] SingularField doesn't consider anonymous classes defined in non-private fields * java-errorprone * [#3624](https://github.com/pmd/pmd/issues/3624): \[java] TestClassWithoutTestCases reports wrong classes in a file * java-performance * [#3491](https://github.com/pmd/pmd/issues/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 * [#3600](https://github.com/pmd/pmd/pull/3600): \[core] Implement GNU-style long options and '--version' - [Yang](https://github.com/duanyang25) * [#3612](https://github.com/pmd/pmd/pull/3612): \[java] Created fix for UselessStringValueOf false positive - [John Armgardt](https://github.com/johnra2) * [#3648](https://github.com/pmd/pmd/pull/3648): \[doc] Rename Code Inspector to Codiga - [Julien Delange](https://github.com/juli1) ### Stats * 80 commits * 23 closed tickets & PRs * Days since last release: 28 ## 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](#new-and-noteworthy) * [Updated Apex Support](#updated-apex-support) * [New rules](#new-rules) * [Modified rules](#modified-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [Experimental APIs](#experimental-apis) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### Updated Apex Support * The Apex language support has been bumped to version 54.0 (Spring '22). #### New rules * The new Apex rule [`EagerlyLoadedDescribeSObjectResult`](https://pmd.github.io/pmd-6.41.0-SNAPSHOT/pmd_rules_apex_performance.html#eagerlyloadeddescribesobjectresult) finds `DescribeSObjectResult`s which could have been loaded eagerly via `SObjectType.getDescribe()`. ```xml ``` #### Modified rules * The Apex rule [`ApexUnitTestClassShouldHaveAsserts`](https://pmd.github.io/pmd-6.41.0-SNAPSHOT/pmd_rules_apex_bestpractices.html#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`](https://pmd.github.io/pmd-6.41.0-SNAPSHOT/pmd_rules_apex_documentation.html#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](https://gitlab.com/StevenWCox/sfapexdoc) and also with analogous documentation tools for other languages, e.g., JavaDoc, ESDoc/JSDoc, etc. * The Apex rule [`ApexCRUDViolation`](https://pmd.github.io/pmd-6.41.0-SNAPSHOT/pmd_rules_apex_security.html#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](https://github.com/SCWells72/sirono-common#authorization-utilities). 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: ```xml 3 ``` * The Apex rule [`EmptyStatementBlock`](https://pmd.github.io/pmd-6.41.0-SNAPSHOT/pmd_rules_apex_errorprone.html#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`](https://pmd.github.io/pmd-6.41.0-SNAPSHOT/pmd_rules_apex_errorprone.html#emptycatchblock) has two new properties modeled after the analogous Java rule: The `allowCommentedBlocks` property, when set to `true` (defaults to `false`), ignores empty blocks containing comments, e.g.: ```apex 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: ```apex try { doSomethingThatThrowsAnExpectedException(); System.assert(false, 'Expected to catch an exception.'); } catch (IllegalStateException ignored) { } catch (NumberFormatException expected) { } ``` * The Apex rule [`OneDeclarationPerLine`](https://pmd.github.io/pmd-6.41.0-SNAPSHOT/pmd_rules_apex_codestyle.html#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., ```apex for (Integer i = 0, numIterations = computeNumIterations(); i < numIterations; i++) { } ``` * The Java rule [`ClassNamingConventions`](https://pmd.github.io/pmd-6.41.0-SNAPSHOT/pmd_rules_java_codestyle.html#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: ```xml ``` ### Fixed Issues * apex * [#1089](https://github.com/pmd/pmd/issues/1089): \[apex] ApexUnitTestClassShouldHaveAsserts: Test asserts in other methods not detected * [#1090](https://github.com/pmd/pmd/issues/1090): \[apex] ApexCRUDViolation: checks not detected if done in another method * [#3532](https://github.com/pmd/pmd/issues/3532): \[apex] Promote usage of consistent getDescribe() info * [#3566](https://github.com/pmd/pmd/issues/3566): \[apex] ApexDoc rule should not require "@description" * [#3568](https://github.com/pmd/pmd/issues/3568): \[apex] EmptyStatementBlock: should provide options to ignore empty private constructors and empty virtual methods * [#3569](https://github.com/pmd/pmd/issues/3569): \[apex] EmptyCatchBlock: should provide an option to ignore empty catch blocks in test methods * [#3570](https://github.com/pmd/pmd/issues/3570): \[apex] OneDeclarationPerLine: should provide an option to ignore multiple declarations in a for loop initializer * [#3576](https://github.com/pmd/pmd/issues/3576): \[apex] ApexCRUDViolation should provide an option to specify additional patterns for methods that encapsulate authorization checks * [#3579](https://github.com/pmd/pmd/issues/3579): \[apex] ApexCRUDViolation: false negative with undelete * java-bestpractices * [#3542](https://github.com/pmd/pmd/issues/3542): \[java] MissingOverride: False negative for enum method * java-codestyle * [#1595](https://github.com/pmd/pmd/issues/1595): \[java] Discuss default for utility classes in ClassNamingConventions * [#3563](https://github.com/pmd/pmd/issues/3563): \[java] The ClassNamingConventionsRule false-positive's on the class name "Constants" * java-errorprone * [#3560](https://github.com/pmd/pmd/issues/3560): \[java] InvalidLogMessageFormat: False positive with message and exception in a block inside a lambda * java-performance * [#2364](https://github.com/pmd/pmd/issues/2364): \[java] AddEmptyString false positive in annotation value * java-security * [#3368](https://github.com/pmd/pmd/issues/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`](https://pmd.github.io/pmd-6.41.0-SNAPSHOT/pmd_rules_apex_errorprone.html#emptycatchblock). This information is also available via XPath attribute `@ContainsComment`. ### External Contributions * [#3538](https://github.com/pmd/pmd/pull/3538): \[apex] New rule EagerlyLoadedDescribeSObjectResult - [Jonathan Wiesel](https://github.com/jonathanwiesel) * [#3549](https://github.com/pmd/pmd/pull/3549): \[java] Ignore AddEmptyString rule in annotations - [Stanislav Myachenkov](https://github.com/smyachenkov) * [#3561](https://github.com/pmd/pmd/pull/3561): \[java] InvalidLogMessageFormat: False positive with message and exception in a block inside a lambda - [Nicolas Filotto](https://github.com/essobedo) * [#3565](https://github.com/pmd/pmd/pull/3565): \[doc] Fix resource leak due to Files.walk - [lujiefsi](https://github.com/lujiefsi) * [#3571](https://github.com/pmd/pmd/pull/3571): \[apex] Fix for #1089 - Added new configuration property additionalAssertMethodPattern to ApexUnitTestClassShouldHaveAssertsRule - [Scott Wells](https://github.com/SCWells72) * [#3572](https://github.com/pmd/pmd/pull/3572): \[apex] Fix for #3566 - Added new configuration property reportMissingDescription to ApexDocRule - [Scott Wells](https://github.com/SCWells72) * [#3573](https://github.com/pmd/pmd/pull/3573): \[apex] Fix for #3568 - Added new configuration properties reportEmptyPrivateNoArgConstructor and reportEmptyVirtualMethod to EmptyStatementBlock - [Scott Wells](https://github.com/SCWells72) * [#3574](https://github.com/pmd/pmd/pull/3574): \[apex] Fix for #3569 - Added new configuration properties allowCommentedBlocks and allowExceptionNameRegex to EmptyCatchBlock - [Scott Wells](https://github.com/SCWells72) * [#3575](https://github.com/pmd/pmd/pull/3575): \[apex] Fix for #3570 - Added new configuration property reportInForLoopInitializer to OneDeclarationPerLine - [Scott Wells](https://github.com/SCWells72) * [#3577](https://github.com/pmd/pmd/pull/3577): \[apex] Fix for #3576 - Added new configuration properties \*AuthMethodPattern and \*AuthMethodTypeParamIndex to ApexCRUDViolation rule - [Scott Wells](https://github.com/SCWells72) * [#3578](https://github.com/pmd/pmd/pull/3578): \[apex] ApexCRUDViolation: Documentation changes for #3576 - [Scott Wells](https://github.com/SCWells72) * [#3580](https://github.com/pmd/pmd/pull/3580): \[doc] Release notes updates for the changes in issue #3569 - [Scott Wells](https://github.com/SCWells72) * [#3581](https://github.com/pmd/pmd/pull/3581): \[apex] #3569 - Requested changes for code review feedback - [Scott Wells](https://github.com/SCWells72) ### Stats * 72 commits * 37 closed tickets & PRs * Days since last release: 34 ## 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](#new-and-noteworthy) * [All Contributors](#all-contributors) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### All Contributors PMD follows the [All Contributors](https://allcontributors.org/) specification. Contributions of any kind welcome! See [credits](https://pmd.github.io/latest/pmd_projectdocs_credits.html) for our complete contributors list. ### Fixed Issues * core * [#3499](https://github.com/pmd/pmd/pull/3499): \[core] Fix XPath rulechain with combined node tests * java-errorprone * [#3493](https://github.com/pmd/pmd/pull/3493): \[java] AvoidAccessibilityAlteration: add tests and fix rule * javascript * [#3516](https://github.com/pmd/pmd/pull/3516): \[javascript] NPE while creating rule violation when specifying explicit line numbers * plsql * [#3487](https://github.com/pmd/pmd/issues/3487): \[plsql] Parsing exception OPEN ref_cursor_name FOR statement * [#3515](https://github.com/pmd/pmd/issues/3515): \[plsql] Parsing exception SELECT...INTO on Associative Arrays Types ### API Changes No changes. ### External Contributions * [#3516](https://github.com/pmd/pmd/pull/3516): \[javascript] NPE while creating rule violation when specifying explicit line numbers - [Kevin Guerra](https://github.com/kevingnet) ### Stats * 37 commits * 10 closed tickets & PRs * Days since last release: 27 ## 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](#fixed-issues) * [External Contributions](#external-contributions) * [Stats](#stats) ### Fixed Issues * apex * [#3462](https://github.com/pmd/pmd/issues/3462): \[apex] SOQL performed in a for-each loop doesn't trigger ApexCRUDViolationRule * [#3484](https://github.com/pmd/pmd/issues/3484): \[apex] ApexCRUDViolationRule maintains state across files * core * [#3446](https://github.com/pmd/pmd/issues/3446): \[core] Allow XPath rules to access the current file name * java-bestpractices * [#3403](https://github.com/pmd/pmd/issues/3403): \[java] MethodNamingConventions junit5TestPattern does not detect parameterized tests ### External Contributions * [#3445](https://github.com/pmd/pmd/pull/3445): \[java] Fix #3403 about MethodNamingConventions and JUnit5 parameterized tests - [Cyril Sicard](https://github.com/CyrilSicard) * [#3470](https://github.com/pmd/pmd/pull/3470): \[apex] Fix ApexCRUDViolationRule - add super call - [Josh Feingold](https://github.com/jfeingold35) ### Stats * 32 commits * 8 closed tickets & PRs * Days since last release: 27 ## 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](#new-and-noteworthy) * [Java 17 Support](#java-17-support) * [Updated PMD Designer](#updated-pmd-designer) * [New rules](#new-rules) * [Renamed rules](#renamed-rules) * [Deprecated rules](#deprecated-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [PMD CLI](#pmd-cli) * [Experimental APIs](#experimental-apis) * [Internal API](#internal-api) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### Java 17 Support This release of PMD brings support for Java 17. PMD supports [JEP 409: Sealed Classes](https://openjdk.java.net/jeps/409) which has been promoted to be a standard language feature of Java 17. PMD also supports [JEP 406: Pattern Matching for switch (Preview)](https://openjdk.java.net/jeps/406) 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](https://github.com/pmd/pmd-designer/releases/tag/6.37.0). #### New rules This release ships with 3 new Java rules. * [`PrimitiveWrapperInstantiation`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_bestpractices.html#primitivewrapperinstantiation) reports usages of primitive wrapper constructors. They are deprecated since Java 9 and should not be used. ```xml ``` The rule is part of the quickstart.xml ruleset. * [`SimplifiableTestAssertion`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_bestpractices.html#simplifiabletestassertion) suggests rewriting some test assertions to be more readable. ```xml ``` The rule is part of the quickstart.xml ruleset. * [`ReturnEmptyCollectionRatherThanNull`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_errorprone.html#returnemptycollectionratherthannull) suggests returning empty collections / arrays instead of null. ```xml ``` The rule is part of the quickstart.xml ruleset. #### Renamed rules * The Java rule [`MissingBreakInSwitch`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_errorprone.html#missingbreakinswitch) has been renamed to [`ImplicitSwitchFallThrough`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_errorprone.html#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 * The following Java rules are deprecated and removed from the quickstart ruleset, as the new rule [`SimplifiableTestAssertion`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_bestpractices.html#simplifiabletestassertion) merges their functionality: * [`UseAssertEqualsInsteadOfAssertTrue`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_bestpractices.html#useassertequalsinsteadofasserttrue) * [`UseAssertNullInsteadOfAssertTrue`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_bestpractices.html#useassertnullinsteadofasserttrue) * [`UseAssertSameInsteadOfAssertTrue`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_bestpractices.html#useassertsameinsteadofasserttrue) * [`UseAssertTrueInsteadOfAssertEquals`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_bestpractices.html#useasserttrueinsteadofassertequals) * [`SimplifyBooleanAssertion`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_design.html#simplifybooleanassertion) * The Java rule [`ReturnEmptyArrayRatherThanNull`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_errorprone.html#returnemptyarrayratherthannull) is deprecated and removed from the quickstart ruleset, as the new rule [`ReturnEmptyCollectionRatherThanNull`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_errorprone.html#returnemptycollectionratherthannull) supersedes it. * The following Java rules are deprecated and removed from the quickstart ruleset, as the new rule [`PrimitiveWrapperInstantiation`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_bestpractices.html#primitivewrapperinstantiation) merges their functionality: * [`BooleanInstantiation`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_performance.html#booleaninstantiation) * [`ByteInstantiation`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_performance.html#byteinstantiation) * [`IntegerInstantiation`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_performance.html#integerinstantiation) * [`LongInstantiation`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_performance.html#longinstantiation) * [`ShortInstantiation`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_performance.html#shortinstantiation) * The Java rule [`UnnecessaryWrapperObjectCreation`](https://pmd.github.io/pmd-6.37.0/pmd_rules_java_performance.html#unnecessarywrapperobjectcreation) is deprecated with no planned replacement before PMD 7. In it's current state, the rule is not useful as it finds only contrived cases of creating a primitive wrapper and unboxing it explicitly in the same expression. In PMD 7 this and more cases will be covered by a new rule `UnnecessaryBoxing`. ### Fixed Issues * apex * [#3201](https://github.com/pmd/pmd/issues/3201): \[apex] ApexCRUDViolation doesn't report Database class DMLs, inline no-arg object instantiations and inline list initialization * [#3329](https://github.com/pmd/pmd/issues/3329): \[apex] ApexCRUDViolation doesn't report SOQL for loops * core * [#1603](https://github.com/pmd/pmd/issues/1603): \[core] Language version comparison * [#2133](https://github.com/pmd/pmd/issues/2133): \[xml] Allow to check Salesforce XML Metadata using XPath rules * [#3377](https://github.com/pmd/pmd/issues/3377): \[core] NPE when specifying report file in current directory in PMD CLI * [#3387](https://github.com/pmd/pmd/issues/3387): \[core] CPD should avoid unnecessary copies when running with --skip-lexical-errors * java-bestpractices * [#2908](https://github.com/pmd/pmd/issues/2908): \[java] Merge Junit assertion simplification rules * [#3235](https://github.com/pmd/pmd/issues/3235): \[java] UseTryWithResources false positive when closeable is provided as a method argument or class field * java-errorprone * [#3361](https://github.com/pmd/pmd/issues/3361): \[java] Rename rule MissingBreakInSwitch to ImplicitSwitchFallThrough * [#3382](https://github.com/pmd/pmd/pull/3382): \[java] New rule ReturnEmptyCollectionRatherThanNull * java-performance * [#3420](https://github.com/pmd/pmd/issues/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](pmd_userdocs_cli_reference.html#analyze-other-xml-formats). #### Experimental APIs * The AST types and APIs around Sealed Classes are not experimental anymore: * ASTClassOrInterfaceDeclaration#isSealed, ASTClassOrInterfaceDeclaration#isNonSealed, ASTClassOrInterfaceDeclaration#getPermittedSubclasses * ASTPermitsList #### Internal API Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. You can identify them with the `@InternalApi` annotation. You'll also get a deprecation warning. * The inner class net.sourceforge.pmd.cpd.TokenEntry.State is considered to be internal API. It will probably be moved away with PMD 7. ### External Contributions * [#3367](https://github.com/pmd/pmd/pull/3367): \[apex] Check SOQL CRUD on for loops - [Jonathan Wiesel](https://github.com/jonathanwiesel) * [#3373](https://github.com/pmd/pmd/pull/3373): \[apex] Add ApexCRUDViolation support for database class, inline no-arg object construction DML and inline list initialization DML - [Jonathan Wiesel](https://github.com/jonathanwiesel) * [#3385](https://github.com/pmd/pmd/pull/3385): \[core] CPD: Optimize --skip-lexical-errors option - [Woongsik Choi](https://github.com/woongsikchoi) * [#3388](https://github.com/pmd/pmd/pull/3388): \[doc] Add Code Inspector in the list of tools - [Julien Delange](https://github.com/juli1) * [#3417](https://github.com/pmd/pmd/pull/3417): \[core] Support forcing a specific language from the command-line - [Aidan Harding](https://github.com/aidan-harding) ### Stats * 82 commits * 29 closed tickets & PRs * Days since last release: 35 ## 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](#new-and-noteworthy) * [Improved Incremental Analysis](#improved-incremental-analysis) * [New rules](#new-rules) * [Renamed rules](#renamed-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### Improved Incremental Analysis [Incremental Analysis](https://pmd.github.io/pmd-6.36.0/pmd_userdocs_incremental_analysis.html) 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`](https://pmd.github.io/pmd-6.36.0/pmd_rules_apex_performance.html#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: ```xml ``` * The new Apex rule [`InaccessibleAuraEnabledGetter`](https://pmd.github.io/pmd-6.36.0/pmd_rules_apex_errorprone.html#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: ```xml ``` #### Renamed rules * The Java rule [`BadComparison`](https://pmd.github.io/pmd-6.36.0/pmd_rules_java_errorprone.html#badcomparison) has been renamed to [`ComparisonWithNaN`](https://pmd.github.io/pmd-6.36.0/pmd_rules_java_errorprone.html#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](https://github.com/pmd/pmd/issues/3307): \[apex] Avoid debug statements since it impact performance * [#3321](https://github.com/pmd/pmd/issues/3321): \[apex] New rule to detect inaccessible AuraEnabled getters (summer '21 security update) * [#3332](https://github.com/pmd/pmd/issues/3332): \[apex] CognitiveComplexity - incorrect increment for "else if" * core * [#2637](https://github.com/pmd/pmd/issues/2637): \[cpd] Error Loading stylesheet cpdhtml.xslt * [#3323](https://github.com/pmd/pmd/pull/3323): \[core] Adds fullDescription and tags in SARIF report * java-bestpractices * [#957](https://github.com/pmd/pmd/issues/957): \[java] GuardLogStatement: False positive with compile-time constant arguments * [#3076](https://github.com/pmd/pmd/pull/3076): \[java] UnusedAssignment reports unused variable when used in increment expr * [#3114](https://github.com/pmd/pmd/issues/3114): \[java] UnusedAssignment false positive when reporting unused variables * [#3315](https://github.com/pmd/pmd/issues/3315): \[java] LiteralsFirstInComparisons false positive with two constants * [#3341](https://github.com/pmd/pmd/issues/3341): \[java] JUnitTestsShouldIncludeAssert should support Junit 5 * [#3340](https://github.com/pmd/pmd/issues/3340): \[java] NullPointerException applying rule GuardLogStatement * java-codestyle * [#3317](https://github.com/pmd/pmd/pull/3317): \[java] Update UnnecessaryImport to recognize usage of imported types in javadoc's `@exception` tag * java-errorprone * [#2895](https://github.com/pmd/pmd/issues/2895): \[java] Improve BadComparison and rename to ComparisonWithNaN * [#3284](https://github.com/pmd/pmd/issues/3284): \[java] InvalidLogMessageFormat may examine the value of a different but identically named String variable * [#3304](https://github.com/pmd/pmd/issues/3304): \[java] NPE in MoreThanOneLoggerRule on a java 16 record * [#3305](https://github.com/pmd/pmd/issues/3305): \[java] ConstructorCallsOverridableMethodRule IndexOutOfBoundsException on a java16 record * [#3343](https://github.com/pmd/pmd/pull/3343): \[java] CloneMethodMustImplementCloneable: FN with local classes * java-performance * [#3331](https://github.com/pmd/pmd/issues/3331): \[java] UseArraysAsList false negative with for-each loop * [#3344](https://github.com/pmd/pmd/pull/3344): \[java] InefficientEmptyStringCheck FN with trim.length on method call ### API Changes No changes. ### External Contributions * [#3276](https://github.com/pmd/pmd/pull/3276): \[apex] Update ApexCRUDViolation and OperationWithLimitsInLoop docs - [Jonathan Wiesel](https://github.com/jonathanwiesel) * [#3306](https://github.com/pmd/pmd/pull/3306): \[java] More than one logger rule test null pointer exception - [Arnaud Jeansen](https://github.com/ajeans) * [#3317](https://github.com/pmd/pmd/pull/3317): \[java] Update UnnecessaryImport to recognize usage of imported types in javadoc's `@exception` tag - [Piotrek Ε»ygieΕ‚o](https://github.com/pzygielo) * [#3319](https://github.com/pmd/pmd/pull/3319): \[apex] New AvoidDebugStatements rule to mitigate performance impact - [Jonathan Wiesel](https://github.com/jonathanwiesel) * [#3320](https://github.com/pmd/pmd/pull/3320): \[java] Fix incorrect increment for "else if" branch in Cognitive Complexity docs - [Denis Borovikov](https://github.com/borovikovd) * [#3322](https://github.com/pmd/pmd/pull/3322): \[apex] added rule to detect inaccessible AuraEnabled getters - [Philippe Ozil](https://github.com/pozil) * [#3323](https://github.com/pmd/pmd/pull/3323): \[core] Adds fullDescription and tags in SARIF report - [Clint Chester](https://github.com/Clint-Chester) * [#3339](https://github.com/pmd/pmd/pull/3339): \[java] JUnitTestsShouldIncludeAssert Tweak assertion definition to avoid false positive with modern JUnit5 - [Arnaud Jeansen](https://github.com/ajeans) ### Stats * 81 commits * 36 closed tickets & PRs * Days since last release: 28 ## 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](#new-and-noteworthy) * [Javascript module now requires at least Java 8](#javascript-module-now-requires-at-least-java-8) * [New rules](#new-rules) * [Modified rules](#modified-rules) * [Deprecated rules](#deprecated-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [Deprecated API](#deprecated-api) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### Javascript module now requires at least Java 8 The latest version of [Rhino](https://github.com/mozilla/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. * [`JUnit5TestShouldBePackagePrivate`](https://pmd.github.io/pmd-6.35.0/pmd_rules_java_bestpractices.html#junit5testshouldbepackageprivate) enforces the convention that JUnit 5 tests should have minimal visibility. You can try out this rule like so: ```xml ``` * [`CognitiveComplexity`](https://pmd.github.io/pmd-6.35.0/pmd_rules_java_design.html#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: ```xml ``` * [`MutableStaticState`](https://pmd.github.io/pmd-6.35.0/pmd_rules_java_design.html#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: ```xml ``` #### Modified rules * The Java rule [`CompareObjectsWithEquals`](https://pmd.github.io/pmd-6.35.0/pmd_rules_java_errorprone.html#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`](https://pmd.github.io/pmd-6.35.0/pmd_rules_java_codestyle.html#defaultpackage) has been deprecated in favor of [`CommentDefaultAccessModifier`](https://pmd.github.io/pmd-6.35.0/pmd_rules_java_codestyle.html#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`](https://pmd.github.io/pmd-6.35.0/pmd_rules_java_codestyle.html#avoidprotectedfieldinfinalclass). The rule [`CommentDefaultAccessModifier`](https://pmd.github.io/pmd-6.35.0/pmd_rules_java_codestyle.html#commentdefaultaccessmodifier) should be used instead. It flags the same thing, but has an escape hatch. * The Java rule [`CloneThrowsCloneNotSupportedException`](https://pmd.github.io/pmd-6.35.0/pmd_rules_java_errorprone.html#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](https://github.com/pmd/pmd/issues/3183): \[apex] ApexUnitTestMethodShouldHaveIsTestAnnotation false positive with helper method * [#3243](https://github.com/pmd/pmd/pull/3243): \[apex] Correct findBoundary when traversing AST * core * [#2639](https://github.com/pmd/pmd/issues/2639): \[core] PMD CLI output file is not created if directory or directories in path don't exist * [#3196](https://github.com/pmd/pmd/issues/3196): \[core] Deprecate ThreadSafeReportListener * doc * [#3230](https://github.com/pmd/pmd/issues/3230): \[doc] Remove "Edit me" button for language index pages * dist * [#2466](https://github.com/pmd/pmd/issues/2466): \[dist] Distribution archive doesn't include all batch scripts * java * [#3269](https://github.com/pmd/pmd/pull/3269): \[java] Fix NPE in MethodTypeResolution * java-bestpractices * [#1175](https://github.com/pmd/pmd/issues/1175): \[java] UnusedPrivateMethod FP with Junit 5 @MethodSource * [#2219](https://github.com/pmd/pmd/issues/2219): \[java] Document Reasons to Avoid Reassigning Parameters * [#2737](https://github.com/pmd/pmd/issues/2737): \[java] Fix misleading rule message on rule SwitchStmtsShouldHaveDefault with non-exhaustive enum switch * [#3236](https://github.com/pmd/pmd/issues/3236): \[java] LiteralsFirstInComparisons should consider constant fields (cont'd) * [#3239](https://github.com/pmd/pmd/issues/3239): \[java] PMD could enforce non-public methods for Junit5 / Jupiter test methods * [#3254](https://github.com/pmd/pmd/issues/3254): \[java] AvoidReassigningParameters reports violations on wrong line numbers * java-codestyle * [#2655](https://github.com/pmd/pmd/issues/2655): \[java] UnnecessaryImport false positive for on-demand imports * [#3206](https://github.com/pmd/pmd/issues/3206): \[java] Deprecate rule DefaultPackage * [#3262](https://github.com/pmd/pmd/pull/3262): \[java] FieldDeclarationsShouldBeAtStartOfClass: false negative with anon classes * [#3265](https://github.com/pmd/pmd/pull/3265): \[java] MethodArgumentCouldBeFinal: false negatives with interfaces and inner classes * [#3266](https://github.com/pmd/pmd/pull/3266): \[java] LocalVariableCouldBeFinal: false negatives with interfaces, anon classes * [#3274](https://github.com/pmd/pmd/pull/3274): \[java] OnlyOneReturn: false negative with anonymous class * [#3275](https://github.com/pmd/pmd/pull/3275): \[java] UnnecessaryLocalBeforeReturn: false negatives with lambda and anon class * java-design * [#2780](https://github.com/pmd/pmd/issues/2780): \[java] DataClass example from documentation results in false-negative * [#2987](https://github.com/pmd/pmd/issues/2987): \[java] New Rule: Public and protected static fields must be final * [#2329](https://github.com/pmd/pmd/issues/2329): \[java] Cognitive complexity rule for Java * java-errorprone * [#3110](https://github.com/pmd/pmd/issues/3110): \[java] Enhance CompareObjectsWithEquals with list of exceptions * [#3112](https://github.com/pmd/pmd/issues/3112): \[java] Deprecate rule CloneThrowsCloneNotSupportedException * [#3205](https://github.com/pmd/pmd/issues/3205): \[java] Make CompareObjectWithEquals allow comparing against constants * [#3248](https://github.com/pmd/pmd/issues/3248): \[java] Documentation is wrong for SingletonClassReturningNewInstance rule * [#3249](https://github.com/pmd/pmd/pull/3249): \[java] AvoidFieldNameMatchingTypeName: False negative with interfaces * [#3268](https://github.com/pmd/pmd/pull/3268): \[java] ConstructorCallsOverridableMethod: IndexOutOfBoundsException with annotations * java-performance * [#1438](https://github.com/pmd/pmd/issues/1438): \[java] InsufficientStringBufferDeclaration false positive for initial calculated StringBuilder size * javascript * [#699](https://github.com/pmd/pmd/issues/699): \[javascript] Update Rhino library to 1.7.13 * [#2081](https://github.com/pmd/pmd/issues/2081): \[javascript] Failing with OutOfMemoryError parsing a Javascript file ### API Changes #### Deprecated API * PMD#doPMD is deprecated. Use PMD#runPMD instead. * PMD#run is deprecated. Use PMD#runPMD instead. * ThreadSafeReportListener and the methods to use them in Report (addListener, getListeners, addListeners) are deprecated. This functionality will be replaced by another TBD mechanism in PMD 7. ### External Contributions * [#3272](https://github.com/pmd/pmd/pull/3272): \[apex] correction for ApexUnitTestMethodShouldHaveIsTestAnnotation false positives - [William Brockhus](https://github.com/YodaDaCoda) * [#3246](https://github.com/pmd/pmd/pull/3246): \[java] New Rule: MutableStaticState - [Vsevolod Zholobov](https://github.com/vszholobov) * [#3247](https://github.com/pmd/pmd/pull/3247): \[java] New rule: JUnit5TestShouldBePackagePrivate - [Arnaud Jeansen](https://github.com/ajeans) * [#3293](https://github.com/pmd/pmd/pull/3293): \[java] Cognitive Complexity Metric - [Denis Borovikov](https://github.com/borovikovd) * [pmd.github.io#12](https://github.com/pmd/pmd.github.io/pull/12): Update quickstart.html - [Igor Lyadov](https://github.com/devigo) ### Stats * 143 commits * 53 closed tickets & PRs * Days since last release: 34 ## 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-and-noteworthy) * [New rules](#new-rules) * [Modified rules](#modified-rules) * [Deprecated rules](#deprecated-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### New rules * The new Java rule [`UseStandardCharsets`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_bestpractices.html#usestandardcharsets) finds usages of `Charset.forName`, where `StandardCharsets` can be used instead. This rule is also part of the Quickstart Ruleset (`rulesets/java/quickstart.xml`) for Java. * The new Java rule [`UnnecessaryImport`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_codestyle.html#unnecessaryimport) replaces the rules [`UnusedImports`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_bestpractices.html#unusedimports), [`DuplicateImports`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_codestyle.html#duplicateimports), [`ImportFromSamePackage`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_errorprone.html#importfromsamepackage), and [`DontImportJavaLang`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_codestyle.html#dontimportjavalang). This rule is also part of the Quickstart Ruleset (`rulesets/java/quickstart.xml`) for Java. #### Modified rules * The Apex rule [`ApexCRUDViolation`](https://pmd.github.io/pmd-6.34.0/pmd_rules_apex_security.html#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](pmd_userdocs_suppressing_warnings.html). #### Deprecated rules * java-bestpractices * [`UnusedImports`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_bestpractices.html#unusedimports): use the rule [`UnnecessaryImport`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_codestyle.html#unnecessaryimport) instead * java-codestyle * [`DuplicateImports`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_codestyle.html#duplicateimports): use the rule [`UnnecessaryImport`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_codestyle.html#unnecessaryimport) instead * [`DontImportJavaLang`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_codestyle.html#dontimportjavalang): use the rule [`UnnecessaryImport`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_codestyle.html#unnecessaryimport) instead * java-errorprone * [`ImportFromSamePackage`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_errorprone.html#importfromsamepackage): use the rule [`UnnecessaryImport`](https://pmd.github.io/pmd-6.34.0/pmd_rules_java_codestyle.html#unnecessaryimport) instead ### Fixed Issues * apex-performance * [#3198](https://github.com/pmd/pmd/pull/3198): \[apex] OperationWithLimitsInLoopRule: Support more limit consuming static method invocations * apex-security * [#3202](https://github.com/pmd/pmd/issues/3202): \[apex] ApexCRUDViolationRule fails to report CRUD violation on COUNT() queries * [#3210](https://github.com/pmd/pmd/issues/3210): \[apex] ApexCRUDViolationRule false-negative on non-VF getter * java-bestpractices * [#3190](https://github.com/pmd/pmd/issues/3190): \[java] Use StandardCharsets instead of Charset.forName * [#3224](https://github.com/pmd/pmd/issues/3224): \[java] UnusedAssignment crashes with nested records * java-codestyle * [#3128](https://github.com/pmd/pmd/issues/3128): \[java] New rule UnnecessaryImport, deprecate DuplicateImports, ImportFromSamePackage, UnusedImports * java-errorprone * [#2757](https://github.com/pmd/pmd/issues/2757): \[java] CloseResource: support Lombok's @Cleanup annotation * [#3169](https://github.com/pmd/pmd/issues/3169): \[java] CheckSkipResult: NPE when using pattern bindings ### API Changes No changes. ### External Contributions * [#3193](https://github.com/pmd/pmd/pull/3193): \[java] New rule: UseStandardCharsets - [Andrea Aime](https://github.com/aaime) * [#3198](https://github.com/pmd/pmd/pull/3198): \[apex] OperationWithLimitsInLoopRule: Support more limit consuming static method invocations - [Jonathan Wiesel](https://github.com/jonathanwiesel) * [#3211](https://github.com/pmd/pmd/pull/3211): \[apex] ApexCRUDViolationRule: Do not assume method is VF getter to avoid CRUD checks - [Jonathan Wiesel](https://github.com/jonathanwiesel) * [#3234](https://github.com/pmd/pmd/pull/3234): \[apex] ApexCRUDViolation: COUNT is indeed CRUD checkable since it exposes data (false-negative) - [Jonathan Wiesel](https://github.com/jonathanwiesel) ### Stats * 74 commits * 18 closed tickets & PRs * Days since last release: 27 ## 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](#new-and-noteworthy) * [PLSQL parsing exclusions](#plsql-parsing-exclusions) * [Fixed Issues](#fixed-issues) * [External Contributions](#external-contributions) * [Stats](#stats) ### 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](pmd_languages_plsql.html). ### Fixed Issues * apex-design * [#3142](https://github.com/pmd/pmd/issues/3142): \[apex] ExcessiveClassLength multiple warning on the same class * java * [#3117](https://github.com/pmd/pmd/issues/3117): \[java] Infinite loop when parsing invalid code nested in lambdas * [#3145](https://github.com/pmd/pmd/issues/3145): \[java] Parse exception when using "record" as variable name * java-bestpractices * [#3118](https://github.com/pmd/pmd/issues/3118): \[java] UnusedPrivateMethod false positive when passing in lombok.val as argument * [#3144](https://github.com/pmd/pmd/issues/3144): \[java] GuardLogStatement can have more detailed example * [#3155](https://github.com/pmd/pmd/pull/3155): \[java] GuardLogStatement: False negative with unguarded method call * [#3160](https://github.com/pmd/pmd/issues/3160): \[java] MethodReturnsInternalArray does not consider static final fields and fields initialized with empty array * java-errorprone * [#2977](https://github.com/pmd/pmd/issues/2977): \[java] CloseResource: false positive with reassignment detection * [#3146](https://github.com/pmd/pmd/issues/3146): \[java] InvalidLogMessageFormat detection failing when String.format used * [#3148](https://github.com/pmd/pmd/issues/3148): \[java] CloseResource false positive with Objects.nonNull * [#3165](https://github.com/pmd/pmd/issues/3165): \[java] InvalidLogMessageFormat detection failing when String.format used in a variable * java-performance * [#2427](https://github.com/pmd/pmd/issues/2427): \[java] ConsecutiveLiteralAppend false-positive with builder inside lambda * [#3152](https://github.com/pmd/pmd/issues/3152): \[java] ConsecutiveLiteralAppends and InsufficientStringBufferDeclaration: FP with switch expressions * plsql * [#195](https://github.com/pmd/pmd/issues/195): \[plsql] Ampersand '&' causes PMD processing error in sql file - Lexical error in file ### External Contributions * [#3161](https://github.com/pmd/pmd/pull/3161): \[plsql] Add support for lexical parameters in SQL*Plus scripts, allow excluding lines which the parser does not understand - [Henning von Bargen](https://github.com/hvbtup) * [#3167](https://github.com/pmd/pmd/pull/3167): \[java] Minor typo in quickstart ruleset - [Austin Tice](https://github.com/AustinTice) ### Stats * 49 commits * 27 closed tickets & PRs * Days since last release: 28 ## 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](#new-and-noteworthy) * [Java 16 Support](#java-16-support) * [Modified Rules](#modified-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [Experimental APIs](#experimental-apis) * [Internal API](#internal-api) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### Java 16 Support This release of PMD brings support for Java 16. PMD supports [JEP 394: Pattern Matching for instanceof](https://openjdk.java.net/jeps/394) and [JEP 395: Records](https://openjdk.java.net/jeps/395). Both have been promoted to be a standard language feature of Java 16. PMD also supports [JEP 397: Sealed Classes (Second Preview)](https://openjdk.java.net/jeps/397) 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`](https://pmd.github.io/pmd-6.32.0/pmd_rules_apex_documentation.html#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](https://github.com/pmd/pmd/issues/3075): \[apex] ApexDoc should support private access modifier * java * [#3101](https://github.com/pmd/pmd/issues/3101): \[java] NullPointerException when running PMD under JRE 11 * java-bestpractices * [#3132](https://github.com/pmd/pmd/issues/3132): \[java] UnusedImports with static imports on subclasses * java-errorprone * [#2716](https://github.com/pmd/pmd/issues/2716): \[java] CompareObjectsWithEqualsRule: False positive with Enums * [#3089](https://github.com/pmd/pmd/issues/3089): \[java] CloseResource rule throws exception on spaces in property types * [#3133](https://github.com/pmd/pmd/issues/3133): \[java] InvalidLogMessageFormat FP with StringFormattedMessage and ParameterizedMessage * plsql * [#3106](https://github.com/pmd/pmd/issues/3106): \[plsql] ParseException while parsing EXECUTE IMMEDIATE 'drop database link ' \|\| linkname; ### API Changes #### Experimental APIs * The experimental class `ASTTypeTestPattern` has been renamed to ASTTypePattern in order to align the naming to the JLS. * The experimental class `ASTRecordConstructorDeclaration` has been renamed to ASTCompactConstructorDeclaration in order to align the naming to the JLS. * The AST types and APIs around Pattern Matching and Records are not experimental anymore: * ASTVariableDeclaratorId#isPatternBinding * ASTPattern * ASTTypePattern * ASTRecordDeclaration * ASTRecordComponentList * ASTRecordComponent * ASTRecordBody * ASTCompactConstructorDeclaration #### Internal API Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0. You can identify them with the `@InternalApi` annotation. You'll also get a deprecation warning. * 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 * [#3098](https://github.com/pmd/pmd/pull/3098): \[apex] ApexDoc optionally report private and protected - [Jonathan Wiesel](https://github.com/jonathanwiesel) * [#3107](https://github.com/pmd/pmd/pull/3107): \[plsql] Fix ParseException for EXECUTE IMMEDIATE str1\|\|str2; - [hvbtup](https://github.com/hvbtup) * [#3125](https://github.com/pmd/pmd/pull/3125): \[doc] Fix sample code indentation in documentation - [Artur Dryomov](https://github.com/arturdryomov) ### Stats * 43 commits * 21 closed tickets & PRs * Days since last release: 27 ## 30-January-2021 - 6.31.0 The PMD team is pleased to announce PMD 6.31.0. This is a minor release. ### Table Of Contents * [New and noteworthy](#new-and-noteworthy) * [SARIF Format](#sarif-format) * [CPD](#cpd) * [New Rules](#new-rules) * [Deprecated rules](#deprecated-rules) * [Fixed Issues](#fixed-issues) * [API Changes](#api-changes) * [Deprecated API](#deprecated-api) * [Experimental APIs](#experimental-apis) * [External Contributions](#external-contributions) * [Stats](#stats) ### New and noteworthy #### SARIF Format PMD now supports the [Static Analysis Results Interchange Format (SARIF)](https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=sarif) as an additional report format. Just use the [command line parameter](pmd_userdocs_cli_reference.html#format) `-format sarif` to select it. SARIF is an OASIS standard format for static analysis tools. PMD creates SARIF JSON files in [SARIF version 2.1.0](https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html). An example report can be found in the documentation in [Report formats for PMD](pmd_userdocs_report_formats.html#sarif). #### CPD * The C++ module now supports the new option [`--ignore-literal-sequences`](https://pmd.github.io/latest/pmd_userdocs_cpd.html#-ignore-literal-sequences), which can be used to avoid detection of some uninteresting clones. This options has been introduced with PMD 6.30.0 for C# and is now available for C++ as well. See [#2963](https://github.com/pmd/pmd/pull/2963). #### New Rules * The new Apex rule [`OverrideBothEqualsAndHashcode`](https://pmd.github.io/pmd-6.31.0/pmd_rules_apex_errorprone.html#overridebothequalsandhashcode) brings the well known Java rule to Apex. In Apex the same principle applies: `equals` and `hashCode` should always be overridden together to ensure collection classes such as Maps and Sets work as expected. * The new Visualforce rule [`VfHtmlStyleTagXss`](https://pmd.github.io/pmd-6.31.0/pmd_rules_vf_security.html#vfhtmlstyletagxss) checks for potential XSS problems when using `