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

[commands] Update requirements consistently #6304

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

spacey-sooty
Copy link
Contributor

Resolves #6291

@spacey-sooty spacey-sooty requested a review from a team as a code owner January 24, 2024 05:41
@spacey-sooty
Copy link
Contributor Author

This doesn't update everywhere because in many places for example ParralelRaceGroup the class uses getRequirements() which returns a Set which cannot be passed into addRequirements directly. We could loop over them but I'm not sure if that's something we want to do

@Starlight220
Copy link
Member

Starlight220 commented Jan 24, 2024

Is it feasible to add an addRequirements(Collection) (or maybe take a Set) overload for those cases?

@spacey-sooty
Copy link
Contributor Author

Is it feasible to add an addRequirements(Collection) (or maybe take a Set) overload for those cases?

I would say probably as it's already a for loop iterating through items so it'd just be the same pretty much

@KangarooKoala
Copy link
Contributor

Would it be reasonable to change Command.m_requirements to private instead of protected after this? (Potentially in a separate PR)

@spacey-sooty
Copy link
Contributor Author

If we add an overload this seems like a reasonable change. It'd be a long term fix for the inconsistency as well so might still be fine in this pr?

@spacey-sooty spacey-sooty changed the title [command based] Update requirements consistently [commands] Update requirements consistently May 11, 2024
@spacey-sooty
Copy link
Contributor Author

/format

@KangarooKoala
Copy link
Contributor

PMD in the Java format CI is actually complaining that m_requirements could be made final. Was there a particular reason to make it non-final?

@PeterJohnson PeterJohnson requested review from PeterJohnson and a team as code owners May 19, 2024 15:53
@spacey-sooty
Copy link
Contributor Author

PMD in the Java format CI is actually complaining that m_requirements could be made final. Was there a particular reason to make it non-final?

There is no guarantee if addRequirements being called in the constructor only. Making it final would make that guarantee which seems like a reasonable change to me, but technically a breaking change.

@spacey-sooty spacey-sooty force-pushed the fix-inconsistent-req branch 2 times, most recently from 78b685c to c9b9b7f Compare May 20, 2024 01:23
@KangarooKoala
Copy link
Contributor

PMD in the Java format CI is actually complaining that m_requirements could be made final. Was there a particular reason to make it non-final?

There is no guarantee if addRequirements being called in the constructor only. Making it final would make that guarantee which seems like a reasonable change to me, but technically a breaking change.

final just indicates that the variable can't be changed to refer to a different object, the object can still be mutated (such as adding new members).

final Set<Integer> x = new HashSet<>();
x.add(0); // This is fine
x = Set.of(1); // This is illegal

@spacey-sooty
Copy link
Contributor Author

PMD in the Java format CI is actually complaining that m_requirements could be made final. Was there a particular reason to make it non-final?

There is no guarantee if addRequirements being called in the constructor only. Making it final would make that guarantee which seems like a reasonable change to me, but technically a breaking change.

final just indicates that the variable can't be changed to refer to a different object, the object can still be mutated (such as adding new members).

final Set<Integer> x = new HashSet<>();
x.add(0); // This is fine
x = Set.of(1); // This is illegal

Ahhhh my misunderstanding its the equivalent of the const keyword in C++ that makes sense

@spacey-sooty
Copy link
Contributor Author

Flaky test 😢

@spacey-sooty spacey-sooty force-pushed the fix-inconsistent-req branch 4 times, most recently from e331b4c to 789c27d Compare June 23, 2024 12:02
spacey-sooty added a commit to spacey-sooty/allwpilib that referenced this pull request Jun 23, 2024
@spacey-sooty
Copy link
Contributor Author

Not required for python as it never had this problem

Starlight220
Starlight220 previously approved these changes Jun 23, 2024
spacey-sooty added a commit to spacey-sooty/allwpilib that referenced this pull request Jun 30, 2024
spacey-sooty added a commit to spacey-sooty/allwpilib that referenced this pull request Jul 1, 2024
spacey-sooty added a commit to spacey-sooty/allwpilib that referenced this pull request Jul 6, 2024
spacey-sooty added a commit to spacey-sooty/allwpilib that referenced this pull request Jul 6, 2024
@PeterJohnson PeterJohnson merged commit 9671055 into wpilibsuite:main Jul 11, 2024
33 checks passed
spacey-sooty added a commit to spacey-sooty/allwpilib that referenced this pull request Jul 12, 2024
@spacey-sooty spacey-sooty deleted the fix-inconsistent-req branch July 12, 2024 13:54
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.

Commands update requirements inconsistently
4 participants