Repository navigation
SONARJAVA-7157: Implemented rule S9432 Strings should not be trimmed or stripped just to check if they are blank - #6332
romainbrenguier wants to merge 7 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
|
⚖️ Ruling update ready for review: #6334 |
trim() removes characters <= U+0020 while isBlank() relies on Character.isWhitespace, so replacing a trim()-based check by isBlank() is only equivalent if Unicode whitespace should count as blank and control characters as non-blank. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
⚖️ Ruling update ready for review: #6334 |
Ruling Diff SummaryDetected changes in 2 rule files: 0 issues removed, 6 issues added. S9432 (
|
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
⚖️ Ruling update ready for review: #6345 |
Code Review ✅ Approved 1 closed / 1 findings🟡 Medium risk · Adding S9432 findings for trim()/strip() blankness checks could produce false positives or prompt replacements with different whitespace semantics. Adds rule S9432 for direct ✅ 1 closed✅ Bug: trim()-based checks are not equivalent to isBlank(); suggested fix changes behavior
Verification Rules 1/1 met Repos 8 inspectedFunctional validation No results Rules 1 passed 2 not applicable
Broader impact Repos 8 inspectedCross-repo 8 repositories inspected 0 open impacts
3 more repositories Auto-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 |
|
|
Closed due to decision raise such issues in the existing rule #6359 |




Detects direct String trim() or strip() call chains used only for blankness checks, including isEmpty(), isBlank(), and zero/one length comparisons.
Agent workflow
PR created using
uv run new_rule_implementation.py S9432 -j SONARJAVA-7157 -a codex -g AGENTS.md .claude/skills/new-rule/SKILL.mdTool link: https://github.com/SonarSource/languages-experimental-tooling/tree/romain/my-tickets/personal/romain-brenguier
PR updated using
uv run update_with_claude.py --prompt "Implement the action plan described in the document Change the error message, so that in the case of trim().isBlank(), we suggest isBlank but says that it is if we want to treat unicode spaces as blank and control characters as non-blank.." -a "Change the error message, so that in the case of trim().isBlank(), we suggest isBlank but says that it is if we want to treat unicode spaces as blank and control characters as non-blank." -g "claude"