SONARJAVA-6951: Implemented rule S9390 - Manual null checks should be replaced with Objects.equals() - #6123
Conversation
… replaced with Objects.equals()
|
🔗 Commit SHA: 7f1356b | Docs | View more details | Give us feedback! |
- Add missing field `d` in test sample to fix compilation - Add rule metadata files (S9390.json, S9390.html) and Sonar way profile - Use syntactic method name lookup to fix rule not firing without semantics - Guard against overloaded equals(SpecificType) methods to prevent false positives - Remove duplicated null-comparison logic in matchesPattern Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
✅ Code review updated (blocking issues remain unresolved).
|
❌ Ruling needs updating. A fix PR has been created: #6132 Please review and merge it into your branch. |
Simplify boolean return in matchesPattern to fix SonarQube code smell, add test cases to improve coverage above 90%, and add ruling baseline for sonar-server findings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Ruling Diff SummaryDetected changes in 1 rule files: 0 issues removed, 2 issues added. S9390 (
|
Use // prefix for caret lines, remove [[sc;ec]] annotations, and correct marker alignment to match actual reported issue locations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Code Review ✅ Approved 5 resolved / 5 findingsImplements rule S9390 to detect manual null checks that should use ✅ 5 resolved✅ Bug: Rule never fires without semantics: methodSymbol().name() is unknown
✅ Bug: Sample file does not compile: undeclared identifier
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
|




Implements rule S9390 which detects ternary expressions performing redundant null-safe equality checks.
The pattern is semantically equivalent to but more verbose and error-prone.
Changes:
The rule detects:
Accepted false negatives: