Skip to content

Avoid negating the result of compareTo() - #8166

Open
kluever wants to merge 1 commit into
typetools:masterfrom
kluever:patch-1
Open

Avoid negating the result of compareTo()#8166
kluever wants to merge 1 commit into
typetools:masterfrom
kluever:patch-1

Conversation

@kluever

@kluever kluever commented Sep 14, 2026

Copy link
Copy Markdown

It is unsafe to negate the result of compareTo, as negating the result can overflow if compareTo() returns Integer.MIN_VALUE.

It is unsafe to negate the result of `compareTo`, as negating the result can overflow if `compareTo()` returns `Integer.MIN_VALUE`.
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: b5a9e0df-dce0-41a5-923c-ee925ca7d455

📥 Commits

Reviewing files that changed from the base of the PR and between 183c482 and 8b58fc0.

📒 Files selected for processing (1)
  • annotation-file-utilities/src/main/java/org/checkerframework/afu/annotator/Main.java

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The insertionSorter comparison now uses i2.getText().compareTo(i1.getText()) directly. The reverse sorting behavior remains unchanged.

Suggested reviewers: mernst

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 8b58f

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)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant