Repository navigation
SONARJAVA-7188 SONARJAVA-4606 Improvements for the rule S7158 - #6359
asya-vorobeva wants to merge 3 commits into
Conversation
LiteralUtils.isZero compared the literal's decimal token text, so length() == 0 was flagged but the equivalent length() == 0x0, 00 or 0b0 was not. Compare the parsed literal value instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…risons Comparing "s.trim().length()" to zero is a blankness check, so report it with an "isBlank()" message and quick fix instead of "isEmpty()". Gated on Java 11, where "String.isBlank()" was introduced. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… comparisons "strip()" removes exactly the characters "isBlank()" treats as white space, so the rewrite is equivalent. "trim()" removes every character up to U+0020 instead, so it disagrees on control characters below U+0020 and on Unicode white space above it; those cases keep the suggestion but the issue message and the quick-fix label state what the replacement changes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Code Review ✅ Approved 1 closed / 1 findings🟡 Medium risk · Expanding zero-literal detection and suggesting isBlank() quick fixes changes analyzer findings; trim() replacements could alter behavior for control characters and Unicode whitespace. Improves rule S7158 to detect zero literals written in any base and to suggest ✅ 1 closedClosed: Cross-PR: S7158 and S9432 both flag trim().length() with conflicting advice
Verification Rules 1/1 met Repos 3 inspected · PRs 1 inspectedFunctional validation No results Rules 1 passed 2 not applicable
Broader impact Repos 3 inspected PRs 1 inspectedCross-repo 3 repositories inspected 0 open impacts
Cross-PR 1 PR inspected 0 open impactsAuto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|




Uh oh!
There was an error while loading. Please reload this page.