Repository navigation
SONARJAVA-7155: Implemented rule S9433 Literals should not be converted to strings using empty string concatenation - #6364
romainbrenguier wants to merge 5 commits into
Conversation
…ed to strings using empty string concatenation Detects primitive literals converted to strings by direct concatenation with an empty string literal and recommends an explicit conversion.
ba6bc1c to
df471ca
Compare
This comment has been minimized.
This comment has been minimized.
…L header Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…annotation defaults Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Code Review ✅ Approved 4 closed / 4 findings🟡 Medium risk · Adding S9433 flags primitive-literal empty-string concatenations; incorrect constant-context detection could produce noisy or missed findings. Adds rule S9433 to flag primitive literals converted to strings via empty string concatenation, recommending an explicit conversion instead. Annotation element defaults and constant contexts are now handled correctly, with the constant-context false positives resolved. No open issues remain. ✅ 4 closed✅ Edge Case: Annotation element default values still flagged, though they must be constants
✅ Edge Case: Any expression inside a static final initializer is suppressed
Closed: Edge Case: Flags compile-time constant contexts where the suggested fix won't compile
Closed: Quality: Test sample has an outdated LGPL license header unlike every other sample
Verification Rules 1/1 met Repos 3 inspectedFunctional validation No results Rules 1 passed 2 not applicable
Broader impact Repos 3 inspectedCross-repo 3 repositories inspected 0 open impacts
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 |
|




Detects primitive literals converted to strings by direct concatenation with an empty string literal, and recommends an explicit conversion.
Agent workflow
PR created using
uv run new_rule_implementation.py S9433 -j SONARJAVA-7155 -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 /tmp/action_plan_romain/new-rule-s9433-sonarjava-7155.txt." -a "/tmp/action_plan_romain/new-rule-s9433-sonarjava-7155.txt" -g "claude"PR updated using
uv run update_with_claude.py --prompt "Implement the action plan described in the document /tmp/action_plan_romain/new-rule-s9433-sonarjava-7155.txt." -a "/tmp/action_plan_romain/new-rule-s9433-sonarjava-7155.txt" -g "claude"Iterated on the PR with
uv run ci_loop.pyfor 2 iterations.✔️ The PR is now ready for review.