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

Make button bindings more concise #168

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from

Conversation

katzuv
Copy link
Member

@katzuv katzuv commented Feb 9, 2025

And other small changes.
I DIDN'T TEST THIS (because my computer is a potato) SO PLEASE CHECK THE CODE. Thanks :)

  • Refactor button bindings to be more concise
  • Remove unneeded PathPlanner command setting function
  • Remove unused variable
  • Remove unneeded requirement
  • Remove unneeded variables for subsystem
  • Remove redundant newline
  • Combine visualizer instantiation with declaration
  • Add braces to if statement
  • Replace variables with imports
  • Fix LoggedPowerDistribution module type
  • IntelliJ IDEA Reformat + Spotless

@katzuv katzuv added the enhancement New feature or request label Feb 9, 2025
@katzuv katzuv self-assigned this Feb 9, 2025
@katzuv katzuv requested review from Emma03L and rakrakon February 9, 2025 11:54
Copy link

github-actions bot commented Feb 9, 2025

Qodana Community for JVM

239 new problems were found

Inspection name Severity Problems
Unused symbol 🔶 Warning 129
Unnecessary modifier 🔶 Warning 22
Constant conditions 🔶 Warning 6
Field can be local 🔶 Warning 5
Unnecessary conversion to 'String' 🔶 Warning 5
Unused receiver parameter 🔶 Warning 4
Declaration has problems in Javadoc references 🔶 Warning 3
Unresolved reference in KDoc 🔶 Warning 3
Field may be 'final' 🔶 Warning 2
Busy wait 🔶 Warning 1
Infinite loop statement 🔶 Warning 1
Main function should return 'Unit' 🔶 Warning 1
Mismatched read and write of array 🔶 Warning 1
'size() == 0' can be replaced with 'isEmpty()' 🔶 Warning 1
Call to 'printStackTrace()' 🔶 Warning 1
Unused import 🔶 Warning 1
Class member can have 'private' visibility ◽️ Notice 24
Lambda argument inside parentheses ◽️ Notice 13
Constant values ◽️ Notice 12
Might be 'const' ◽️ Notice 2
Commented out code ◽️ Notice 1
Method can be extracted ◽️ Notice 1

☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

Copy link
Contributor

@Emma03L Emma03L left a comment

Choose a reason for hiding this comment

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

Looks great! But a bit unreadable

operatorController
.povUp()
.onTrue(extender.reset(operatorController.povUp().negate()))
driverController.apply {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is less readable and makes it harder to switch buttons between controllers

Copy link
Member Author

@katzuv katzuv Feb 9, 2025

Choose a reason for hiding this comment

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

Perhaps it's for the better, otherwise there's more chance for errors. The biggest improvement here is that you don't need to write the button twice (the negate part is done for you).
It won't be hard to switch buttons, you just need to remove one line and add another in the second section. You can refactor the mapping into a constant/function if you'd like.
IMO the previous code too verbose, and it was easy to miss stuff in all the boilerplate.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like not having to write the negate but I still think this is less readable, maybe an extension function could be good.

Copy link
Member Author

Choose a reason for hiding this comment

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

What would that exentsion function look like?
What exactly about the code looks unreadable?
@rakrakon, what is your opinion?

Copy link
Contributor

@rakrakon rakrakon Feb 11, 2025

Choose a reason for hiding this comment

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

First of all I agree with Emma about the readability. As for the code duplication I think our best option is to do something like this:

driverController.circle().run {
    onTrue(l3(negate()))
}

Copy link
Member Author

Choose a reason for hiding this comment

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

If anything, I think that using the negate without the object is less readable than not specifying the controller. My concern is that because the controller name is written so many times we will glance over the code and miss important things.
I don't really see how not specifying the controller hinders readability. What do you think about extracting the code for each controller into its own function

In any case, I don't think I'm going to add code to this branch so you can just push your suggestion and then we'll see how it looks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants