Skip to content

Remove always-false array-length check in ForgeRockTestListener#297

Open
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix/constant-comparison-testlistener
Open

Remove always-false array-length check in ForgeRockTestListener#297
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix/constant-comparison-testlistener

Conversation

@vharseko

Copy link
Copy Markdown
Member

Summary

Fixes a CodeQL java/constant-comparison alert ("Useless comparison test / Test is always false") in ForgeRockTestListener.checkForInterleavedBetweenClasses.

The method wrapped a single ITestNGMethod.getInstance() value into a one-element array literal and then tested testInstances.length != 1 — a condition that can never be true, so the guard was dead code (likely a leftover from an earlier getInstances() array API).

Change

  • Use the single test instance directly.
  • Drop the useless one-element array allocation and the always-false length comparison.

No behavior change: the length guard never protected anything since the array always had exactly one element.

Closes code scanning alert #2089.

checkForInterleavedBetweenClasses wrapped a single ITestNGMethod.getInstance()
value into a one-element array and then tested testInstances.length != 1, a
condition that is always false (dead branch flagged by CodeQL
java/constant-comparison). Use the single test instance directly and drop the
useless array allocation and comparison.
@vharseko
vharseko requested a review from maximthomas July 22, 2026 14:10
@vharseko vharseko added codeql CodeQL static-analysis findings refactoring Code cleanup / refactoring, no behavior change labels Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codeql CodeQL static-analysis findings refactoring Code cleanup / refactoring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants