SONARJAVA-6706 Implement new rule S2330 - #5867
Conversation
|
❌ Ruling needs updating. A fix PR has been created: #5868 Please review and merge it into your branch. |
|
❌ Ruling needs updating. A fix PR has been created: #5868 Please review and merge it into your branch. |
Ruling Diff SummaryDetected changes in 5 rule files: 0 issues removed, 161 issues added. S2330 (
|
Detect array covariance where an array of a derived type is assigned to a variable declared as an array of its base type, which can lead to ArrayStoreException at runtime.
Cover varargs method invocations with covariant array arguments, including multiple vararg arguments, mixed varargs with regular parameters, and edge cases like no vararg arguments passed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
594a768 to
2648f82
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
❌ Ruling needs updating. A fix PR has been created: #5875 Please review and merge it into your branch. |
|
❌ Ruling needs updating. A fix PR has been created: #5875 Please review and merge it into your branch. |
|
❌ Ruling needs updating. A fix PR has been created: #5880 Please review and merge it into your branch. |
…n S2330 Handle LAMBDA_EXPRESSION nodes directly to detect covariant array returns in expression-bodied lambdas (e.g. `() -> new Apple[1]`), which were previously missed since they have no RETURN_STATEMENT node. For varargs, check the first argument against the whole array type first, falling back to element-type check only if no issue was reported. This prevents double-reporting when an array-of-arrays argument matches both the vararg type and its element type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
❌ Ruling needs updating. A fix PR has been created: #5880 Please review and merge it into your branch. |
Code Review ✅ Approved 2 resolved / 2 findingsImplements new rule S2330 to detect unsafe array covariance leading to potential ArrayStoreException at runtime. Addressed expression-bodied lambda handling and varargs double-reporting findings. ✅ 2 resolved✅ Edge Case: Expression-bodied lambdas escape covariance detection
✅ Edge Case: First vararg argument is checked twice in visitInvocation
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 |
|




Detect array covariance where an array of a derived type is assigned to a variable declared as an array of its base type, which can lead to ArrayStoreException at runtime.