Compare commits

...
Author SHA1 Message Date
Andreas Dangel 4f766035a4 [java] Fix #5263 - UnnecessaryFullyQualifiedName FP with forward references (#5353)
Merge pull request #5353 from oowekyala:issue5263-ufqn-forward-ref
2024-11-22 09:48:25 +01:00
Andreas Dangel 9da17877ac [doc] Update release notes (#5263, #5353) 2024-11-22 09:47:53 +01:00
Andreas Dangel 3e9e128aa7 [java] UnnecessaryFullyQualifiedName - improve test case 2024-11-22 09:46:35 +01:00
Clément Fournier 918684c154 Fix static methods being whitelisted 2024-11-21 16:51:24 +01:00
Clément Fournier e63edf358e [java] Fix #5263 - UnnecessaryFullyQualifiedName FP with forward reference. 2024-11-21 15:26:54 +01:00
Clément Fournier 0d11f151bd [java] Add more details to parse failures in signatures 2024-11-21 14:55:51 +01:00
Juan Martín Sotuyo Dodero 28b4139cd4 Bump rouge from 4.5.0 to 4.5.1 in the all-gems group across 1 directory (#5348) 2024-11-18 15:44:10 -03:00
Juan Martín Sotuyo Dodero d61f691559 Bump org.apache.commons:commons-lang3 from 3.14.0 to 3.17.0 (#5350) 2024-11-18 15:43:55 -03:00
Clément Fournier 12f7f98803 Fix junit 5 warning
return type of factory method must be a collection
or array or stream
2024-11-18 11:43:51 +01:00
dependabot[bot] 2e4f16d516 Bump org.apache.commons:commons-lang3 from 3.14.0 to 3.17.0
Bumps org.apache.commons:commons-lang3 from 3.14.0 to 3.17.0.

---
updated-dependencies:
- dependency-name: org.apache.commons:commons-lang3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-18 04:05:13 +00:00
dependabot[bot] 46ef55c9a9 Bump rouge from 4.5.0 to 4.5.1 in the all-gems group across 1 directory
Bumps the all-gems group with 1 update in the / directory: [rouge](https://github.com/rouge-ruby/rouge).


Updates `rouge` from 4.5.0 to 4.5.1
- [Release notes](https://github.com/rouge-ruby/rouge/releases)
- [Changelog](https://github.com/rouge-ruby/rouge/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rouge-ruby/rouge/compare/v4.5.0...v4.5.1)

---
updated-dependencies:
- dependency-name: rouge
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: all-gems
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-18 03:46:56 +00:00
Andreas Dangel 79c0ce0415 [julia] Ignore generated code in Julia module (#5342)
Merge pull request #5342 from Monits:fix-generated-code-julia
2024-11-17 16:16:51 +01:00
Andreas Dangel 8fdfd369b0 [doc] Update release notes (#5342) 2024-11-17 16:15:55 +01:00
Andreas Dangel 80b8bc47df [gherkin] Remove generated gherkin code from coverage report (#5336)
Merge pull request #5336 from Monits:fix-generated-code-gherkin
2024-11-17 16:13:13 +01:00
Andreas Dangel a9b6c946b4 [doc] Update release notes (#5336) 2024-11-17 16:12:46 +01:00
Andreas Dangel 2910ab0403 [kotlin] Prevent auxiliary grammars from generating lexers (#5335)
Merge pull request #5335 from Monits:fix-generated-code-kotlin
2024-11-17 15:58:54 +01:00
Andreas Dangel 5a0220da2e [doc] Update release notes (#5335) 2024-11-17 15:58:05 +01:00
Andreas Dangel bc4a49deac [doc] Update docs/pages/pmd/projectdocs/credits.md [skip ci] 2024-11-17 15:49:32 +01:00
Andreas Dangel a40c30c8c1 [apex] New Rule: Queueable Should Attach Finalizer (#5303)
Merge pull request #5303 from mitchspano:Require_Finalizer
2024-11-17 15:46:05 +01:00
Andreas Dangel 44c15aae6d [doc] Update release notes (#5303, #5302) 2024-11-17 15:30:59 +01:00
Andreas Dangel 85aeebbab0 Merge branch 'main' into pr-5303 2024-11-17 15:25:24 +01:00
Andreas Dangel a5925eb5ea [doc] Fix typo in release notes 2024-11-17 15:24:49 +01:00
mitchspano c456396931 Reset credits.md to pmd main HEAD. 2024-11-15 22:14:20 +00:00
mitchspano 1ee0f53608 Update @mitchspano as a contributor 2024-11-15 22:07:44 +00:00
Juan Martín Sotuyo Dodero e60f460e02 Merge branch 'pr-5340' 2024-11-15 18:40:37 -03:00
Juan Martín Sotuyo Dodero ee1ab976bc update changelog, refs #5097 2024-11-15 18:39:39 -03:00
Juan Martín Sotuyo Dodero 15cab177d2 Remove added test 2024-11-15 18:30:03 -03:00
Juan Martín Sotuyo Dodero b6f45ed618 Ensure types don't match 2024-11-15 17:55:07 -03:00
Juan Martín Sotuyo Dodero 1ceae38880 [java] TooFewBranchesForSwitch - allow list of case constants (#5289) 2024-11-15 13:48:50 -06:00
Juan Martín Sotuyo Dodero f7de8d3e7e Merge branch 'pr-5331' 2024-11-15 16:47:09 -03:00
Juan Martín Sotuyo Dodero 59864a7c6c Merge branch 'pr-5341' 2024-11-15 16:15:19 -03:00
Juan Martín Sotuyo Dodero a6746fcffa Update changelog, refs #5083 2024-11-15 16:14:53 -03:00
Juan Martín Sotuyo Dodero aad8e93a2f Add test case ensuring we don't incur in FNs 2024-11-15 16:13:44 -03:00
Juan Martín Sotuyo Dodero 3bb943e0e5 Add deprecated code for backwards compatibility 2024-11-15 16:01:45 -03:00
Juan Martín Sotuyo Dodero 3356dd949d Ignore generated code in Julia module 2024-11-15 15:42:35 -03:00
Clément Fournier b264fa14e1 Fix #5083 - mref without target type but with exact method
has compile time decl
2024-11-15 16:36:52 +01:00
Clément Fournier c1aa4e0381 Merge branch 'main' into typeres-problem-with-unchecked-conversion 2024-11-15 16:18:22 +01:00
Clément Fournier a72ac5845b Add test for #5113 2024-11-15 16:16:08 +01:00
Juan Martín Sotuyo Dodero 4e1f4be009 Merge branch 'main' into issue-5287 2024-11-15 08:51:52 -06:00
Juan Martín Sotuyo Dodero c73e5cb8b1 [html] Test for a closing tag when determining node positions (#5328) 2024-11-15 08:50:53 -06:00
Clément Fournier 5931b6601c [java] Fix #5097 - problem with unchecked conversion 2024-11-15 15:27:55 +01:00
Juan Martín Sotuyo Dodero 9d15c900db Pass linters in generated code 2024-11-15 11:27:07 -03:00
mitchspano 69a24126f7 Fix formatting and static code analysis findings. 2024-11-14 23:29:44 +00:00
Juan Martín Sotuyo Dodero ef3a4cc15e Remove generated gherkin code from coverage report
- Take the chance to remove / deprecate autogenerated classes that are
   not needed and were not used.
2024-11-14 18:10:59 -03:00
Juan Martín Sotuyo Dodero 4ef8fb21a9 Merge branch 'main' into issue-5322 2024-11-14 14:38:45 -06:00
Juan Martín Sotuyo Dodero f803aa36dc [java] InsufficientStringBufferDeclaration: Fix CCE for Character (#5332) 2024-11-14 13:57:49 -06:00
Juan Martín Sotuyo Dodero 0cf8f2c18b Suppress style warnings on generated file 2024-11-14 16:55:55 -03:00
Juan Martín Sotuyo Dodero 178f9541e2 Add since to deprecation notice 2024-11-14 16:51:04 -03:00
Juan Martín Sotuyo Dodero 79026f98c9 Add licence header 2024-11-14 16:49:45 -03:00
Juan Martín Sotuyo Dodero 0e0f347f51 Rename parser before annotating to ensure files are found 2024-11-14 16:47:20 -03:00
Juan Martín Sotuyo Dodero 0d606a7122 Prevent auxiliary grammars from generating lexers
- A misconfiguration of Antlr4 produced an auxiliary gramma
   (UnicodeClasses), that was imported into the main kotlin grammar,
   to produce it's own Lexer, which was never used.
 - We no longer produce that Lexer, properly moving imports to the
   standard directory for that.
 - We manually copy a generated version for API compatibility, flagging
   it as both Generated and Deprecated for removal in PMD 8
2024-11-14 16:39:09 -03:00
Andreas Dangel d60b234a47 Merge branch 'main' into issue-5314 2024-11-14 19:47:41 +01:00
Andreas Dangel b050ce353e [java] Propagate unknown type better when mref is unresolved (#5330)
Merge pull request #5330 from oowekyala:typeres-fix-inference-issue-mref
2024-11-14 19:18:43 +01:00
Andreas Dangel 32f55e22e3 [doc] Update release notes (#5329, #5330) 2024-11-14 19:18:11 +01:00
Andreas Dangel 206ed8bbd3 [apex] Use case-insensitive input stream to avoid choking on Unicode escape sequences (#5284)
Merge pull request #5284 from wahajenius:main
2024-11-14 18:23:26 +01:00
Andreas Dangel e1d4f27e19 Add @wahajenius as a contributor 2024-11-14 18:18:06 +01:00
Andreas Dangel 093683bc59 [doc] Update release notes (#5284, #5333) 2024-11-14 18:17:49 +01:00
Andreas Dangel 509452577d [apex] Add test case for #5333 2024-11-14 18:16:06 +01:00
Andreas Dangel 991bc2c41d [apex] Report LexException when extracting comments 2024-11-14 18:12:13 +01:00
Andreas Dangel 8c58a0b3f5 Merge branch 'main' into pr-5284 2024-11-14 18:01:56 +01:00
Andreas Dangel 01b8ca765b Add @chenguangqi as a contributor 2024-11-14 17:48:26 +01:00
Andreas Dangel 3fdbf7d6cb [java] InsufficientStringBufferDeclaration: Fix CCE for Character
Fixes #5314
2024-11-14 17:48:08 +01:00
Andreas Dangel bb729e02f4 Add @VitaliiIevtushenko as a contributor 2024-11-14 17:39:32 +01:00
Clément Fournier bf388d7fd0 Propagate unknown type better when mref is unresolved 2024-11-14 17:39:31 +01:00
Andreas Dangel 61eb116833 [java] PreserveStackTrace - consider instance type patterns
Fixes #5318
2024-11-14 17:39:07 +01:00
Andreas Dangel 634a525286 [html] Test for a closing tag when determining node positions
Fixes #5322
2024-11-14 17:07:37 +01:00
Clément Fournier 2df68ed168 Disable type inf logging by default 2024-11-14 16:32:09 +01:00
Clément Fournier 04dfb782f0 Merge branch 'typeres-fix-inference-issue' 2024-11-14 16:14:50 +01:00
Clément Fournier a79d3e6557 Add unit tests 2024-11-14 16:13:30 +01:00
Andreas Dangel bb2782241e [java] Fix inference dependency issue with nested lambdas (#5325)
Merge pull request #5325 from oowekyala:typeres-fix-inference-issue
2024-11-14 15:51:08 +01:00
Andreas Dangel 2340168421 [doc] Update release notes (#5324) 2024-11-14 15:50:35 +01:00
Andreas Dangel e5a1236981 Update pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedPrivateMethod.xml 2024-11-14 15:48:47 +01:00
dependabot[bot] ed5e862aa3 Bump rouge from 4.4.0 to 4.5.0 in the all-gems group across 1 directory (#5316)
Bumps the all-gems group with 1 update in the / directory: [rouge](https://github.com/rouge-ruby/rouge).


Updates `rouge` from 4.4.0 to 4.5.0
- [Release notes](https://github.com/rouge-ruby/rouge/releases)
- [Changelog](https://github.com/rouge-ruby/rouge/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rouge-ruby/rouge/compare/v4.4.0...v4.5.0)

---
updated-dependencies:
- dependency-name: rouge
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: all-gems
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-14 15:14:44 +01:00
Clément Fournier 529693c916 [java] fix inference dependency issue
Reported in #5324

I improved the verbose logging output a bit so
some of the changes are not directly relevant.
2024-11-13 22:39:34 +01:00
mitchspano 1a9e721fb6 Implements the RuleChain within the QueueableWithoutFinalizerRule.
Implements the [`RuleChain`](https://docs.pmd-code.org/latest/pmd_userdocs_extending_writing_java_rules.html#economic-traversal-the-rulechain) to traverse all classes within the file.
2024-11-12 21:59:02 +00:00
mitchspano 4e4ca6bb70 Incorporate code review feedback.
- Renames the rule to `QueueableWithoutFinalizer` to be more neutral.
- Provides a more robust description.
- Provides a more succinct error message.
- Provides a positive sample for the documentation .
2024-11-12 19:46:58 +00:00
Juan Martín Sotuyo Dodero 3659a2cb7d Bump org.apache.commons:commons-compress from 1.26.0 to 1.27.1 (#5317) 2024-11-10 22:55:15 -06:00
dependabot[bot] 07de5559bc Bump org.apache.commons:commons-compress from 1.26.0 to 1.27.1
Bumps org.apache.commons:commons-compress from 1.26.0 to 1.27.1.

---
updated-dependencies:
- dependency-name: org.apache.commons:commons-compress
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-11 03:35:46 +00:00
Andreas Dangel b05b8240a7 Merge branch 'main' into issue-5287 2024-11-07 19:51:00 +01:00
Andreas Dangel ee7d6fed3e [java] TooFewBranchesForSwitch - add test case from comment on #5311 2024-11-07 19:50:29 +01:00
Juan Martín Sotuyo Dodero fe88498ee8 [java] Fix #5293: Parse number of type parameters eagerly (#5309) 2024-11-07 06:19:16 -06:00
Juan Martín Sotuyo Dodero 944e1e8f7a Bump maven-pmd-plugin from 3.24.0 to 3.26.0 (#5312) 2024-11-07 06:17:30 -06:00
Andreas Dangel ca208d2241 Bump maven-pmd-plugin from 3.24.0 to 3.26.0 2024-11-07 12:40:18 +01:00
Andreas Dangel 9dcb697f13 Improve DeadlockTest 2024-11-07 12:38:11 +01:00
Andreas Dangel 733ac4bba0 [doc] Update release notes (#5293) 2024-11-04 11:23:49 +01:00
Andreas Dangel 1ee6494429 [java] Fix #5293: Parse number of type parameters eagerly
When creating a LazyClassSignature or LazyMethodType, make sure
to parse the number of type parameters eagerly, so that AstDisambiguationPass
can get this number without triggering additional parsing.
2024-11-04 11:23:49 +01:00
Andreas Dangel a1996554d8 [java] Add DeadlockTest for verifying #5293
- Improve logging for Parselock

Refs #5293
2024-11-04 11:23:48 +01:00
dependabot[bot] e15c05721e Bump webrick from 1.8.2 to 1.9.0 in /docs in the all-gems group across 1 directory (#5308)
Bump webrick in /docs in the all-gems group across 1 directory

Bumps the all-gems group with 1 update in the /docs directory: [webrick](https://github.com/ruby/webrick).


Updates `webrick` from 1.8.2 to 1.9.0
- [Release notes](https://github.com/ruby/webrick/releases)
- [Commits](https://github.com/ruby/webrick/compare/v1.8.2...v1.9.0)

---
updated-dependencies:
- dependency-name: webrick
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-gems
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-04 09:23:58 +01:00
Juan Martín Sotuyo Dodero f0daed5874 Bump org.apache.maven.plugins:maven-clean-plugin from 3.3.2 to 3.4.0 (#5307) 2024-11-03 21:54:00 -06:00
dependabot[bot] 36dfcf8211 Bump org.apache.maven.plugins:maven-clean-plugin from 3.3.2 to 3.4.0
Bumps [org.apache.maven.plugins:maven-clean-plugin](https://github.com/apache/maven-clean-plugin) from 3.3.2 to 3.4.0.
- [Release notes](https://github.com/apache/maven-clean-plugin/releases)
- [Commits](https://github.com/apache/maven-clean-plugin/compare/maven-clean-plugin-3.3.2...maven-clean-plugin-3.4.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-clean-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-04 03:08:41 +00:00
mitchspano 83d8ca0169 Fix bestPractices.xml formatting and priority definition. 2024-11-01 21:59:13 +00:00
mitchspano be3c34fe1a Add priority definition. 2024-11-01 21:29:30 +00:00
mitchspano 52fb6c814b Queueable Should Attach Finalizer 2024-11-01 21:17:53 +00:00
mitchspano 93929deef6 Update @mitchspano as a contributor 2024-11-01 17:09:51 +00:00
Andreas Dangel 3ed370f61d Bump gems and bundler (#5301)
- Bump bundler from 2.5.3 to 2.5.22
- Bump activesupport from 7.2.1 to 7.2.2
- Bump execjs from 2.9.1 to 2.10.0
- Bump faraday from 2.11.0 to 2.12.0
- Bump i18n from 1.14.5 to 1.14.6
- Bump json from 2.7.2 to 2.7.5
- Bump logger from 1.6.0 to 1.6.1
- Bump rexml from 3.3.6/3.3.8 to 3.3.9
- Bump rufus-scheduler from 3.9.2 to 3.9.2

- Fixes https://github.com/pmd/pmd/security/dependabot/69
- Fixes https://github.com/pmd/pmd/security/dependabot/70
2024-10-31 15:07:25 +01:00
Andreas Dangel 5eaefd2841 [doc] Update release notes (#1860) 2024-10-31 15:06:32 +01:00
Andreas Dangel a709be1dcb [xml] Have pmd-xml Lexer in line with other antlr grammars (#5296)
Merge pull request #5296 from Monits:align-xml-antlr
2024-10-31 12:27:11 +01:00
Andreas Dangel c079d8c544 [doc] Update release notes (#5296) 2024-10-31 12:25:59 +01:00
Andreas Dangel 7bfa581511 Merge branch 'main' into pr-5296 2024-10-31 12:17:57 +01:00
Andreas Dangel 6ae7404941 [xml] XMLLexer - Update deprecation notice 2024-10-31 12:17:27 +01:00
Juan Martín Sotuyo Dodero 94095df872 Fix style issues 2024-10-29 17:21:24 -03:00
Juan Martín Sotuyo Dodero 7119424d96 Add license header 2024-10-29 16:56:30 -03:00
Juan Martín Sotuyo Dodero 69a92de52d Have pmd-xml Lexer in line with other antlr grammars
- The package is no longer antlr4, but ast, as is in all other modules
 - We keep a deprecated proxy for backwards compatibility
 - We annotate the generated classes as such to ignore them from
   coverage reports
2024-10-28 22:10:21 -03:00
Juan Martín Sotuyo Dodero 73dbc7a67f Bump org.apache.maven.plugins:maven-assembly-plugin from 3.6.0 to 3.7.1 (#5290) 2024-10-28 14:06:52 -03:00
dependabot[bot] c81cd1d520 Bump org.apache.maven.plugins:maven-assembly-plugin from 3.6.0 to 3.7.1
Bumps [org.apache.maven.plugins:maven-assembly-plugin](https://github.com/apache/maven-assembly-plugin) from 3.6.0 to 3.7.1.
- [Release notes](https://github.com/apache/maven-assembly-plugin/releases)
- [Commits](https://github.com/apache/maven-assembly-plugin/compare/maven-assembly-plugin-3.6.0...maven-assembly-plugin-3.7.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-assembly-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-28 03:31:36 +00:00
Juan Martín Sotuyo Dodero 4473aa6667 [ant] Formatter: avoid reflective access to determine console encoding (#5286) 2024-10-27 15:40:04 -03:00
Juan Martín Sotuyo Dodero 97d68e331c Bump asm from 9.7 to 9.7.1 (#5288) 2024-10-27 12:38:42 -03:00
Andreas Dangel 16eafc89c2 [java] TooFewBranchesForSwitch - allow list of case constants
Fixes #5287
2024-10-27 16:24:05 +01:00
Andreas Dangel d68d6c57ef Bump asm from 9.7 to 9.7.1
This enables support for Java 24
Refs #5154
2024-10-27 15:53:00 +01:00
Andreas Dangel 9c098b2531 Bump pmd from 7.5.0 to 7.7.0 (#5285)
* Bump pmd from 7.5.0 to 7.7.0

* Bump build-tools from 27 to 28-SNAPSHOT

Needed to remove deprecation warnings
about old rule names
2024-10-27 15:20:28 +01:00
Andreas Dangel 3f697aff35 [ant] Formatter: avoid reflective access to determine console encoding
- for java 17+, there is public API to get the console encoding
  -> no problem
- for older java versions, try to use system property
  sun.jnu.encoding if it exists
- only then use the fall-backs with illegal reflective access
  to private fields/methods on java.io.Console
- Also avoid using reflection utils from apache commons, instead
  use reflection directly. The illegal access warnings are then
  properly reported against our class
  net.sourceforge.pmd.ant.Formatter.

Fixes #1860
2024-10-25 18:33:36 +02:00
Andreas Dangel 74ec6f45ee [doc] Fix release notes for 7.7.0
Old rule name was actually DefaultLabelNotLastInSwitchStmt
2024-10-25 10:35:02 +02:00
Andreas Dangel c179834288 [release] Prepare next development version [skip ci] 2024-10-25 09:28:54 +02:00
Andreas Dangel 7739f2b840 [release] prepare release pmd_releases/7.7.0 2024-10-25 09:07:54 +02:00
Andreas Dangel 919e73f6b0 Prepare pmd release 7.7.0 2024-10-25 08:47:38 +02:00
Andreas Dangel e2d59c0e64 Fix #5244: [java] UselessOperationOnImmutable: consider java.time.* types (#5279)
Merge pull request #5279 from adangel:issue-5244
2024-10-24 14:24:16 +02:00
Andreas Dangel 8f2d47dfb7 Fix #5270: [apex] AvoidNonRestrictiveQueries: Fix regex for detecting LIMIT clause (#5273)
Merge pull request #5273 from adangel:issue-5270
2024-10-24 14:22:25 +02:00
Andreas Dangel e6097d6090 [java] Rename rule SwitchStmtsShouldHaveDefault to NonExhaustiveSwitch (#5267)
Merge pull request #5267 from adangel:issue-4286
2024-10-24 14:21:04 +02:00
Andreas Dangel 5e83246469 [doc] Update release notes (#5267) 2024-10-24 14:16:43 +02:00
Andreas Dangel 62c2858f70 Fix #5257: [java] NonCaseLabelInSwitch - support switch expressions (#5256)
Merge pull request #5256 from adangel:rename-nocaselabelswitch
2024-10-24 14:15:06 +02:00
Andreas Dangel 0d8878d58e [java] Rename rule DefaultLabelNotLastInSwitch (#5255)
Merge pull request #5255 from adangel:rename-defaultlabelswitch
2024-10-24 14:10:16 +02:00
Andreas Dangel 4b23718aac Fix #4813: [java] SwitchStmtsShouldHaveDefault false positive with pattern matching (#5252)
Merge pull request #5252 from adangel:issue-4813
2024-10-24 14:08:12 +02:00
Andreas Dangel 3a501a0f6b Fix #5249 and #5250: [java] TooFewBranchesForSwitch ignore pattern matching and support switch expressions (#5251)
Merge pull request #5251 from adangel:issue-5249-5250
2024-10-24 14:06:03 +02:00
Andreas Dangel 36654ed52e [java] UselessOperationOnImmutable: false positive on void results 2024-10-24 13:08:09 +02:00
Andreas Dangel 45b1217485 [java] TooFewBranchesForSwitch: don't report empty switch
Empty switch statements are already reported
by EmptyControlStatement
2024-10-24 12:51:42 +02:00
Andreas Dangel 662759755d [java] SwitchStmtsShouldHaveDefault.xml: don't report empty switch
Empty switch statements are already reported
by EmptyControlStatement
2024-10-24 12:47:53 +02:00
Andreas Dangel d9d6b57f2a [java] TooFewBranchesForSwitch: report empty switch
This fixes a false negative
2024-10-24 12:38:45 +02:00
Andreas Dangel 6c35c73919 [java] SwitchStmtsShouldHaveDefault: use new PatternLabel attribute 2024-10-24 11:29:40 +02:00
Andreas Dangel e37f82b62d Merge branch 'main' into issue-4813 2024-10-24 11:24:17 +02:00
Andreas Dangel 6f5af6e585 [java] TooFewBranchesForSwitch: use new PatternLabel attribute 2024-10-24 11:22:47 +02:00
Andreas Dangel 66d879f707 Merge branch 'main' into issue-5249-5250 2024-10-24 11:20:39 +02:00
Andreas Dangel 93f6279ea7 Fix #3362: [java] ImplicitSwitchFallThrough should consider switch expressions (#5248) 2024-10-24 10:46:59 +02:00
Andreas Dangel 156f293ef3 Fix #5030: [java] SwitchDensity false positive with pattern matching (#5247) 2024-10-24 10:45:56 +02:00
Andreas Dangel 40ed4590be [java] Improve UnitTestShouldUse{After,Before}Annotation rules to support JUnit5 and TestNG (#5245) 2024-10-24 10:43:48 +02:00
Andreas Dangel 7358289bbe [cpp] Ignore literals and ignore identifiers capability to C++ CPD (#5040)
Merge pull request #5040 from jdupak:master
2024-10-24 10:18:39 +02:00
Andreas Dangel a180258033 [doc] Update release notes (#5040) 2024-10-24 10:17:51 +02:00
Andreas Dangel 63675eaa18 [doc] Update release notes (#5279) 2024-10-22 21:03:22 +02:00
Andreas Dangel 49f2c15b83 [doc] Update release notes (#5273) 2024-10-22 21:01:42 +02:00
Andreas Dangel 15520211b5 Merge branch 'main' into issue-5270 2024-10-22 21:01:00 +02:00
Andreas Dangel c4b8f18a36 [doc] Update release notes (#5252) 2024-10-22 20:58:37 +02:00
Andreas Dangel c95817a75d Merge branch 'main' into issue-4813 2024-10-22 20:55:38 +02:00
Andreas DangelandClément Fournier 09b0864eff Apply suggestions from code review
Co-authored-by: Clément Fournier <clement.fournier@tu-dresden.de>
2024-10-22 20:50:10 +02:00
dependabot[bot] 1517a18956 Bump org.scala-lang:scala-reflect from 2.13.13 to 2.13.15 (#5281)
Bumps [org.scala-lang:scala-reflect](https://github.com/scala/scala) from 2.13.13 to 2.13.15.
- [Release notes](https://github.com/scala/scala/releases)
- [Commits](https://github.com/scala/scala/compare/v2.13.13...v2.13.15)

---
updated-dependencies:
- dependency-name: org.scala-lang:scala-reflect
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-22 20:23:50 +02:00
Willem Hajenius 61b1c372cd [apex] Must use case-insensitive input stream to avoid choking on Unicode escape sequences 2024-10-22 12:27:28 +02:00
Juan Martín Sotuyo Dodero 97fe389dcc Bump danger from 9.5.0 to 9.5.1 in the all-gems group across 1 directory (#5280) 2024-10-21 11:28:12 -03:00
dependabot[bot] 7df70ea7c1 Bump danger from 9.5.0 to 9.5.1 in the all-gems group across 1 directory
Bumps the all-gems group with 1 update in the / directory: [danger](https://github.com/danger/danger).


Updates `danger` from 9.5.0 to 9.5.1
- [Release notes](https://github.com/danger/danger/releases)
- [Changelog](https://github.com/danger/danger/blob/master/CHANGELOG.md)
- [Commits](https://github.com/danger/danger/compare/v9.5.0...v9.5.1)

---
updated-dependencies:
- dependency-name: danger
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-gems
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-21 03:18:38 +00:00
Jakub Dupak 7ad4e0f0fc Add @jdupak as a contributor 2024-10-20 21:57:48 +02:00
Jakub Dupak c47f5a6062 [cpd] Add ignore literals and identifiers capability to C++ 2024-10-20 21:57:48 +02:00
Andreas Dangel 6d55f6f053 [java] UselessOperationOnImmutable: consider java.time.* types
Fixes #5244
2024-10-18 17:42:44 +02:00
Andreas Dangel 5df7dccfb6 [doc] Update release notes (#5255) 2024-10-18 16:40:27 +02:00
Andreas Dangel f4941433ce Merge branch 'main' into rename-defaultlabelswitch 2024-10-18 16:39:12 +02:00
Andreas Dangel 665504decc [doc] Update release notes (#5251) 2024-10-18 16:30:41 +02:00
Andreas Dangel ef0db9a166 Merge branch 'main' into issue-5249-5250 2024-10-18 16:30:01 +02:00
Andreas Dangel fd8fcd67d6 [doc] Update release notes (#5248) 2024-10-18 16:23:17 +02:00
Andreas Dangel dafdc964a5 Merge branch 'main' into issue-3362 2024-10-18 16:22:17 +02:00
Andreas Dangel 81429a4628 [doc] Update release notes (#5247) 2024-10-18 16:21:02 +02:00
Andreas Dangel fb94e2493c Merge branch 'main' into issue-5030 2024-10-18 16:20:11 +02:00
Andreas Dangel a0d4b38b53 [doc] Update release notes (#5245) 2024-10-18 16:16:54 +02:00
Andreas Dangel f317e8bee5 Merge branch 'main' into java-unit-test-rules 2024-10-18 16:15:51 +02:00
Andreas Dangel 7ae3155325 Add @thesunlover as a contributor 2024-10-11 11:57:39 +02:00
Andreas Dangel c595fea83f [apex] AvoidNonRestrictiveQueries: Fix regex for detecting LIMIT clause
Fixes #5270
2024-10-11 11:57:10 +02:00
Andreas Dangel 07840cace2 [java] Rename rule SwitchStmtsShouldHaveDefault to NonExhaustiveSwitch
Fixes #4286
2024-10-08 17:33:32 +02:00
Andreas Dangel ff1b9b2cdd [java] SwitchStmtsShouldHaveDefault - test for multiple case constants 2024-10-08 17:15:18 +02:00
Andreas Dangel 377670f267 [doc] Update release notes (#5257) 2024-10-06 18:48:47 +02:00
Andreas Dangel 5ecc29245b Fix externalInfoUrl after rename 2024-10-05 11:37:45 +02:00
Andreas Dangel 079eb238b9 [java] NonCaseLabelInSwitch - support switch expressions
Rename rule from NonCaseLabelInSwitchStatement

- as it applies to both switch statements and switch expressions
- extend the test cases to cover new java syntax
2024-10-05 11:19:53 +02:00
Andreas Dangel b3157825d8 [java] Rename rule DefaultLabelNotLastInSwitch
- as it applies to both switch statements and switch expressions
- extend the test cases to cover new java syntax

Note: For patterns in switch, the java compiler already makes sure, that
default is the last case.
2024-10-05 11:00:13 +02:00
Andreas Dangel 6f081e111a Update pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml 2024-10-05 10:41:10 +02:00
Andreas Dangel 59403fc9e1 [java] SwitchStmtsShouldHaveDefault - also ignore record pattern 2024-10-05 10:39:55 +02:00
Andreas Dangel 13cc79af62 [java] TooFewBranchesForSwitch - also ignore record pattern 2024-10-05 10:36:39 +02:00
Andreas Dangel 1f31f771ad [java] SwitchDensity - more tests with (record) patterns 2024-10-05 10:31:40 +02:00
Andreas Dangel d9db4dbcab [java] Rename TooFewBranchesForSwitch in quickstart.xml 2024-10-05 10:19:03 +02:00
Andreas Dangel 855e5175d4 [java] Renamed rule TooFewBranchesForSwitch
as it consider Switch Expressions now
additionally to Switch Statements.
2024-10-04 17:48:56 +02:00
Andreas Dangel b87944a565 [java] TooFewBranchesForSwitch should consider Switch Expressions
Fixes #5250
2024-10-04 17:48:49 +02:00
Andreas Dangel 90f436fd28 [java] TooFewBranchesForSwitch should ignore Pattern Matching
Fixes #5249
2024-10-04 17:47:21 +02:00
Andreas Dangel 375fb72f3c [java] Fix tree dump test
New SwitchLabel#PatternLabel flag
2024-10-04 17:32:46 +02:00
Andreas Dangel 49deb8d4a0 [java] SwitchDensity false positive with pattern matching
Fixes #5030
2024-10-04 17:12:29 +02:00
Andreas Dangel 312d8e46ae [java] ImplicitSwitchFallThrough should consider switch expressions
Fixes #3362
2024-10-04 16:45:29 +02:00
Andreas Dangel e5ff5532d4 Update @emouty as a contributor 2024-10-04 16:05:46 +02:00
Andreas Dangel 0c858b0a7b [java] SwitchStmtsShouldHaveDefault should ignore patterns
Fixes #4813
2024-10-04 16:05:45 +02:00
Andreas Dangel 9337e5a7a2 [java] UnitTestShouldUseAfterAnnotation: Consider JUnit 5 and TestNG 2024-10-03 20:55:11 +02:00
Andreas Dangel 33c737718c [java] UnitTestShouldUseBeforeAnnotation: Consider JUnit 5 and TestNG 2024-10-03 20:55:10 +02:00
172 changed files with 10685 additions and 1070 deletions

No files matched your search

+48 -1
View File
@@ -7453,7 +7453,8 @@
"avatar_url": "https://avatars.githubusercontent.com/u/16755668?v=4",
"profile": "https://github.com/emouty",
"contributions": [
"code"
"code",
"bug"
]
},
{
@@ -7516,6 +7517,7 @@
"avatar_url": "https://avatars.githubusercontent.com/u/18402464?v=4",
"profile": "https://github.com/mitchspano",
"contributions": [
"code",
"bug"
]
},
@@ -7820,6 +7822,15 @@
"bug"
]
},
{
"login": "thesunlover",
"name": "Iskren Stanislavov",
"avatar_url": "https://avatars.githubusercontent.com/u/6734600?v=4",
"profile": "https://interop.io/",
"contributions": [
"bug"
]
},
{
"login": "gudzpoz",
"name": "gudzpoz",
@@ -7846,6 +7857,42 @@
"contributions": [
"code"
]
},
{
"login": "jdupak",
"name": "Jakub Dupak",
"avatar_url": "https://avatars.githubusercontent.com/u/22683640?v=4",
"profile": "https://github.com/jdupak",
"contributions": [
"code"
]
},
{
"login": "chenguangqi",
"name": "天热吃西瓜",
"avatar_url": "https://avatars.githubusercontent.com/u/6231010?v=4",
"profile": "http://chenguangqi.github.io/",
"contributions": [
"bug"
]
},
{
"login": "wahajenius",
"name": "Willem A. Hajenius",
"avatar_url": "https://avatars.githubusercontent.com/u/7836322?v=4",
"profile": "https://github.com/wahajenius",
"contributions": [
"code"
]
},
{
"login": "VitaliiIevtushenko",
"name": "Vitalii Yevtushenko",
"avatar_url": "https://avatars.githubusercontent.com/u/11145125?v=4",
"profile": "https://github.com/VitaliiIevtushenko",
"contributions": [
"bug"
]
}
],
"contributorsPerLine": 7,
+16 -12
View File
@@ -3,6 +3,7 @@ GEM
specs:
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
base64 (0.2.0)
bigdecimal (3.1.8)
claide (1.1.0)
claide-plugins (0.9.2)
@@ -13,7 +14,8 @@ GEM
concurrent-ruby (1.3.4)
cork (0.3.0)
colored2 (~> 3.1)
danger (9.5.0)
danger (9.5.1)
base64 (~> 0.2)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
@@ -24,12 +26,14 @@ GEM
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.0)
octokit (>= 4.0)
pstore (~> 0.1)
terminal-table (>= 1, < 4)
differ (0.1.2)
et-orbi (1.2.11)
tzinfo
faraday (2.11.0)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
logger
faraday-http-cache (2.5.1)
faraday (>= 0.8)
@@ -41,19 +45,20 @@ GEM
git (1.19.1)
addressable (~> 2.8)
rchardet (~> 1.8)
json (2.7.5)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (5.5.1)
logger (1.6.0)
logger (1.6.1)
logger-colors (1.0.0)
nap (1.1.0)
net-http (0.4.1)
uri
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
octokit (9.1.0)
octokit (9.2.0)
faraday (>= 1, < 3)
sawyer (~> 0.9)
open4 (1.3.4)
@@ -64,26 +69,25 @@ GEM
nokogiri (~> 1.13)
rufus-scheduler (~> 3.8)
slop (~> 4.9)
pstore (0.1.3)
public_suffix (6.0.1)
raabro (1.4.0)
racc (1.8.1)
rchardet (1.8.0)
rexml (3.3.6)
strscan
rouge (4.4.0)
rufus-scheduler (3.9.1)
fugit (~> 1.1, >= 1.1.6)
rexml (3.3.9)
rouge (4.5.1)
rufus-scheduler (3.9.2)
fugit (~> 1.1, >= 1.11.1)
safe_yaml (1.0.5)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
slop (4.10.1)
strscan (3.1.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
uri (0.13.1)
PLATFORMS
@@ -98,4 +102,4 @@ DEPENDENCIES
safe_yaml
BUNDLED WITH
2.5.3
2.5.22
+2 -2
View File
@@ -172,8 +172,8 @@ public class ${lexer-name}'/>
</delete>
</target>
<target name="pmd-language" depends="check-up-to-date, annotate-classes, pmd-language-processing, update-stamp-file"/>
<target name="pmd-language-processing" description="Adapt Antlr sources for PMD languages" depends="rename-parser"
<target name="pmd-language" depends="check-up-to-date, rename-parser, annotate-classes, pmd-language-processing, update-stamp-file"/>
<target name="pmd-language-processing" description="Adapt Antlr sources for PMD languages"
unless="processing-not-required">
<!-- Adapt parser. -->
+12 -10
View File
@@ -1,8 +1,9 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.2.1)
activesupport (7.2.2)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
@@ -15,6 +16,7 @@ GEM
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
base64 (0.2.0)
benchmark (0.3.0)
bigdecimal (3.1.8)
coffee-script (2.4.1)
coffee-script-source
@@ -34,9 +36,10 @@ GEM
ethon (0.16.0)
ffi (>= 1.15.0)
eventmachine (1.2.7)
execjs (2.9.1)
faraday (2.11.0)
execjs (2.10.0)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
logger
faraday-net_http (3.3.0)
net-http
@@ -99,7 +102,7 @@ GEM
activesupport (>= 2)
nokogiri (>= 1.4)
http_parser.rb (0.8.0)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
jekyll (3.10.0)
addressable (~> 2.4)
@@ -211,6 +214,7 @@ GEM
gemoji (>= 3, < 5)
html-pipeline (~> 2.2)
jekyll (>= 3.0, < 5.0)
json (2.7.5)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
@@ -219,7 +223,7 @@ GEM
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.0)
logger (1.6.1)
mercenary (0.3.6)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
@@ -240,8 +244,7 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rexml (3.3.6)
strscan
rexml (3.3.9)
rouge (3.30.0)
rubyzip (2.3.2)
safe_yaml (1.0.5)
@@ -255,7 +258,6 @@ GEM
faraday (>= 0.17.3, < 3)
securerandom (0.3.1)
simpleidn (0.2.3)
strscan (3.1.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
typhoeus (1.4.1)
@@ -264,7 +266,7 @@ GEM
concurrent-ruby (~> 1.0)
unicode-display_width (1.8.0)
uri (0.13.1)
webrick (1.8.2)
webrick (1.9.0)
PLATFORMS
x86_64-linux
@@ -276,4 +278,4 @@ DEPENDENCIES
webrick
BUNDLED WITH
2.5.3
2.5.22
+3 -3
View File
@@ -1,9 +1,9 @@
repository: pmd/pmd
pmd:
version: 7.7.0-SNAPSHOT
previous_version: 7.6.0
date: 2024-10-25
version: 7.8.0-SNAPSHOT
previous_version: 7.7.0
date: 2024-11-29
# release types: major, minor, bugfix
release_type: minor
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -163,7 +163,7 @@ exactly identical.
{% include custom/cli_option_row.html options="--ignore-literals"
description="Ignore literal values such as numbers and strings when comparing text.
By default, literals are not ignored."
languages="Java"
languages="Java, C++"
%}
{% include custom/cli_option_row.html options="--ignore-literal-sequences"
description="Ignore sequences of literals such as list initializers.
@@ -173,7 +173,7 @@ exactly identical.
{% include custom/cli_option_row.html options="--ignore-identifiers"
description="Ignore names of classes, methods, variables, constants, etc. when comparing text.
By default, identifier names are not ignored."
languages="Java"
languages="Java, C++"
%}
{% include custom/cli_option_row.html options="--ignore-annotations"
description="Ignore language annotations (Java) or attributes (C#) when comparing text.
+55 -33
View File
@@ -14,48 +14,70 @@ This is a {{ site.pmd.release_type }} release.
### 🚀 New and noteworthy
### 🌟 Rule Changes
### 🌟 New and changed rules
#### Renamed Rules
* Several rules for unit testing have been renamed to better reflect their actual scope. Lots of them were called
after JUnit / JUnit 4, even when they applied to JUnit 5 and / or TestNG.
* {% rule java/bestpractices/UnitTestAssertionsShouldIncludeMessage %} (Java Best Practices) has been renamed from `JUnitAssertionsShouldIncludeMessage`.
* {% rule java/bestpractices/UnitTestContainsTooManyAsserts %} (Java Best Practices) has been renamed from `JUnitTestContainsTooManyAsserts`.
* {% rule java/bestpractices/UnitTestShouldIncludeAssert %} (Java Best Practices) has been renamed from `JUnitTestsShouldIncludeAssert`.
* {% rule java/bestpractices/UnitTestShouldUseAfterAnnotation %} (Java Best Practices) has been renamed from `JUnit4TestShouldUseAfterAnnotation`.
* {% rule java/bestpractices/UnitTestShouldUseBeforeAnnotation %} (Java Best Practices) has been renamed from `JUnit4TestShouldUseBeforeAnnotation`.
* {% rule java/bestpractices/UnitTestShouldUseTestAnnotation %} (Java Best Practices) has been renamed from `JUnit4TestShouldUseTestAnnotation`.
The old rule names still work but are deprecated.
#### New Rules
* The new Apex rule {% rule apex/bestpractices/QueueableWithoutFinalizer %} detects when the Queueable interface
is used but a Finalizer is not attached. Without attaching a Finalizer, there is no way of designing error
recovery actions should the Queueable action fail.
### 🐛 Fixed Issues
* ant
* [#1860](https://github.com/pmd/pmd/issues/1860): \[ant] Reflective access warnings on java > 9 and java < 17
* apex
* [#5302](https://github.com/pmd/pmd/issues/5302): \[apex] New Rule: Queueable Should Attach Finalizer
* [#5333](https://github.com/pmd/pmd/issues/5333): \[apex] Token recognition errors for string containing unicode escape sequence
* html
* [#5322](https://github.com/pmd/pmd/issues/5322): \[html] CPD throws exception on when HTML file is missing closing tag
* java
* [#4532](https://github.com/pmd/pmd/issues/4532): \[java] Rule misnomer for JUnit* rules
* [#5261](https://github.com/pmd/pmd/issues/5261): \[java] Record patterns with empty deconstructor lists lead to NPE
* [#5293](https://github.com/pmd/pmd/issues/5293): \[java] Deadlock when executing PMD in multiple threads
* [#5324](https://github.com/pmd/pmd/issues/5324): \[java] Issue with type inference of nested lambdas
* [#5329](https://github.com/pmd/pmd/issues/5329): \[java] Type inference issue with unknown method ref in call chain
* java-bestpractices
* [#5083](https://github.com/pmd/pmd/issues/5083): \[java] UnusedPrivateMethod false positive when method reference has no target type
* [#5097](https://github.com/pmd/pmd/issues/5097): \[java] UnusedPrivateMethod FP with raw type missing from the classpath
* [#5318](https://github.com/pmd/pmd/issues/5318): \[java] PreserveStackTraceRule: false-positive on Pattern Matching with instanceof
* java-codestyle
* [#5253](https://github.com/pmd/pmd/issues/5253): \[java] BooleanGetMethodName: False-negatives with `Boolean` wrapper
* java-errorprone
* [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault()
* [#5263](https://github.com/pmd/pmd/issues/5263): \[java] UnnecessaryFullyQualifiedName: false-positive in an enum that uses its own static variables
* java-performance
* [#5287](https://github.com/pmd/pmd/issues/5287): \[java] TooFewBranchesForSwitch false-positive with switch using list of case constants
* [#5314](https://github.com/pmd/pmd/issues/5314): \[java] InsufficientStringBufferDeclarationRule: Lack of handling for char type parameters
### 🚨 API Changes
* java-bestpractices
* The old rule name `JUnit4TestShouldUseAfterAnnotation` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestShouldUseAfterAnnotation %} instead.
* The old rule name `JUnit4TestShouldUseBeforeAnnotation` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestShouldUseBeforeAnnotation %} instead.
* The old rule name `JUnit4TestShouldUseTestAnnotation` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestShouldUseTestAnnotation %} instead.
* The old rule name `JUnitAssertionsShouldIncludeMessage` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestAssertionsShouldIncludeMessage %} instead.
* The old rule name `JUnitTestContainsTooManyAsserts` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestContainsTooManyAsserts %} instead.
* The old rule name `JUnitTestsShouldIncludeAssert` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestShouldIncludeAssert %} instead.
#### Deprecations
* pmd-gherkin
* {%jdoc gherkin::lang.gherkin.ast.GherkinBaseListener %} is deprecated for removal. This class was never intended
to be generated. It will be removed with no replacement.
* {%jdoc gherkin::lang.gherkin.ast.GherkinBaseVisitor %} is deprecated for removal. This class was never intended
to be generated. It will be removed with no replacement.
* {%jdoc gherkin::lang.gherkin.ast.GherkinListener %} is deprecated for removal. This class was never intended
to be generated. It will be removed with no replacement.
* {%jdoc gherkin::lang.gherkin.ast.GherkinParser %} is deprecated for removal. This class was never intended
to be generated. It will be removed with no replacement.
* {%jdoc gherkin::lang.gherkin.ast.GherkinVisitor %} is deprecated for removal. This class was never intended
to be generated. It will be removed with no replacement.
* pmd-julia
* {%jdoc julia::lang.julia.ast.JuliaBaseListener %} is deprecated for removal. This class was never intended to
be generated. It will be removed with no replacement.
* {%jdoc julia::lang.julia.ast.JuliaBaseVisitor %} is deprecated for removal. This class was never intended to
be generated. It will be removed with no replacement.
* {%jdoc julia::lang.julia.ast.JuliaListener %} is deprecated for removal. This class was never intended to
be generated. It will be removed with no replacement.
* {%jdoc julia::lang.julia.ast.JuliaParser %} is deprecated for removal. This class was never intended to
be generated. It will be removed with no replacement.
* {%jdoc julia::lang.julia.ast.JuliaVisitor %} is deprecated for removal. This class was never intended to
be generated. It will be removed with no replacement.
* pmd-kotlin
* {%jdoc kotlin::lang.kotlin.ast.UnicodeClasses %} is deprecated for removal. This class was never intended to
be generated. It will be removed with no replacement.
* pmd-xml
* {%jdoc xml::lang.xml.antlr4.XMLLexer %} is deprecated for removal. Use {%jdoc !!xml::lang.xml.ast.XMLLexer %}
instead (note different package `ast` instead of `antlr4`).
### ✨ Merged pull requests
* [#4965](https://github.com/pmd/pmd/pull/4965): Fix #4532: \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod)
* [#5225](https://github.com/pmd/pmd/pull/5225): Fix #5067: \[java] CloseResource: False positive for FileSystems.getDefault() - [Lukas Gräf](https://github.com/lukasgraef) (@lukasgraef)
* [#5241](https://github.com/pmd/pmd/pull/5241): Ignore javacc code in coverage report - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod)
* [#5258](https://github.com/pmd/pmd/pull/5258): Ignore generated antlr classes in coverage reports - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod)
* [#5264](https://github.com/pmd/pmd/pull/5264): Fix #5261: \[java] Fix NPE with empty pattern list - [Clément Fournier](https://github.com/oowekyala) (@oowekyala)
* [#5269](https://github.com/pmd/pmd/pull/5269): Fix #5253: \[java] Support Boolean wrapper class for BooleanGetMethodName rule - [Aryant Tripathi](https://github.com/Aryant-Tripathi) (@Aryant-Tripathi)
* [#5275](https://github.com/pmd/pmd/pull/5275): Use plugin-classpath to simplify javacc-wrapper.xml - [Andreas Dangel](https://github.com/adangel) (@adangel)
* [#5278](https://github.com/pmd/pmd/pull/5278): \[java] CouplingBetweenObjects: improve violation message - [Andreas Dangel](https://github.com/adangel) (@adangel)
### ✨ External Contributions
* [#5284](https://github.com/pmd/pmd/pull/5284): \[apex] Use case-insensitive input stream to avoid choking on Unicode escape sequences - [Willem A. Hajenius](https://github.com/wahajenius) (@wahajenius)
* [#5303](https://github.com/pmd/pmd/pull/5303): \[apex] New Rule: Queueable Should Attach Finalizer - [Mitch Spano](https://github.com/mitchspano) (@mitchspano)
{% endtocmaker %}
+126
View File
@@ -5,6 +5,132 @@ permalink: pmd_release_notes_old.html
Previous versions of PMD can be downloaded here: [Releases - pmd/pmd (GitHub)](https://github.com/pmd/pmd/releases)
## 25-October-2024 - 7.7.0
The PMD team is pleased to announce PMD 7.7.0.
This is a minor release.
### Table Of Contents
* [🚀 New and noteworthy](#new-and-noteworthy)
* [CPD can now ignore literals and identifiers in C++ code](#cpd-can-now-ignore-literals-and-identifiers-in-c-code)
* [🌟 Rule Changes](#rule-changes)
* [Changed Rules](#changed-rules)
* [Renamed Rules](#renamed-rules)
* [🐛 Fixed Issues](#fixed-issues)
* [🚨 API Changes](#api-changes)
* [✨ Merged pull requests](#merged-pull-requests)
* [📦 Dependency updates](#dependency-updates)
* [📈 Stats](#stats)
### 🚀 New and noteworthy
#### CPD can now ignore literals and identifiers in C++ code
When searching for duplicated code in C++ differences in literals or identifiers can be
ignored now (like in Java). This can be enabled via the command line options `--ignore-literal`
and `--ignore-identifiers`.
See [PR #5040](https://github.com/pmd/pmd/pull/5040) for details.
### 🌟 Rule Changes
#### Changed Rules
* [`SwitchStmtsShouldHaveDefault`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#switchstmtsshouldhavedefault) (Java Best Practices) doesn't report empty switch statements anymore.
To detect these, use [`EmptyControlStatement`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_codestyle.html#emptycontrolstatement).
* [`UnitTestShouldUseAfterAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshoulduseafterannotation) (Java Best Practices) now also considers JUnit 5 and TestNG tests.
* [`UnitTestShouldUseBeforeAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldusebeforeannotation) (Java Best Practices) now also considers JUnit 5 and TestNG tests.
* [`TooFewBranchesForSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_performance.html#toofewbranchesforswitch) (Java Performance) doesn't report empty switches anymore.
To detect these, use [`EmptyControlStatement`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_codestyle.html#emptycontrolstatement).
#### Renamed Rules
* Several rules for unit testing have been renamed to better reflect their actual scope. Lots of them were called
after JUnit / JUnit 4, even when they applied to JUnit 5 and / or TestNG.
* [`UnitTestAssertionsShouldIncludeMessage`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestassertionsshouldincludemessage) (Java Best Practices) has been renamed from `JUnitAssertionsShouldIncludeMessage`.
* [`UnitTestContainsTooManyAsserts`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestcontainstoomanyasserts) (Java Best Practices) has been renamed from `JUnitTestContainsTooManyAsserts`.
* [`UnitTestShouldIncludeAssert`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldincludeassert) (Java Best Practices) has been renamed from `JUnitTestsShouldIncludeAssert`.
* [`UnitTestShouldUseAfterAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshoulduseafterannotation) (Java Best Practices) has been renamed from `JUnit4TestShouldUseAfterAnnotation`.
* [`UnitTestShouldUseBeforeAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldusebeforeannotation) (Java Best Practices) has been renamed from `JUnit4TestShouldUseBeforeAnnotation`.
* [`UnitTestShouldUseTestAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldusetestannotation) (Java Best Practices) has been renamed from `JUnit4TestShouldUseTestAnnotation`.
* Several rules about switch statements and switch expression have been renamed, as they apply both to Switch Statements
and to Switch Expressions:
* [`DefaultLabelNotLastInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitch) (Java Best Practices) has been renamed from `DefaultLabelNotLastInSwitchStmt`.
* [`NonCaseLabelInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_errorprone.html#noncaselabelinswitch) (Java Error Prone) has been renamed from `NonCaseLabelInSwitchStatement`.
* [`TooFewBranchesForSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_performance.html#toofewbranchesforswitch) (Java Performance) has been renamed from `TooFewBranchesForASwitchStatement`.
* [`NonExhaustiveSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#nonexhaustiveswitch) (Java Best Practices) has been renamed from `SwitchStmtsShouldHaveDefault`.
The old rule names still work but are deprecated.
### 🐛 Fixed Issues
* apex-performance
* [#5270](https://github.com/pmd/pmd/issues/5270): \[apex] AvoidNonRestrictiveQueries when LIMIT is followed by bind expression
* java
* [#4532](https://github.com/pmd/pmd/issues/4532): \[java] Rule misnomer for JUnit* rules
* [#5261](https://github.com/pmd/pmd/issues/5261): \[java] Record patterns with empty deconstructor lists lead to NPE
* java-bestpractices
* [#4286](https://github.com/pmd/pmd/issues/4286): \[java] Rename rule SwitchStmtsShouldHaveDefault to NonExhaustiveSwitch
* [#4813](https://github.com/pmd/pmd/issues/4813): \[java] SwitchStmtsShouldHaveDefault false positive with pattern matching
* java-codestyle
* [#5253](https://github.com/pmd/pmd/issues/5253): \[java] BooleanGetMethodName: False-negatives with `Boolean` wrapper
* java-design
* [#5030](https://github.com/pmd/pmd/issues/5030): \[java] SwitchDensity false positive with pattern matching
* java-errorprone
* [#3362](https://github.com/pmd/pmd/issues/3362): \[java] ImplicitSwitchFallThrough should consider switch expressions
* [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault()
* [#5244](https://github.com/pmd/pmd/issues/5244): \[java] UselessOperationOnImmutable should detect java.time types
* [#5257](https://github.com/pmd/pmd/issues/5257): \[java] NonCaseLabelInSwitch should consider switch expressions
* java-performance
* [#5249](https://github.com/pmd/pmd/issues/5249): \[java] TooFewBranchesForASwitchStatement false positive for Pattern Matching
* [#5250](https://github.com/pmd/pmd/issues/5250): \[java] TooFewBranchesForASwitchStatement should consider Switch Expressions
### 🚨 API Changes
* java-bestpractices
* The old rule name `JUnit4TestShouldUseAfterAnnotation` has been deprecated. Use the new name [`UnitTestShouldUseAfterAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshoulduseafterannotation) instead.
* The old rule name `JUnit4TestShouldUseBeforeAnnotation` has been deprecated. Use the new name [`UnitTestShouldUseBeforeAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldusebeforeannotation) instead.
* The old rule name `JUnit4TestShouldUseTestAnnotation` has been deprecated. Use the new name [`UnitTestShouldUseTestAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldusetestannotation) instead.
* The old rule name `JUnitAssertionsShouldIncludeMessage` has been deprecated. Use the new name [`UnitTestAssertionsShouldIncludeMessage`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestassertionsshouldincludemessage) instead.
* The old rule name `JUnitTestContainsTooManyAsserts` has been deprecated. Use the new name [`UnitTestContainsTooManyAsserts`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestcontainstoomanyasserts) instead.
* The old rule name `JUnitTestsShouldIncludeAssert` has been deprecated. Use the new name [`UnitTestShouldIncludeAssert`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldincludeassert) instead.
* The old rule name `DefaultLabelNotLastInSwitchStmt` has been deprecated. Use the new name [`DefaultLabelNotLastInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitch) instead.
* The old rule name `SwitchStmtsShouldHaveDefault` has been deprecated. USe the new name [`NonExhaustiveSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#nonexhaustiveswitch) instead.
* java-errorprone
* The old rule name `NonCaseLabelInSwitchStatement` has been deprecated. Use the new name [`NonCaseLabelInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_errorprone.html#noncaselabelinswitch) instead.
* java-performance
* The old rule name `TooFewBranchesForASwitchStatement` has been deprecated. Use the new name [`TooFewBranchesForSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_performance.html#toofewbranchesforswitch) instead.
### ✨ Merged pull requests
* [#4965](https://github.com/pmd/pmd/pull/4965): Fix #4532: \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod)
* [#5040](https://github.com/pmd/pmd/pull/5040): \[cpp] Ignore literals and ignore identifiers capability to C++ CPD - [Jakub Dupak](https://github.com/jdupak) (@jdupak)
* [#5225](https://github.com/pmd/pmd/pull/5225): Fix #5067: \[java] CloseResource: False positive for FileSystems.getDefault() - [Lukas Gräf](https://github.com/lukasgraef) (@lukasgraef)
* [#5241](https://github.com/pmd/pmd/pull/5241): Ignore javacc code in coverage report - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod)
* [#5245](https://github.com/pmd/pmd/pull/5245): \[java] Improve UnitTestShouldUse{After,Before}Annotation rules to support JUnit5 and TestNG - [Andreas Dangel](https://github.com/adangel) (@adangel)
* [#5247](https://github.com/pmd/pmd/pull/5247): Fix #5030: \[java] SwitchDensity false positive with pattern matching - [Andreas Dangel](https://github.com/adangel) (@adangel)
* [#5248](https://github.com/pmd/pmd/pull/5248): Fix #3362: \[java] ImplicitSwitchFallThrough should consider switch expressions - [Andreas Dangel](https://github.com/adangel) (@adangel)
* [#5251](https://github.com/pmd/pmd/pull/5251): Fix #5249 and #5250: \[java] TooFewBranchesForSwitch ignore pattern matching and support switch expressions - [Andreas Dangel](https://github.com/adangel) (@adangel)
* [#5252](https://github.com/pmd/pmd/pull/5252): Fix #4813: \[java] SwitchStmtsShouldHaveDefault false positive with pattern matching - [Andreas Dangel](https://github.com/adangel) (@adangel)
* [#5255](https://github.com/pmd/pmd/pull/5255): \[java] Rename rule DefaultLabelNotLastInSwitch - [Andreas Dangel](https://github.com/adangel) (@adangel)
* [#5256](https://github.com/pmd/pmd/pull/5256): Fix #5257: \[java] NonCaseLabelInSwitch - support switch expressions - [Andreas Dangel](https://github.com/adangel) (@adangel)
* [#5258](https://github.com/pmd/pmd/pull/5258): Ignore generated antlr classes in coverage reports - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod)
* [#5264](https://github.com/pmd/pmd/pull/5264): Fix #5261: \[java] Fix NPE with empty pattern list - [Clément Fournier](https://github.com/oowekyala) (@oowekyala)
* [#5267](https://github.com/pmd/pmd/pull/5267): \[java] Rename rule SwitchStmtsShouldHaveDefault to NonExhaustiveSwitch - [Andreas Dangel](https://github.com/adangel) (@adangel)
* [#5269](https://github.com/pmd/pmd/pull/5269): Fix #5253: \[java] Support Boolean wrapper class for BooleanGetMethodName rule - [Aryant Tripathi](https://github.com/Aryant-Tripathi) (@Aryant-Tripathi)
* [#5273](https://github.com/pmd/pmd/pull/5273): Fix #5270: \[apex] AvoidNonRestrictiveQueries: Fix regex for detecting LIMIT clause - [Andreas Dangel](https://github.com/adangel) (@adangel)
* [#5275](https://github.com/pmd/pmd/pull/5275): Use plugin-classpath to simplify javacc-wrapper.xml - [Andreas Dangel](https://github.com/adangel) (@adangel)
* [#5278](https://github.com/pmd/pmd/pull/5278): \[java] CouplingBetweenObjects: improve violation message - [Andreas Dangel](https://github.com/adangel) (@adangel)
* [#5279](https://github.com/pmd/pmd/pull/5279): Fix #5244: \[java] UselessOperationOnImmutable: consider java.time.* types - [Andreas Dangel](https://github.com/adangel) (@adangel)
### 📦 Dependency updates
* [#5234](https://github.com/pmd/pmd/issues/5234): Bump com.google.protobuf:protobuf-java from 3.25.3 to 4.28.2
* [#5274](https://github.com/pmd/pmd/issues/5274): Bump org.junit from 5.8.2 to 5.11.2
* [#5276](https://github.com/pmd/pmd/issues/5276): Bump org.checkerframework:checker-qual from 2.11.1 to 3.48.1
* [#5280](https://github.com/pmd/pmd/issues/5280): Bump danger from 9.5.0 to 9.5.1 in the all-gems group across 1 directory
* [#5281](https://github.com/pmd/pmd/issues/5281): Bump org.scala-lang:scala-reflect from 2.13.13 to 2.13.15
### 📈 Stats
* 98 commits
* 32 closed tickets & PRs
* Days since last release: 27
## 27-September-2024 - 7.6.0
The PMD team is pleased to announce PMD 7.6.0.
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<artifactId>pmd</artifactId>
<groupId>net.sourceforge.pmd</groupId>
<version>7.7.0-SNAPSHOT</version>
<version>7.8.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -11,6 +11,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
@@ -21,8 +22,6 @@ import java.util.List;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.commons.lang3.reflect.MethodUtils;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Parameter;
@@ -200,10 +199,12 @@ public class Formatter {
if (console != null) {
// Since Java 22, this returns a console even for redirected streams.
// In that case, we need to check Console.isTerminal()
// https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/io/Console.html#isTerminal()
// See: JLine As The Default Console Provider (JDK-8308591)
try {
Boolean isTerminal = (Boolean) MethodUtils.invokeMethod(console, "isTerminal");
if (!isTerminal) {
Method method = Console.class.getMethod("isTerminal");
Object isTerminal = method.invoke(console);
if (isTerminal instanceof Boolean && !(Boolean) isTerminal) {
// stop here, we don't have an interactive console.
return null;
}
@@ -211,39 +212,58 @@ public class Formatter {
// fall-through - we use a Java Runtime < 22.
}
// Maybe this is Java17+? Then there will be a public method charset()
// https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Console.html#charset()
try {
Object res = FieldUtils.readDeclaredField(console, "cs", true);
if (res instanceof Charset) {
return ((Charset) res).name();
Method method = Console.class.getMethod("charset");
Object charset = method.invoke(console);
if (charset instanceof Charset) {
return ((Charset) charset).name();
}
} catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException ignored) {
// fall-through
}
{
// try to use the system property "sun.jnu.encoding", which is the platform encoding.
// this property is not specified and might not always be available, but it is for
// openjdk 11: https://github.com/openjdk/jdk11u/blob/cee8535a9d3de8558b4b5028d68e397e508bef71/src/java.base/share/native/libjava/System.c#L384
// if it exists, we use it - this avoids illegal reflective access below.
String jnuEncoding = System.getProperty("sun.jnu.encoding");
if (jnuEncoding != null) {
return jnuEncoding;
}
}
// the following parts are accessing private/protected fields via reflection
// this should work with Java 8 and 11. With Java 11, you'll see warnings abouts
// illegal reflective access, see #1860. However, the access still works.
// Fall-Back 1: private field "cs" in java.io.Console
try {
Field field = Console.class.getDeclaredField("cs");
field.setAccessible(true);
Object csField = field.get(console);
if (csField instanceof Charset) {
return ((Charset) csField).name();
}
} catch (IllegalArgumentException | ReflectiveOperationException ignored) {
// fall-through
}
// Maybe this is Java17+? Then there will be
// https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Console.html#charset()
// instead of the field "cs".
// Fall-Back 2: private native method "encoding()" in java.io.Console
try {
Method charsetMethod = Console.class.getDeclaredMethod("charset");
Charset charset = (Charset) charsetMethod.invoke(console);
return charset.name();
} catch (IllegalArgumentException | ReflectiveOperationException ignored) {
Method method = Console.class.getDeclaredMethod("encoding");
method.setAccessible(true);
Object encoding = method.invoke(console);
if (encoding instanceof String) {
return (String) encoding;
}
} catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException ignored) {
// fall-through
}
return getNativeConsoleEncoding();
}
return null;
}
private static String getNativeConsoleEncoding() {
try {
Object res = MethodUtils.invokeStaticMethod(Console.class, "encoding");
if (res instanceof String) {
return (String) res;
}
} catch (IllegalArgumentException | ReflectiveOperationException ignored) {
// fall-through
}
// we couldn't determine the correct platform console encoding
return null;
}
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>7.7.0-SNAPSHOT</version>
<version>7.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -14,14 +14,19 @@ import java.util.List;
import java.util.Map;
import java.util.RandomAccess;
import org.antlr.v4.runtime.BaseErrorListener;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Recognizer;
import org.antlr.v4.runtime.Token;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.LexException;
import net.sourceforge.pmd.lang.document.TextDocument;
import net.sourceforge.pmd.lang.document.TextRegion;
import io.github.apexdevtools.apexparser.ApexLexer;
import io.github.apexdevtools.apexparser.CaseInsensitiveInputStream;
@InternalApi
final class ApexCommentBuilder {
@@ -103,7 +108,15 @@ final class ApexCommentBuilder {
}
private static CommentInformation extractInformationFromComments(TextDocument sourceCode, String suppressMarker) {
ApexLexer lexer = new ApexLexer(CharStreams.fromString(sourceCode.getText().toString()));
String source = sourceCode.getText().toString();
ApexLexer lexer = new ApexLexer(new CaseInsensitiveInputStream(CharStreams.fromString(source)));
lexer.removeErrorListeners();
lexer.addErrorListener(new BaseErrorListener() {
@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) {
throw new LexException(line, charPositionInLine, sourceCode.getFileId(), msg, e);
}
});
List<Token> allCommentTokens = new ArrayList<>();
Map<Integer, String> suppressMap = new HashMap<>();
@@ -0,0 +1,92 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.rule.bestpractices;
import java.util.List;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.sourceforge.pmd.lang.apex.ast.ASTMethod;
import net.sourceforge.pmd.lang.apex.ast.ASTMethodCallExpression;
import net.sourceforge.pmd.lang.apex.ast.ASTParameter;
import net.sourceforge.pmd.lang.apex.ast.ASTUserClass;
import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule;
import net.sourceforge.pmd.lang.rule.RuleTargetSelector;
/**
* Scans classes which implement the `Queueable` interface. If the `public void
* execute(QueueableContext context)` method does not call the
* `System.attachFinalizer(Finalizer f)` method, then a violation will be added
* to the `execute` method.
*
* @author mitchspano
*/
public class QueueableWithoutFinalizerRule extends AbstractApexRule {
private static final String EXECUTE = "execute";
private static final String QUEUEABLE = "queueable";
private static final String QUEUEABLE_CONTEXT = "queueablecontext";
private static final String SYSTEM_ATTACH_FINALIZER = "system.attachfinalizer";
@Override
protected @NonNull RuleTargetSelector buildTargetSelector() {
return RuleTargetSelector.forTypes(ASTUserClass.class);
}
/**
* If the class implements the `Queueable` interface and the
* `execute(QueueableContext context)` does not call the
* `System.attachFinalizer(Finalizer f)` method, then add a violation.
*/
@Override
public Object visit(ASTUserClass theClass, Object data) {
if (!implementsTheQueueableInterface(theClass)) {
return data;
}
for (ASTMethod theMethod : theClass.descendants(ASTMethod.class).toList()) {
if (isTheExecuteMethodOfTheQueueableInterface(theMethod)
&& !callsTheSystemAttachFinalizerMethod(theMethod)) {
asCtx(data).addViolation(theMethod);
}
}
return data;
}
/** Determines if the class implements the Queueable interface. */
private boolean implementsTheQueueableInterface(ASTUserClass theClass) {
for (String interfaceName : theClass.getInterfaceNames()) {
if (QUEUEABLE.equalsIgnoreCase(interfaceName)) {
return true;
}
}
return false;
}
/**
* Determines if the method is the `execute(QueueableContext context)`
* method. Parameter count is checked to account for method overloading.
*/
private boolean isTheExecuteMethodOfTheQueueableInterface(ASTMethod theMethod) {
if (!EXECUTE.equalsIgnoreCase(theMethod.getCanonicalName())) {
return false;
}
List<ASTParameter> parameters = theMethod.descendants(ASTParameter.class).toList();
return parameters.size() == 1 && QUEUEABLE_CONTEXT.equalsIgnoreCase(parameters.get(0).getType());
}
/**
* Determines if the method calls the `System.attachFinalizer(Finalizer f)`
* method.
*/
private boolean callsTheSystemAttachFinalizerMethod(ASTMethod theMethod) {
for (ASTMethodCallExpression methodCallExpression : theMethod.descendants(ASTMethodCallExpression.class)
.toList()) {
if (SYSTEM_ATTACH_FINALIZER.equalsIgnoreCase(methodCallExpression.getFullMethodName())) {
return true;
}
}
return false;
}
}
@@ -24,7 +24,7 @@ import net.sourceforge.pmd.lang.rule.RuleTargetSelector;
import net.sourceforge.pmd.reporting.RuleContext;
public class AvoidNonRestrictiveQueriesRule extends AbstractApexRule {
private static final Pattern RESTRICTIVE_PATTERN = Pattern.compile("(where\\s+)|(limit\\s+)", Pattern.CASE_INSENSITIVE);
private static final Pattern RESTRICTIVE_PATTERN = Pattern.compile("\\b(where|limit)\\b", Pattern.CASE_INSENSITIVE);
private static final Pattern SELECT_OR_FIND_PATTERN = Pattern.compile("(select\\s+|find\\s+)", Pattern.CASE_INSENSITIVE);
private static final Pattern SUB_QUERY_PATTERN = Pattern.compile("(?i)\\(\\s*select\\s+[^)]+\\)");
@@ -285,4 +285,56 @@ Detects when a local variable is declared and/or assigned but not used.
</example>
</rule>
<rule name="QueueableWithoutFinalizer"
since="7.8.0"
language="apex"
message="This Queueable doesn't attach a Finalizer"
class="net.sourceforge.pmd.lang.apex.rule.bestpractices.QueueableWithoutFinalizerRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_bestpractices.html#queueablewithoutfinalizer">
<description>
Detects when the Queueable interface is used but a Finalizer is not attached.
It is best practice to call the `System.attachFinalizer(Finalizer f)` method within the `execute` method of a class which implements the `Queueable` interface.
Without attaching a Finalizer, there is no way of designing error recovery actions should the Queueable action fail.
</description>
<priority>5</priority>
<example>
<![CDATA[
// Incorrect code, does not attach a finalizer.
public class UserUpdater implements Queueable {
public List<User> usersToUpdate;
public UserUpdater(List<User> usersToUpdate) {
this.usersToUpdate = usersToUpdate;
}
public void execute(QueueableContext context) { // no Finalizer is attached
update usersToUpdate;
}
}
// Proper code, attaches a finalizer.
public class UserUpdater implements Queueable, Finalizer {
public List<User> usersToUpdate;
public UserUpdater(List<User> usersToUpdate) {
this.usersToUpdate = usersToUpdate;
}
public void execute(QueueableContext context) {
System.attachFinalizer(this);
update usersToUpdate;
}
public void execute(FinalizerContext ctx) {
if (ctx.getResult() == ParentJobResult.SUCCESS) {
// Handle success
} else {
// Handle failure
}
}
}
]]>
</example>
</rule>
</ruleset>
@@ -209,6 +209,7 @@
<priority>3</priority>
</rule>
<!-- <rule ref="category/apex/bestpractices.xml/UnusedLocalVariable"/> -->
<!-- <rule ref="category/apex/bestpractices.xml/QueueableWithoutFinalizer"/> -->
<!-- <rule ref="category/apex/errorprone.xml/OverrideBothEqualsAndHashcode" /> -->
<!-- <rule ref="category/apex/errorprone.xml/InaccessibleAuraEnabledGetter" /> -->
@@ -66,4 +66,12 @@ class ApexCommentTest extends ApexParserTestBase {
ASTFormalComment comment = file.descendants(ASTUserClass.class).children(ASTFormalComment.class).first();
assertEquals(FORMAL_COMMENT_CONTENT, comment.getImage());
}
@Test
void fileWithUnicodeEscapes() {
ASTApexFile file = apex.parse(FORMAL_COMMENT_CONTENT + "\n"
+ "class MyClass { String s = 'Fran\\u00E7ois'; }");
ASTFormalComment comment = file.descendants(ASTUserClass.class).children(ASTFormalComment.class).first();
assertEquals(FORMAL_COMMENT_CONTENT, comment.getImage());
}
}
@@ -8,14 +8,18 @@ package net.sourceforge.pmd.lang.apex.ast;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.antlr.v4.runtime.BaseErrorListener;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Recognizer;
import org.antlr.v4.runtime.Token;
import org.junit.jupiter.api.Test;
import io.github.apexdevtools.apexparser.ApexLexer;
import io.github.apexdevtools.apexparser.ApexParser;
import io.github.apexdevtools.apexparser.CaseInsensitiveInputStream;
/**
* This is an exploration test for {@link ApexLexer}.
@@ -49,4 +53,36 @@ class ApexLexerTest {
ApexParser.CompilationUnitContext compilationUnit = parser.compilationUnit();
assertNotNull(compilationUnit);
}
@Test
void testLexerUnicodeEscapes() {
String s = "'Fran\\u00E7ois'";
// note: with apex-parser 4.3.1, no errors are reported anymore
assertEquals(2, getLexingErrors(CharStreams.fromString(s)));
assertEquals(0, getLexingErrors(new CaseInsensitiveInputStream(CharStreams.fromString(s))));
}
private int getLexingErrors(CharStream stream) {
ApexLexer lexer = new ApexLexer(stream);
ErrorListener errorListener = new ErrorListener();
lexer.removeErrorListeners(); // Avoid distracting "token recognition error" stderr output
lexer.addErrorListener(errorListener);
CommonTokenStream tokens = new CommonTokenStream(lexer);
tokens.fill();
return errorListener.getErrorCount();
}
private static class ErrorListener extends BaseErrorListener {
private int errorCount = 0;
@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,
int charPositionInLine, String msg, RecognitionException e) {
++errorCount;
}
public int getErrorCount() {
return errorCount;
}
}
}
@@ -0,0 +1,11 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.rule.bestpractices;
import net.sourceforge.pmd.test.PmdRuleTst;
class QueueableWithoutFinalizerTest extends PmdRuleTst {
// no additional unit tests
}
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<test-data
xmlns="http://pmd.sourceforge.net/rule-tests"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
<test-code>
<description>[apex] Queueable Without Finalizer - positive test case #5302</description>
<expected-problems>1</expected-problems>
<expected-linenumbers>8</expected-linenumbers>
<code><![CDATA[
public class UserUpdater implements Queueable {
public List<User> usersToUpdate;
public UserUpdater(List<User> usersToUpdate) {
this.usersToUpdate = usersToUpdate;
}
public void execute(QueueableContext context) {
update usersToUpdate;
}
}
]]></code>
</test-code>
<test-code>
<description>[apex] Queueable Without Finalizer - negative test case #5302</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class UserUpdater implements Queueable, Finalizer {
public List<User> usersToUpdate;
public UserUpdater(List<User> usersToUpdate) {
this.usersToUpdate = usersToUpdate;
}
public void execute(QueueableContext context) {
System.attachFinalizer(this);
update usersToUpdate;
}
public void execute(FinalizerContext ctx) {
if (ctx.getResult() == ParentJobResult.SUCCESS) {
// Handle success
} else {
// Handle failure
}
}
}
]]></code>
</test-code>
</test-data>
@@ -260,6 +260,36 @@ public class Something {
.isEmpty();
}
}
]]></code>
</test-code>
<test-code>
<description>[apex] AvoidNonRestrictiveQueries when LIMIT is followed by bind expression #5270</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public with sharing class DemoController {
public static final Integer LIMIT_ACCOUNTS = 2;
@AuraEnabled
public static List<Account> getTwoAccounts() {
List<Account> result = [
SELECT Id, Name FROM Account WITH SECURITY_ENFORCED
LIMIT:LIMIT_ACCOUNTS // note: no spaces... - false positive here
];
List<Account> result2 = [
SELECT Id, Name FROM Account WITH SECURITY_ENFORCED
LIMIT :LIMIT_ACCOUNTS
];
List<Account> result3 = [
SELECT Id, Name FROM Account WITH SECURITY_ENFORCED
LIMIT : LIMIT_ACCOUNTS
];
// sosl:
List<List<SObject>> searchList = [FIND 'map*' IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead LIMIT:LIMIT_ACCOUNTS];
return result;
}
}
]]></code>
</test-code>
</test-data>
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>7.7.0-SNAPSHOT</version>
<version>7.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>7.7.0-SNAPSHOT</version>
<version>7.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>7.7.0-SNAPSHOT</version>
<version>7.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -48,7 +48,7 @@ class AbstractNodeTest {
return childIndexes;
}
static Object childrenAndGrandChildrenIndexes() {
static Object[] childrenAndGrandChildrenIndexes() {
final Integer[] childrenIndexes = childrenIndexes();
final Integer[] grandChildrenIndexes = grandChildrenIndexes();
final Object[] indexes = new Object[childrenIndexes.length * grandChildrenIndexes.length];
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>7.7.0-SNAPSHOT</version>
<version>7.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -47,6 +47,8 @@ public class CppLanguageModule extends CpdOnlyLanguageModuleBase {
LanguagePropertyBundle bundle = super.newPropertyBundle();
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES);
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES);
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS);
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS);
bundle.definePropertyDescriptor(CPD_SKIP_BLOCKS);
return bundle;
}
@@ -9,8 +9,9 @@ import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.impl.CpdLexerBase;
import net.sourceforge.pmd.cpd.TokenFactory;
import net.sourceforge.pmd.cpd.impl.JavaCCTokenFilter;
import net.sourceforge.pmd.cpd.impl.JavaccCpdLexer;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
@@ -26,17 +27,21 @@ import net.sourceforge.pmd.lang.document.TextDocument;
*
* <p>Note: This class has been called CPPTokenizer in PMD 6</p>.
*/
public class CppCpdLexer extends CpdLexerBase<JavaccToken> {
public class CppCpdLexer extends JavaccCpdLexer {
private boolean skipBlocks;
private Pattern skipBlocksStart;
private Pattern skipBlocksEnd;
private final boolean ignoreIdentifierAndLiteralSeqences;
private final boolean ignoreLiteralSequences;
private final boolean ignoreLiterals;
private final boolean ignoreIdentifiers;
public CppCpdLexer(LanguagePropertyBundle cppProperties) {
ignoreLiteralSequences = cppProperties.getProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES);
ignoreIdentifierAndLiteralSeqences = cppProperties.getProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES);
ignoreLiterals = cppProperties.getProperty(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS);
ignoreIdentifiers = cppProperties.getProperty(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS);
String skipBlocksPattern = cppProperties.getProperty(CppLanguageModule.CPD_SKIP_BLOCKS);
if (StringUtils.isNotBlank(skipBlocksPattern)) {
skipBlocks = true;
@@ -73,6 +78,23 @@ public class CppCpdLexer extends CpdLexerBase<JavaccToken> {
return new CppTokenFilter(tokenManager, ignoreLiteralSequences, ignoreIdentifierAndLiteralSeqences);
}
@Override
protected void processToken(TokenFactory tokenEntries, JavaccToken currentToken) {
int kind = currentToken.getKind();
String image = currentToken.getImage();
boolean isLiteral = kind == CppTokenKinds.STRING || kind == CppTokenKinds.RSTRING || kind == CppTokenKinds.CHARACTER || kind == CppTokenKinds.DECIMAL_INT_LITERAL || kind == CppTokenKinds.HEXADECIMAL_INT_LITERAL || kind == CppTokenKinds.OCTAL_INT_LITERAL || kind == CppTokenKinds.FLOAT_LITERAL || kind == CppTokenKinds.BINARY_INT_LITERAL || kind == CppTokenKinds.ZERO;
if (ignoreLiterals && isLiteral) {
image = CppTokenKinds.describe(kind);
}
if (ignoreIdentifiers && (kind == CppTokenKinds.ID)) {
image = CppTokenKinds.describe(kind);
}
tokenEntries.recordToken(image, currentToken.getReportLocation());
}
private static class CppTokenFilter extends JavaCCTokenFilter {
private final boolean ignoreLiteralSequences;
@@ -59,6 +59,16 @@ class CppCpdLexerTest extends CpdTextComparisonTest {
doTest("specialComments");
}
@Test
void testIgnoreLiterals() {
doTest("ignoreLiterals", "", ignoreLiterals());
}
@Test
void testIgnoreIdents() {
doTest("ignoreIdents", "", ignoreIdents());
}
@Test
void testMultiLineMacros() {
doTest("multilineMacros");
@@ -142,7 +152,7 @@ class CppCpdLexerTest extends CpdTextComparisonTest {
}
private static LanguagePropertyConfig skipBlocks(String skipPattern) {
return properties(true, skipPattern, false, false);
return properties(true, skipPattern, false, false, false, false);
}
private static LanguagePropertyConfig skipBlocks() {
@@ -150,22 +160,31 @@ class CppCpdLexerTest extends CpdTextComparisonTest {
}
private static LanguagePropertyConfig dontSkipBlocks() {
return properties(false, null, false, false);
return properties(false, null, false, false, false, false);
}
private static LanguagePropertyConfig skipLiteralSequences() {
return properties(false, null, true, false);
return properties(false, null, true, false, false, false);
}
private static LanguagePropertyConfig skipIdentifierAndLiteralsSequences() {
return properties(false, null, true, true);
return properties(false, null, true, true, false, false);
}
private static LanguagePropertyConfig skipIdentifierSequences() {
return properties(false, null, false, true);
return properties(false, null, false, true, false, false);
}
private static LanguagePropertyConfig properties(boolean skipBlocks, String skipPattern, boolean skipLiteralSequences, boolean skipSequences) {
private static LanguagePropertyConfig ignoreIdents() {
return properties(false, null, false, false, false, true);
}
private static LanguagePropertyConfig ignoreLiterals() {
return properties(false, null, false, false, true, false);
}
private static LanguagePropertyConfig properties(boolean skipBlocks, String skipPattern, boolean skipLiteralSequences, boolean skipSequences, boolean ignoreLiterals, boolean ignoreIdents) {
return properties -> {
if (!skipBlocks) {
properties.setProperty(CppLanguageModule.CPD_SKIP_BLOCKS, "");
@@ -174,6 +193,8 @@ class CppCpdLexerTest extends CpdTextComparisonTest {
}
properties.setProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES, skipLiteralSequences);
properties.setProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES, skipSequences);
properties.setProperty(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS, ignoreLiterals);
properties.setProperty(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS, ignoreIdents);
};
}
}
Loaded 30 of 172 files, more files were not shown because too many files have changed in this diff. Show more