[wpilibj] Fix warnings that are not unused variables or deprecation (#3161)

Fix all warnings given by intellisense that are not unused variables or deprecation.
This commit is contained in:
Thad House
2021-02-12 22:22:11 -08:00
committed by GitHub
parent c14b237757
commit 99b5ad9ebb
20 changed files with 43 additions and 35 deletions

View File

@@ -14,7 +14,7 @@ import java.util.WeakHashMap;
* those commands are not also used independently, which can result in inconsistent command state
* and unpredictable execution.
*/
public abstract class CommandGroupBase extends CommandBase implements Command {
public abstract class CommandGroupBase extends CommandBase {
private static final Set<Command> m_groupedCommands =
Collections.newSetFromMap(new WeakHashMap<>());

View File

@@ -353,7 +353,7 @@ public abstract class Command implements Sendable, AutoCloseable {
* @return the requirements (as an {@link Enumeration Enumeration} of {@link Subsystem
* Subsystems}) of this command
*/
synchronized Enumeration getRequirements() {
synchronized Enumeration<?> getRequirements() {
return m_requirements.getElements();
}

View File

@@ -81,7 +81,7 @@ public class CommandGroup extends Command {
command.setParent(this);
m_commands.addElement(new Entry(command, Entry.IN_SEQUENCE));
for (Enumeration e = command.getRequirements(); e.hasMoreElements(); ) {
for (Enumeration<?> e = command.getRequirements(); e.hasMoreElements(); ) {
requires((Subsystem) e.nextElement());
}
}
@@ -119,7 +119,7 @@ public class CommandGroup extends Command {
command.setParent(this);
m_commands.addElement(new Entry(command, Entry.IN_SEQUENCE, timeout));
for (Enumeration e = command.getRequirements(); e.hasMoreElements(); ) {
for (Enumeration<?> e = command.getRequirements(); e.hasMoreElements(); ) {
requires((Subsystem) e.nextElement());
}
}
@@ -152,7 +152,7 @@ public class CommandGroup extends Command {
command.setParent(this);
m_commands.addElement(new Entry(command, Entry.BRANCH_CHILD));
for (Enumeration e = command.getRequirements(); e.hasMoreElements(); ) {
for (Enumeration<?> e = command.getRequirements(); e.hasMoreElements(); ) {
requires((Subsystem) e.nextElement());
}
}
@@ -193,7 +193,7 @@ public class CommandGroup extends Command {
command.setParent(this);
m_commands.addElement(new Entry(command, Entry.BRANCH_CHILD, timeout));
for (Enumeration e = command.getRequirements(); e.hasMoreElements(); ) {
for (Enumeration<?> e = command.getRequirements(); e.hasMoreElements(); ) {
requires((Subsystem) e.nextElement());
}
}
@@ -283,7 +283,7 @@ public class CommandGroup extends Command {
cmd.removed();
}
Enumeration children = m_children.elements();
Enumeration<?> children = m_children.elements();
while (children.hasMoreElements()) {
Command cmd = ((Entry) children.nextElement()).m_command;
cmd._cancel();
@@ -361,7 +361,7 @@ public class CommandGroup extends Command {
for (int i = 0; i < m_children.size(); i++) {
Command child = m_children.elementAt(i).m_command;
Enumeration requirements = command.getRequirements();
Enumeration<?> requirements = command.getRequirements();
while (requirements.hasMoreElements()) {
Object requirement = requirements.nextElement();

View File

@@ -37,13 +37,13 @@ public abstract class ConditionalCommand extends Command {
private void requireAll() {
if (m_onTrue != null) {
for (Enumeration e = m_onTrue.getRequirements(); e.hasMoreElements(); ) {
for (Enumeration<?> e = m_onTrue.getRequirements(); e.hasMoreElements(); ) {
requires((Subsystem) e.nextElement());
}
}
if (m_onFalse != null) {
for (Enumeration e = m_onFalse.getRequirements(); e.hasMoreElements(); ) {
for (Enumeration<?> e = m_onFalse.getRequirements(); e.hasMoreElements(); ) {
requires((Subsystem) e.nextElement());
}
}

View File

@@ -144,7 +144,7 @@ public final class Scheduler implements Sendable, AutoCloseable {
// Only add if not already in
if (!m_commandTable.containsKey(command)) {
// Check that the requirements can be had
Enumeration requirements = command.getRequirements();
Enumeration<?> requirements = command.getRequirements();
while (requirements.hasMoreElements()) {
Subsystem lock = (Subsystem) requirements.nextElement();
if (lock.getCurrentCommand() != null && !lock.getCurrentCommand().isInterruptible()) {
@@ -210,7 +210,7 @@ public final class Scheduler implements Sendable, AutoCloseable {
}
// Call every subsystem's periodic method
Enumeration subsystems = m_subsystems.getElements();
Enumeration<?> subsystems = m_subsystems.getElements();
while (subsystems.hasMoreElements()) {
((Subsystem) subsystems.nextElement()).periodic();
}
@@ -233,7 +233,7 @@ public final class Scheduler implements Sendable, AutoCloseable {
m_additions.removeAllElements();
// Add in the defaults
Enumeration locks = m_subsystems.getElements();
Enumeration<?> locks = m_subsystems.getElements();
while (locks.hasMoreElements()) {
Subsystem lock = (Subsystem) locks.nextElement();
if (lock.getCurrentCommand() == null) {
@@ -276,7 +276,7 @@ public final class Scheduler implements Sendable, AutoCloseable {
}
element.remove();
Enumeration requirements = command.getRequirements();
Enumeration<?> requirements = command.getRequirements();
while (requirements.hasMoreElements()) {
((Subsystem) requirements.nextElement()).setCurrentCommand(null);
}

View File

@@ -30,10 +30,9 @@ public final class MockHardwareExtension implements BeforeAllCallback {
private void initializeHardware() {
HAL.initialize(500, 0);
DriverStationSim dsSim = new DriverStationSim();
dsSim.setDsAttached(true);
dsSim.setAutonomous(false);
dsSim.setEnabled(true);
dsSim.setTest(true);
DriverStationSim.setDsAttached(true);
DriverStationSim.setAutonomous(false);
DriverStationSim.setEnabled(true);
DriverStationSim.setTest(true);
}
}

View File

@@ -9,7 +9,6 @@ import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.SimBoolean;
import edu.wpi.first.hal.SimDevice;
import edu.wpi.first.hal.SimDouble;
import edu.wpi.first.wpilibj.interfaces.Gyro;
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -25,7 +24,7 @@ import java.nio.ByteOrder;
* an ADXRS Gyro is supported.
*/
@SuppressWarnings({"TypeName", "AbbreviationAsWordInName", "PMD.UnusedPrivateField"})
public class ADXRS450_Gyro extends GyroBase implements Gyro, PIDSource, Sendable, AutoCloseable {
public class ADXRS450_Gyro extends GyroBase {
private static final double kSamplePeriod = 0.0005;
private static final double kCalibrationSampleTime = 5.0;
private static final double kDegreePerSecondPerLSB = 0.0125;

View File

@@ -5,6 +5,7 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.SimDevice;
import edu.wpi.first.hal.SimDevice.Direction;
import edu.wpi.first.hal.SimDouble;
import edu.wpi.first.wpilibj.AnalogTriggerOutput.AnalogTriggerType;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
@@ -39,7 +40,7 @@ public class AnalogEncoder implements Sendable, AutoCloseable {
m_simDevice = SimDevice.create("AnalogEncoder", m_analogInput.getChannel());
if (m_simDevice != null) {
m_simPosition = m_simDevice.createDouble("Position", false, 0.0);
m_simPosition = m_simDevice.createDouble("Position", Direction.kInput, 0.0);
}
// Limits need to be 25% from each end

View File

@@ -9,7 +9,6 @@ import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam;
import edu.wpi.first.hal.AnalogGyroJNI;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.interfaces.Gyro;
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
/**
@@ -21,7 +20,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
*
* <p>This class is for gyro sensors that connect to an analog input.
*/
public class AnalogGyro extends GyroBase implements Gyro, PIDSource, Sendable, AutoCloseable {
public class AnalogGyro extends GyroBase {
private static final double kDefaultVoltsPerDegreePerSecond = 0.007;
protected AnalogInput m_analog;
private boolean m_channelAllocated;

View File

@@ -17,7 +17,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
* elsewhere will automatically allocate digital inputs and outputs as required. This class is only
* for devices like switches etc. that aren't implemented anywhere else.
*/
public class DigitalInput extends DigitalSource implements Sendable, AutoCloseable {
public class DigitalInput extends DigitalSource implements Sendable {
private final int m_channel;
private int m_handle;

View File

@@ -15,7 +15,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
* Class to write digital outputs. This class will write digital outputs. Other devices that are
* implemented elsewhere will automatically allocate digital inputs and outputs as required.
*/
public class DigitalOutput extends DigitalSource implements Sendable, AutoCloseable {
public class DigitalOutput extends DigitalSource implements Sendable {
private static final int invalidPwmGenerator = 0;
private int m_pwmGenerator = invalidPwmGenerator;

View File

@@ -19,7 +19,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
* @deprecated Use {@link edu.wpi.first.wpilibj.controller.PIDController} instead.
*/
@Deprecated(since = "2020", forRemoval = true)
public class PIDController extends PIDBase implements Controller, AutoCloseable {
public class PIDController extends PIDBase implements Controller {
Notifier m_controlLoop = new Notifier(this::calculate);
/**

View File

@@ -5,6 +5,7 @@
package edu.wpi.first.wpilibj;
/** Interface for speed controlling devices. */
@SuppressWarnings("removal")
public interface SpeedController extends PIDOutput {
/**
* Common interface for setting the speed of a speed controller.

View File

@@ -10,6 +10,7 @@ import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.SimBoolean;
import edu.wpi.first.hal.SimDevice;
import edu.wpi.first.hal.SimDevice.Direction;
import edu.wpi.first.hal.SimDouble;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
@@ -93,8 +94,8 @@ public class Ultrasonic implements PIDSource, Sendable, AutoCloseable {
private synchronized void initialize() {
m_simDevice = SimDevice.create("Ultrasonic", m_echoChannel.getChannel());
if (m_simDevice != null) {
m_simRangeValid = m_simDevice.createBoolean("Range Valid", false, true);
m_simRange = m_simDevice.createDouble("Range (in)", false, 0.0);
m_simRangeValid = m_simDevice.createBoolean("Range Valid", Direction.kInput, true);
m_simRange = m_simDevice.createDouble("Range (in)", Direction.kInput, 0.0);
m_pingChannel.setSimDevice(m_simDevice);
m_echoChannel.setSimDevice(m_simDevice);
}

View File

@@ -197,6 +197,7 @@ public class Watchdog implements Closeable, Comparable<Watchdog> {
m_suppressTimeoutMessage = suppress;
}
@SuppressWarnings("resource")
private static void updateAlarm() {
if (m_watchdogs.size() == 0) {
NotifierJNI.cancelNotifierAlarm(m_notifier);

View File

@@ -82,7 +82,7 @@ public class CallbackStore implements AutoCloseable {
m_cancelType = -1;
}
@SuppressWarnings("NoFinalizer")
@SuppressWarnings({"NoFinalizer", "deprecation"})
@Override
protected void finalize() throws Throwable {
try {

View File

@@ -11,7 +11,11 @@ import edu.wpi.first.wpilibj.DriverStation;
/** Class to control a simulated driver station. */
@SuppressWarnings({"PMD.UseUtilityClass", "PMD.GodClass", "PMD.ExcessivePublicCount"})
public class DriverStationSim {
public final class DriverStationSim {
private DriverStationSim() {
throw new UnsupportedOperationException("This is a utility class!");
}
/**
* Register a callback on whether the DS is enabled.
*

View File

@@ -5,6 +5,7 @@
package edu.wpi.first.wpilibj.simulation;
import edu.wpi.first.hal.SimDevice;
import edu.wpi.first.hal.SimDevice.Direction;
import edu.wpi.first.hal.SimDouble;
import java.util.HashMap;
import java.util.Map;
@@ -23,7 +24,8 @@ public class Mechanism2D {
ligamentPath = ligamentPath + "/angle";
if (m_device != null) {
if (!m_createdItems.containsKey(ligamentPath)) {
m_createdItems.put(ligamentPath, m_device.createDouble(ligamentPath, false, angle));
m_createdItems.put(
ligamentPath, m_device.createDouble(ligamentPath, Direction.kInput, angle));
}
m_createdItems.get(ligamentPath).set(angle);
}
@@ -39,7 +41,8 @@ public class Mechanism2D {
ligamentPath = ligamentPath + "/length";
if (m_device != null) {
if (!m_createdItems.containsKey(ligamentPath)) {
m_createdItems.put(ligamentPath, m_device.createDouble(ligamentPath, false, length));
m_createdItems.put(
ligamentPath, m_device.createDouble(ligamentPath, Direction.kInput, length));
}
m_createdItems.get(ligamentPath).set(length);
}

View File

@@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test;
public class ElevatorSimTest {
@Test
@SuppressWarnings("LocalVariableName")
@SuppressWarnings({"LocalVariableName", "resource"})
public void testStateSpaceSimWithElevator() {
var controller = new PIDController(10, 0, 0);

View File

@@ -14,7 +14,7 @@ import edu.wpi.first.wpilibj.command.Subsystem;
* The Collector subsystem has one motor for the rollers, a limit switch for ball detection, a
* piston for opening and closing the claw, and a reed switch to check if the piston is open.
*/
public class Collector extends Subsystem implements AutoCloseable {
public class Collector extends Subsystem {
// Constants for some useful speeds
public static final double kForward = 1;
public static final double kStop = 0;