Skip to content

[java] Fix #6826: AssertEqualsArgumentOrder false positive for double/float delta - #6827

Merged
UncleOwen merged 2 commits into
pmd:mainfrom
dhalperi:copilot/fix-upstream-issue-6826
Jul 6, 2026
Merged

UncleOwen merged 2 commits into
pmd:mainfrom
dhalperi:copilot/fix-upstream-issue-6826

Conversation

@dhalperi

@dhalperi dhalperi commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Describe the PR

The wildcard assertEquals(_,_,_) matchers for org.junit.Assert and junit.framework.TestCase modeled the 3-arg form as (message?, expected, actual), so for the delta overload assertEquals(double expected, double actual, double delta) they read the delta as "actual" and flagged correctly-ordered calls.

Replace the wildcards with the forms actually in use: (String,_,_) and (String,_,_,_) for the message variants, (double,double,double) and (float,float,float) for the deltas. The message + delta form was not matched at all before, so a swap there went undetected.

Added a release-note entry under java-errorprone.

Related issues

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)

…ble/float delta

The wildcard assertEquals(_,_,_) matchers for org.junit.Assert and
junit.framework.TestCase modeled the 3-arg form as (message?, expected,
actual), so for the delta overload assertEquals(double expected, double
actual, double delta) they read the delta as "actual" and flagged
correctly-ordered calls.

Replace the wildcards with the forms actually in use: (String,_,_) and
(String,_,_,_) for the message variants, (double,double,double) and
(float,float,float) for the deltas. The message + delta form was not
matched at all before, so a swap there went undetected.

Fixes pmd#6826.
@dhalperi
dhalperi force-pushed the copilot/fix-upstream-issue-6826 branch from bb090d3 to 488c6a9 Compare June 30, 2026 03:53
@pmd-actions-helper

pmd-actions-helper Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-07-06 10:06:19+00:00 for 6215d44)

@zbynek zbynek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, looks good. Another thing I've missed when implementing this rule is JUnit Jupiter's assertEquals with 4 parameters (maybe we should just just generalize args for Jupiter to _* + add tests), but I can do that in a separate PR.

@UncleOwen UncleOwen added this to the 7.27.0 milestone Jul 6, 2026
@UncleOwen
UncleOwen merged commit 1e32029 into pmd:main Jul 6, 2026
13 checks passed
@UncleOwen

Copy link
Copy Markdown
Member

Thanks!

@dhalperi
dhalperi deleted the copilot/fix-upstream-issue-6826 branch July 6, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[java] AssertEqualsArgumentOrder: False positive for double assertEquals

3 participants