Skip to content

Conversation

@zbynek
Copy link
Contributor

@zbynek zbynek commented Oct 9, 2025

Describe the PR

The unused variable rule should also inspect patterns. With Java 22 enforce using _ where possible, with Java 21 accept named variables when the whole type pattern cannot be removed.

Related issues

  • Fix #

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@zbynek zbynek marked this pull request as draft October 9, 2025 01:46
@zbynek zbynek changed the title Unused pattern [java] UnusedLocalVariable: fix false negatives in pattern matching Oct 9, 2025
@pmd-actions-helper
Copy link
Contributor

pmd-actions-helper bot commented Oct 9, 2025

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 125 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.

Regression Tester Report

(comment created at 2025-10-10 21:33:37+00:00 for e6a0b66)

Copy link
Member

@oowekyala oowekyala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zbynek Is there is a reason this is still a draft?

@zbynek zbynek marked this pull request as ready for review October 18, 2025 10:39
@oowekyala oowekyala added this to the 7.18.0 milestone Oct 19, 2025
@oowekyala oowekyala added the a:false-negative PMD doesn't flag a problematic piece of code label Oct 19, 2025
@oowekyala oowekyala self-assigned this Oct 19, 2025
@oowekyala oowekyala merged commit c3df003 into pmd:main Oct 19, 2025
12 checks passed
oowekyala added a commit that referenced this pull request Oct 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a:false-negative PMD doesn't flag a problematic piece of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants