Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make SortedList#add return value adhere to List contract #6049

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

CoreRasurae
Copy link
Contributor

Copy link
Collaborator

@SirYwell SirYwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor thing, other than that, please make sure your PR title follows our guidelines (https://github.com/INRIA/spoon/blob/master/CONTRIBUTING.md#guidelines-for-pull-requests). Thanks!

for (E e : c) {
ret &= add(e);
ret |= add(e);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we'll always return true this way (because add always returns true), we can probably also just return !c.isEmpty() (assuming c doesn't get modified in between) or just do ret = true, similar to the default implementation in AbstractList. What do you think? (Seems like the Qodana inspection is a bit aggressive here...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qodana is right i didn't notice it was using bit-wise operations instead of logical operations i have fixed that now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope the PR title is okay now

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code before was fine, I definitely prefer it over the short-circuit solution now. I mainly suggested the alternatives because Qodana complained, but I still think the inspection is not helpful in such case at all.

I hope the PR title is okay now

Please give it a short description of what is addressed, so we can use it as commit message when merging (e.g. fix: address SortedList#addAll(...) contract violation). Also, please additionally prefix the title with review: given the PR is ready for review.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i hope that the title is okay now... trying to follow the procedures that indicate that fic and the number of the issue needs to be present too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use one of my suggested variants or your initial version instead of the ||. The title is fine now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, i've reverted the change to use bit-wise logic again.

@CoreRasurae CoreRasurae changed the title Fix SortedList.addAll(...) to be JLS/API compliant and provide unit tests fix: #6034 Oct 29, 2024
@CoreRasurae CoreRasurae changed the title fix: #6034 review: fix: address SortedList#addAll(...) contract violation, fix #6034 Oct 30, 2024
…ests (Fixes INRIA#6034)

SortedList.addAll(...) should return a boolean value indicating if the Collection was modified is any way as a result of the call
@CoreRasurae
Copy link
Contributor Author

I am unable to merge... The base branch restricts merging to authorized users.

@algomaster99
Copy link
Contributor

@CoreRasurae Qodana still fails. Could you take a look? @SirYwell would merge afterwards.

@SirYwell SirYwell changed the title review: fix: address SortedList#addAll(...) contract violation, fix #6034 fix: Make SortedList#add return value adhere to List contract Nov 15, 2024
@SirYwell SirYwell merged commit 5f250ea into INRIA:master Nov 15, 2024
12 of 13 checks passed
@SirYwell
Copy link
Collaborator

@CoreRasurae Qodana still fails. Could you take a look? @SirYwell would merge afterwards.

The Qodana problem is basically a false positive. A short-circuit operation isn't intuitive there at all imho.

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.

[Bug]: spoon.support.util.SortedList.addAll(...) return value is not JLS compliant
3 participants