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

style: format code with Ktlint #7

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/main/java/frc/robot/RobotContainer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import edu.wpi.first.math.geometry.Rotation2d
import edu.wpi.first.math.geometry.Translation2d
import edu.wpi.first.wpilibj.DriverStation
import edu.wpi.first.wpilibj.RobotBase
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard
import edu.wpi.first.wpilibj2.command.Command
Expand All @@ -37,7 +36,7 @@

private val controlChooser: SendableChooser<String> = SendableChooser()
private val controlChooserLogger: LoggedDashboardChooser<String>

private val speedChooser: SendableChooser<Double> = SendableChooser()
private val speedChooserLogger: LoggedDashboardChooser<Double>
private var MaxSpeed: Double = TunerConstants.kSpeedAt12VoltsMps // Initial max is true top speed
Expand Down Expand Up @@ -127,7 +126,7 @@
val controlPick = Trigger { lastControl !== controlChooserLogger.get() }
controlPick.onTrue(Commands.runOnce({ newControlStyle() }))

val speedPick = Trigger { lastSpeed !== try { speedChooserLogger.get()!! } catch (e: Throwable) {0.65} }
val speedPick = Trigger { lastSpeed !== try { speedChooserLogger.get()!! } catch (e: Throwable) { 0.65 } }

Check warning

Code scanning / detekt

Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled. Warning

Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.

Check warning

Code scanning / detekt

Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning

This expression contains a magic number. Consider defining it to a well named constant.
speedPick.onTrue(Commands.runOnce({ newSpeed() }))

drv.x().and(drv.pov(0)).whileTrue(drivetrain.runDriveQuasiTest(SysIdRoutine.Direction.kForward))
Expand Down Expand Up @@ -184,7 +183,7 @@
autoChooser.get()

private fun newControlStyle() {
lastControl = if(controlChooserLogger.get() != null) controlChooserLogger.get() else "2 Joysticks"
lastControl = if (controlChooserLogger.get() != null) controlChooserLogger.get() else "2 Joysticks"
when (controlChooserLogger.get()) {
"2 Joysticks" -> controlStyle = Supplier<SwerveRequest?> {
drive.withVelocityX(-drv.leftY * MaxSpeed) // Drive forward -Y
Expand Down
Loading