Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
|
⚖️ Ruling update ready for review: #6355 |
Ruling Diff SummaryDetected changes in 1 rule files: 0 issues removed, 3 issues added. S9435 (
|
Code Review ✅ Approved🟡 Medium risk · Adding S9435 flags negated ternary conditions in analyzed projects, which could introduce new issues and affect quality-gate results. Adds rule S9435 to flag ternary expressions whose top-level condition is negated ( Verification Repos 3 inspectedFunctional validation No results Rules No rules evaluated Cross-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 |
|
|
/pvf |
|
📊 Performance Validation complete |
|
📊 Performance Validation complete |
|
📊 Performance Validation complete |




Implements rule S9435, which raises on a ternary expression whose condition is negated (
!xorx != y), since the reader has to invert the condition mentally before pairing each result with the case it belongs to.Null checks are exempt:
value != null ? value.name() : "unknown"reads naturally as a positive guard, and so does its long form!(value == null). Only the top-level condition is considered, sovalue != null && count != 0 ? ... : ...does not raise.ifstatements are out of scope by design, as decided on the RSPEC.RSPEC: https://github.com/SonarSource/rspec/pull/8337 (branch
rule/add-RSPEC-S9435, not merged yet)Jira: https://sonarsource.atlassian.net/browse/SONARJAVA-7162