From cd4306ebb9888e97b75ad0c75591009d50de745c Mon Sep 17 00:00:00 2001 From: Jade Turner Date: Fri, 13 Sep 2024 11:56:25 +0800 Subject: [PATCH 1/6] [commands] Add a warning to `schedule` javadocs --- .../edu/wpi/first/wpilibj2/command/CommandScheduler.java | 4 ++++ .../main/native/include/frc2/command/CommandScheduler.h | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java index 0e80a74c613..1a9b25dcfad 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java @@ -180,6 +180,8 @@ private void initCommand(Command command, Set requirements) { * using those requirements have been scheduled as interruptible. If this is the case, they will * be interrupted and the command will be scheduled. * + * WARNING: using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands. + * * @param command the command to schedule. If null, no-op. */ private void schedule(Command command) { @@ -230,6 +232,8 @@ private void schedule(Command command) { /** * Schedules multiple commands for execution. Does nothing for commands already scheduled. * + * WARNING: using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands. + * * @param commands the commands to schedule. No-op on null. */ public void schedule(Command... commands) { diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h index 2f43ff7bc2e..a00011dcc5c 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h @@ -24,7 +24,6 @@ namespace frc2 { class Command; class CommandPtr; class Subsystem; - /** * The scheduler responsible for running Commands. A Command-based robot should * call Run() on the singleton instance in its periodic block in order to run @@ -88,6 +87,8 @@ class CommandScheduler final : public wpi::Sendable, * interruptible. If this is the case, they will be interrupted and the * command will be scheduled. * + * @warning Using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands. + * * @param command the command to schedule */ void Schedule(const CommandPtr& command); @@ -112,6 +113,8 @@ class CommandScheduler final : public wpi::Sendable, * * The pointer must remain valid through the entire lifecycle of the command. * + * @warning Using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands. + * * @param command the command to schedule */ void Schedule(Command* command); @@ -120,6 +123,8 @@ class CommandScheduler final : public wpi::Sendable, * Schedules multiple commands for execution. Does nothing for commands * already scheduled. * + * @warning Using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands. + * * @param commands the commands to schedule */ void Schedule(std::span commands); @@ -128,6 +133,8 @@ class CommandScheduler final : public wpi::Sendable, * Schedules multiple commands for execution. Does nothing for commands * already scheduled. * + * @warning Using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands. + * * @param commands the commands to schedule */ void Schedule(std::initializer_list commands); From 34b4b95e561397979d123204ca597a424ba2b020 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 02:38:41 +0000 Subject: [PATCH 2/6] Formatting fixes --- .../wpi/first/wpilibj2/command/CommandScheduler.java | 6 ++++-- .../native/include/frc2/command/CommandScheduler.h | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java index 1a9b25dcfad..74380724a54 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java @@ -180,7 +180,8 @@ private void initCommand(Command command, Set requirements) { * using those requirements have been scheduled as interruptible. If this is the case, they will * be interrupted and the command will be scheduled. * - * WARNING: using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands. + *

WARNING: using this function directly is often a footgun and should be avoided. Instead + * Triggers should be used to schedule Commands. * * @param command the command to schedule. If null, no-op. */ @@ -232,7 +233,8 @@ private void schedule(Command command) { /** * Schedules multiple commands for execution. Does nothing for commands already scheduled. * - * WARNING: using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands. + *

WARNING: using this function directly is often a footgun and should be avoided. Instead + * Triggers should be used to schedule Commands. * * @param commands the commands to schedule. No-op on null. */ diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h index a00011dcc5c..7572faba828 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h @@ -87,7 +87,8 @@ class CommandScheduler final : public wpi::Sendable, * interruptible. If this is the case, they will be interrupted and the * command will be scheduled. * - * @warning Using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands. + * @warning Using this function directly is often a footgun and should be + * avoided. Instead Triggers should be used to schedule Commands. * * @param command the command to schedule */ @@ -113,7 +114,8 @@ class CommandScheduler final : public wpi::Sendable, * * The pointer must remain valid through the entire lifecycle of the command. * - * @warning Using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands. + * @warning Using this function directly is often a footgun and should be + * avoided. Instead Triggers should be used to schedule Commands. * * @param command the command to schedule */ @@ -123,7 +125,8 @@ class CommandScheduler final : public wpi::Sendable, * Schedules multiple commands for execution. Does nothing for commands * already scheduled. * - * @warning Using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands. + * @warning Using this function directly is often a footgun and should be + * avoided. Instead Triggers should be used to schedule Commands. * * @param commands the commands to schedule */ @@ -133,7 +136,8 @@ class CommandScheduler final : public wpi::Sendable, * Schedules multiple commands for execution. Does nothing for commands * already scheduled. * - * @warning Using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands. + * @warning Using this function directly is often a footgun and should be + * avoided. Instead Triggers should be used to schedule Commands. * * @param commands the commands to schedule */ From 2613107be07e184452cc1317a8c95d7e70eadbae Mon Sep 17 00:00:00 2001 From: Jade Turner Date: Tue, 3 Dec 2024 10:17:23 +0800 Subject: [PATCH 3/6] newline Signed-off-by: Jade Turner --- .../src/main/native/include/frc2/command/CommandScheduler.h | 1 + 1 file changed, 1 insertion(+) diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h index 7572faba828..536905f996f 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h @@ -24,6 +24,7 @@ namespace frc2 { class Command; class CommandPtr; class Subsystem; + /** * The scheduler responsible for running Commands. A Command-based robot should * call Run() on the singleton instance in its periodic block in order to run From 5d27b3326d6609280c05b8feb7f70f34034f4950 Mon Sep 17 00:00:00 2001 From: Jade Turner Date: Sun, 15 Dec 2024 22:14:33 +0800 Subject: [PATCH 4/6] review Signed-off-by: Jade Turner --- .../edu/wpi/first/wpilibj2/command/CommandScheduler.java | 4 ++-- .../main/native/include/frc2/command/CommandScheduler.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java index 74380724a54..f4e676ac494 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java @@ -180,7 +180,7 @@ private void initCommand(Command command, Set requirements) { * using those requirements have been scheduled as interruptible. If this is the case, they will * be interrupted and the command will be scheduled. * - *

WARNING: using this function directly is often a footgun and should be avoided. Instead + *

WARNING: using this function directly is often can lead to unexpected behavior and should be avoided. Instead * Triggers should be used to schedule Commands. * * @param command the command to schedule. If null, no-op. @@ -233,7 +233,7 @@ private void schedule(Command command) { /** * Schedules multiple commands for execution. Does nothing for commands already scheduled. * - *

WARNING: using this function directly is often a footgun and should be avoided. Instead + *

WARNING: using this function directly is often can lead to unexpected behavior and should be avoided. Instead * Triggers should be used to schedule Commands. * * @param commands the commands to schedule. No-op on null. diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h index 536905f996f..e0eceb605b5 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h @@ -88,7 +88,7 @@ class CommandScheduler final : public wpi::Sendable, * interruptible. If this is the case, they will be interrupted and the * command will be scheduled. * - * @warning Using this function directly is often a footgun and should be + * @warning Using this function directly is often can lead to unexpected behavior and should be * avoided. Instead Triggers should be used to schedule Commands. * * @param command the command to schedule @@ -115,7 +115,7 @@ class CommandScheduler final : public wpi::Sendable, * * The pointer must remain valid through the entire lifecycle of the command. * - * @warning Using this function directly is often a footgun and should be + * @warning Using this function directly is often can lead to unexpected behavior and should be * avoided. Instead Triggers should be used to schedule Commands. * * @param command the command to schedule @@ -126,7 +126,7 @@ class CommandScheduler final : public wpi::Sendable, * Schedules multiple commands for execution. Does nothing for commands * already scheduled. * - * @warning Using this function directly is often a footgun and should be + * @warning Using this function directly is often can lead to unexpected behavior and should be * avoided. Instead Triggers should be used to schedule Commands. * * @param commands the commands to schedule @@ -137,7 +137,7 @@ class CommandScheduler final : public wpi::Sendable, * Schedules multiple commands for execution. Does nothing for commands * already scheduled. * - * @warning Using this function directly is often a footgun and should be + * @warning Using this function directly is often can lead to unexpected behavior and should be * avoided. Instead Triggers should be used to schedule Commands. * * @param commands the commands to schedule From 4d5cc46267e1aa9209ca0b1d631748a7dd9bddff Mon Sep 17 00:00:00 2001 From: Jade Turner Date: Mon, 16 Dec 2024 20:07:01 +0800 Subject: [PATCH 5/6] wording Signed-off-by: Jade Turner --- .../edu/wpi/first/wpilibj2/command/CommandScheduler.java | 4 ++-- .../main/native/include/frc2/command/CommandScheduler.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java index f4e676ac494..20fab812267 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java @@ -180,7 +180,7 @@ private void initCommand(Command command, Set requirements) { * using those requirements have been scheduled as interruptible. If this is the case, they will * be interrupted and the command will be scheduled. * - *

WARNING: using this function directly is often can lead to unexpected behavior and should be avoided. Instead + *

WARNING: using this function directly can often lead to unexpected behavior and should be avoided. Instead * Triggers should be used to schedule Commands. * * @param command the command to schedule. If null, no-op. @@ -233,7 +233,7 @@ private void schedule(Command command) { /** * Schedules multiple commands for execution. Does nothing for commands already scheduled. * - *

WARNING: using this function directly is often can lead to unexpected behavior and should be avoided. Instead + *

WARNING: using this function directly can often lead to unexpected behavior and should be avoided. Instead * Triggers should be used to schedule Commands. * * @param commands the commands to schedule. No-op on null. diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h index e0eceb605b5..ee7b2b076e0 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h @@ -88,7 +88,7 @@ class CommandScheduler final : public wpi::Sendable, * interruptible. If this is the case, they will be interrupted and the * command will be scheduled. * - * @warning Using this function directly is often can lead to unexpected behavior and should be + * @warning Using this function directly can often lead to unexpected behavior and should be * avoided. Instead Triggers should be used to schedule Commands. * * @param command the command to schedule @@ -115,7 +115,7 @@ class CommandScheduler final : public wpi::Sendable, * * The pointer must remain valid through the entire lifecycle of the command. * - * @warning Using this function directly is often can lead to unexpected behavior and should be + * @warning Using this function directly can often lead to unexpected behavior and should be * avoided. Instead Triggers should be used to schedule Commands. * * @param command the command to schedule @@ -126,7 +126,7 @@ class CommandScheduler final : public wpi::Sendable, * Schedules multiple commands for execution. Does nothing for commands * already scheduled. * - * @warning Using this function directly is often can lead to unexpected behavior and should be + * @warning Using this function directly can often lead to unexpected behavior and should be * avoided. Instead Triggers should be used to schedule Commands. * * @param commands the commands to schedule @@ -137,7 +137,7 @@ class CommandScheduler final : public wpi::Sendable, * Schedules multiple commands for execution. Does nothing for commands * already scheduled. * - * @warning Using this function directly is often can lead to unexpected behavior and should be + * @warning Using this function directly can often lead to unexpected behavior and should be * avoided. Instead Triggers should be used to schedule Commands. * * @param commands the commands to schedule From 2cd4e88c0e15f442b31329eea72a3d2bbeb45e8e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:11:58 +0000 Subject: [PATCH 6/6] Formatting fixes --- .../wpilibj2/command/CommandScheduler.java | 8 ++++---- .../include/frc2/command/CommandScheduler.h | 20 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java index 20fab812267..15babf85bbf 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java @@ -180,8 +180,8 @@ private void initCommand(Command command, Set requirements) { * using those requirements have been scheduled as interruptible. If this is the case, they will * be interrupted and the command will be scheduled. * - *

WARNING: using this function directly can often lead to unexpected behavior and should be avoided. Instead - * Triggers should be used to schedule Commands. + *

WARNING: using this function directly can often lead to unexpected behavior and should be + * avoided. Instead Triggers should be used to schedule Commands. * * @param command the command to schedule. If null, no-op. */ @@ -233,8 +233,8 @@ private void schedule(Command command) { /** * Schedules multiple commands for execution. Does nothing for commands already scheduled. * - *

WARNING: using this function directly can often lead to unexpected behavior and should be avoided. Instead - * Triggers should be used to schedule Commands. + *

WARNING: using this function directly can often lead to unexpected behavior and should be + * avoided. Instead Triggers should be used to schedule Commands. * * @param commands the commands to schedule. No-op on null. */ diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h index ee7b2b076e0..c45d3811555 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h @@ -88,8 +88,9 @@ class CommandScheduler final : public wpi::Sendable, * interruptible. If this is the case, they will be interrupted and the * command will be scheduled. * - * @warning Using this function directly can often lead to unexpected behavior and should be - * avoided. Instead Triggers should be used to schedule Commands. + * @warning Using this function directly can often lead to unexpected behavior + * and should be avoided. Instead Triggers should be used to schedule + * Commands. * * @param command the command to schedule */ @@ -115,8 +116,9 @@ class CommandScheduler final : public wpi::Sendable, * * The pointer must remain valid through the entire lifecycle of the command. * - * @warning Using this function directly can often lead to unexpected behavior and should be - * avoided. Instead Triggers should be used to schedule Commands. + * @warning Using this function directly can often lead to unexpected behavior + * and should be avoided. Instead Triggers should be used to schedule + * Commands. * * @param command the command to schedule */ @@ -126,8 +128,9 @@ class CommandScheduler final : public wpi::Sendable, * Schedules multiple commands for execution. Does nothing for commands * already scheduled. * - * @warning Using this function directly can often lead to unexpected behavior and should be - * avoided. Instead Triggers should be used to schedule Commands. + * @warning Using this function directly can often lead to unexpected behavior + * and should be avoided. Instead Triggers should be used to schedule + * Commands. * * @param commands the commands to schedule */ @@ -137,8 +140,9 @@ class CommandScheduler final : public wpi::Sendable, * Schedules multiple commands for execution. Does nothing for commands * already scheduled. * - * @warning Using this function directly can often lead to unexpected behavior and should be - * avoided. Instead Triggers should be used to schedule Commands. + * @warning Using this function directly can often lead to unexpected behavior + * and should be avoided. Instead Triggers should be used to schedule + * Commands. * * @param commands the commands to schedule */