SONARJAVA-6759: Avoid overlap between S1244 and S9147 for NaN comparisons - #5937
SONARJAVA-6759: Avoid overlap between S1244 and S9147 for NaN comparisons#5937romainbrenguier wants to merge 5 commits into
Conversation
…sons S1244 no longer raises issues when a float/double is compared to Double.NaN or Float.NaN, since this case is already covered by S9147. Also adds S1244 as a related rule in the S9147 Rspec. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…coverage Move duplicated NaN detection logic from FloatEqualityCheck and NanEqualityCheck into ExpressionUtils.getNanOwnerTypeName(), and add additional test cases for Float.NaN parenthesized and self-comparison patterns to improve coverage on new code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e gate Add comprehensive tests for ExpressionUtils.getNanOwnerTypeName() covering all branches: member select (Double.NaN, Float.NaN), static imports, parenthesized expressions, unknown symbols, and non-NaN expressions. Also extend FloatEquality test sample with edge cases for non-NaN member selects and cross-type NaN comparisons. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rTypeName edge cases Cover lines 417 (identifier not named NaN), 431 (null owner/type), and 437 (owner type not Double/Float) in ExpressionUtils to fix coverage gate. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…uality Gate Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Code Review ✅ Approved 1 resolved / 1 findingsExtracts shared NaN detection logic to prevent rule overlap between S1244 and S9147, addressing the NaN detection logic duplication finding. No issues found. ✅ 1 resolved✅ Quality: NaN detection logic duplicated across S1244 and S9147
Implementation Status ✅ 1 / 1 issues implemented✅ SONARJAVA-6759 — 2 / 2 objectivesThe PR successfully updates FloatEqualityCheck (S1244) to avoid raising on NaN comparisons and marks S9147 as related to S1244 in the Rspec. ✅ 2 complete
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 |
|




Summary
FloatEqualityCheck) no longer raises issues when a float/double is compared toDouble.NaNorFloat.NaN, since this case is already covered by S9147 (NanEqualityCheck)See rspec PR: https://github.com/SonarSource/rspec/pull/7904
FloatEquality.javato verify NaN comparisons are compliant for S1244Test plan
FloatEqualityCheckTestpasses (both with and without semantic analysis)NanEqualityCheckTestpasses (unchanged)🤖 Generated with Claude Code