Avoid negating the result of compareTo() - #8166
Conversation
It is unsafe to negate the result of `compareTo`, as negating the result can overflow if `compareTo()` returns `Integer.MIN_VALUE`.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe Suggested reviewers: Priority: ⬇️ Low Change: Bug fix Merge Risk: ⚪ Minimal · up to This small change preserves insertion sorting behavior and avoids compareTo overflow risk, so it is ready to merge. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
It is unsafe to negate the result of
compareTo, as negating the result can overflow ifcompareTo()returnsInteger.MIN_VALUE.