You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] CheckResultSet: False positive for rs.next() ? x : y #7063
Note that this rule is a more complicated case than UnusedReturnValue. It's not really about rs.next() either. It's about what you're allowed to do afterwards.
There's one set of functions (rs.next(), rs.previous(), rs.first(), rs.last(), rs.absolute(), rs.relative()) that move the cursor. The return values of these functions tell you whether you're allowed to use rs.getRow(), rs.getInt(), etc. at the new position. If the return value is true you are allowed, if it's false (or before moving the cursor at all), you're not allowed. That's what this rule is (or at least should be) about.
(There's also rs.beforeFirst() and rs.beforeLast() that always move the cursor into an invalid position, functions that query the current position, etc. - but before we think about those we should get the basics I outlined above correct.)
changed the title [-][java] ResultSet.next() ? x : y fires CheckResultSet[/-][+][java] CheckResultSet: FalsePositive for rs.next() ? x : y[/+]on Sep 13, 2026
changed the title [-][java] CheckResultSet: FalsePositive for rs.next() ? x : y[/-][+][java] CheckResultSet: False positive for rs.next() ? x : y[/+]on Sep 13, 2026
Activity
UncleOwen commentedon Sep 12, 2026
Yes, that rule needs an overhaul. See also #5031 and #5209
[-][java] rs.next() ? x : y fires CheckResultSet[/-][+][java] ResultSet.next() ? x : y fires CheckResultSet[/+]UncleOwen commentedon Sep 12, 2026
Note that this rule is a more complicated case than UnusedReturnValue. It's not really about rs.next() either. It's about what you're allowed to do afterwards.
There's one set of functions (rs.next(), rs.previous(), rs.first(), rs.last(), rs.absolute(), rs.relative()) that move the cursor. The return values of these functions tell you whether you're allowed to use rs.getRow(), rs.getInt(), etc. at the new position. If the return value is true you are allowed, if it's false (or before moving the cursor at all), you're not allowed. That's what this rule is (or at least should be) about.
(There's also rs.beforeFirst() and rs.beforeLast() that always move the cursor into an invalid position, functions that query the current position, etc. - but before we think about those we should get the basics I outlined above correct.)
fabian-hahn commentedon Sep 12, 2026
Thanks, @UncleOwen for the fast reply.
Hmm, I do not completely understand.
A works just fine. B flags a violation. Shouldn't they behave the same?
UncleOwen commentedon Sep 12, 2026
Yes, they should behave the same. What I'm saying is, that in my opinion that rule has deeper issues than that.
[-][java] ResultSet.next() ? x : y fires CheckResultSet[/-][+][java] CheckResultSet: FalsePositive for rs.next() ? x : y[/+][-][java] CheckResultSet: FalsePositive for rs.next() ? x : y[/-][+][java] CheckResultSet: False positive for rs.next() ? x : y[/+][java] Fix pmd#7063: CheckResultSet false positive with next() as ter…
[java] Fix pmd#7063: CheckResultSet false positive with next() as ter…
[java] Fix pmd#7063: CheckResultSet false positive with next() as ter…
[java] Fix #7063: CheckResultSet false positive with next() as ternar…