Product: SonarQube Community Build 26.7.0.124771
Type: false negative.
Explanation (expected vs actual): S1488 flags a local declared only to be immediately returned. Splitting the declaration-with-initializer into a declaration plus a single immediate assignment is behaviour-identical, the temporary is still write-once and returned on the next statement, and the rule’s prescribed fix (return in.read();) still applies verbatim — but the checker only matches declaration-with-initializer immediately followed by return, so the split form goes silent.
class ReturnTemp {
int read(java.io.InputStream in) throws java.io.IOException {
int c = in.read(); // Noncompliant — S1488 reported (baseline)
return c;
}
}
Variant — not reported (same valueless temporary):
class ReturnTemp {
int read(java.io.InputStream in) throws java.io.IOException {
int c;
c = in.read(); // same temp, now split; no S1488
return c;
}
}