mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Fix multiple Java warnings (#6201)
This commit is contained in:
@@ -27,6 +27,7 @@ import edu.wpi.first.networktables.StringArrayTopic;
|
||||
import edu.wpi.first.networktables.StringEntry;
|
||||
import edu.wpi.first.networktables.StringPublisher;
|
||||
import edu.wpi.first.util.PixelFormat;
|
||||
import java.lang.ref.Reference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -140,6 +141,7 @@ public final class CameraServer {
|
||||
if (m_choicesPublisher != null) {
|
||||
m_choicesPublisher.close();
|
||||
}
|
||||
Reference.reachabilityFence(m_videoListener);
|
||||
}
|
||||
|
||||
BooleanEntry m_booleanValueEntry;
|
||||
@@ -223,7 +225,7 @@ public final class CameraServer {
|
||||
// - "PropertyInfo/{Property}" - Property supporting information
|
||||
|
||||
// Listener for video events
|
||||
@SuppressWarnings({"PMD.UnusedPrivateField", "PMD.AvoidCatchingGenericException"})
|
||||
@SuppressWarnings("PMD.AvoidCatchingGenericException")
|
||||
private static final VideoListener m_videoListener =
|
||||
new VideoListener(
|
||||
event -> {
|
||||
|
||||
@@ -40,12 +40,10 @@ public class FieldConfig {
|
||||
|
||||
public FieldConfig() {}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public URL getImageUrl() {
|
||||
return getClass().getResource(Fields.kBaseResourceDir + m_fieldImage);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public InputStream getImageAsStream() {
|
||||
return getClass().getResourceAsStream(Fields.kBaseResourceDir + m_fieldImage);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.nio.ByteOrder;
|
||||
* href="https://docs.wpilib.org/en/stable/docs/yearly-overview/known-issues.html#onboard-i2c-causing-system-lockups">
|
||||
* WPILib Known Issues</a> page for details.
|
||||
*/
|
||||
@SuppressWarnings({"TypeName", "PMD.UnusedPrivateField"})
|
||||
@SuppressWarnings("TypeName")
|
||||
public class ADXL345_I2C implements NTSendable, AutoCloseable {
|
||||
/** Default I2C device address. */
|
||||
public static final byte kAddress = 0x1D;
|
||||
@@ -34,16 +34,17 @@ public class ADXL345_I2C implements NTSendable, AutoCloseable {
|
||||
private static final byte kDataFormatRegister = 0x31;
|
||||
private static final byte kDataRegister = 0x32;
|
||||
private static final double kGsPerLSB = 0.00390625;
|
||||
private static final byte kPowerCtl_Link = 0x20;
|
||||
private static final byte kPowerCtl_AutoSleep = 0x10;
|
||||
// private static final byte kPowerCtl_Link = 0x20;
|
||||
// private static final byte kPowerCtl_AutoSleep = 0x10;
|
||||
private static final byte kPowerCtl_Measure = 0x08;
|
||||
private static final byte kPowerCtl_Sleep = 0x04;
|
||||
// private static final byte kPowerCtl_Sleep = 0x04;
|
||||
|
||||
private static final byte kDataFormat_SelfTest = (byte) 0x80;
|
||||
private static final byte kDataFormat_SPI = 0x40;
|
||||
private static final byte kDataFormat_IntInvert = 0x20;
|
||||
// private static final byte kDataFormat_SelfTest = (byte) 0x80;
|
||||
// private static final byte kDataFormat_SPI = 0x40;
|
||||
// private static final byte kDataFormat_IntInvert = 0x20;
|
||||
private static final byte kDataFormat_FullRes = 0x08;
|
||||
private static final byte kDataFormat_Justify = 0x04;
|
||||
|
||||
// private static final byte kDataFormat_Justify = 0x04;
|
||||
|
||||
/** Accelerometer range. */
|
||||
public enum Range {
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/** ADXL345 SPI Accelerometer. */
|
||||
@SuppressWarnings({"TypeName", "PMD.UnusedPrivateField"})
|
||||
@SuppressWarnings("TypeName")
|
||||
public class ADXL345_SPI implements NTSendable, AutoCloseable {
|
||||
private static final int kPowerCtlRegister = 0x2D;
|
||||
private static final int kDataFormatRegister = 0x31;
|
||||
@@ -29,16 +29,17 @@ public class ADXL345_SPI implements NTSendable, AutoCloseable {
|
||||
private static final int kAddress_Read = 0x80;
|
||||
private static final int kAddress_MultiByte = 0x40;
|
||||
|
||||
private static final int kPowerCtl_Link = 0x20;
|
||||
private static final int kPowerCtl_AutoSleep = 0x10;
|
||||
// private static final int kPowerCtl_Link = 0x20;
|
||||
// private static final int kPowerCtl_AutoSleep = 0x10;
|
||||
private static final int kPowerCtl_Measure = 0x08;
|
||||
private static final int kPowerCtl_Sleep = 0x04;
|
||||
// private static final int kPowerCtl_Sleep = 0x04;
|
||||
|
||||
private static final int kDataFormat_SelfTest = 0x80;
|
||||
private static final int kDataFormat_SPI = 0x40;
|
||||
private static final int kDataFormat_IntInvert = 0x20;
|
||||
// private static final int kDataFormat_SelfTest = 0x80;
|
||||
// private static final int kDataFormat_SPI = 0x40;
|
||||
// private static final int kDataFormat_IntInvert = 0x20;
|
||||
private static final int kDataFormat_FullRes = 0x08;
|
||||
private static final int kDataFormat_Justify = 0x04;
|
||||
|
||||
// private static final int kDataFormat_Justify = 0x04;
|
||||
|
||||
/** Accelerometer range. */
|
||||
public enum Range {
|
||||
|
||||
@@ -38,8 +38,8 @@ public class ADXL362 implements NTSendable, AutoCloseable {
|
||||
|
||||
private static final byte kPowerCtl_UltraLowNoise = 0x20;
|
||||
|
||||
@SuppressWarnings("PMD.UnusedPrivateField")
|
||||
private static final byte kPowerCtl_AutoSleep = 0x04;
|
||||
// @SuppressWarnings("PMD.UnusedPrivateField")
|
||||
// private static final byte kPowerCtl_AutoSleep = 0x04;
|
||||
|
||||
private static final byte kPowerCtl_Measure = 0x02;
|
||||
|
||||
|
||||
@@ -26,21 +26,21 @@ import java.nio.ByteOrder;
|
||||
* <p>This class is for the digital ADXRS450 gyro sensor that connects via SPI. Only one instance of
|
||||
* an ADXRS Gyro is supported.
|
||||
*/
|
||||
@SuppressWarnings({"TypeName", "PMD.UnusedPrivateField"})
|
||||
@SuppressWarnings("TypeName")
|
||||
public class ADXRS450_Gyro implements Sendable, AutoCloseable {
|
||||
private static final double kSamplePeriod = 0.0005;
|
||||
private static final double kCalibrationSampleTime = 5.0;
|
||||
private static final double kDegreePerSecondPerLSB = 0.0125;
|
||||
|
||||
private static final int kRateRegister = 0x00;
|
||||
private static final int kTemRegister = 0x02;
|
||||
private static final int kLoCSTRegister = 0x04;
|
||||
private static final int kHiCSTRegister = 0x06;
|
||||
private static final int kQuadRegister = 0x08;
|
||||
private static final int kFaultRegister = 0x0A;
|
||||
// private static final int kRateRegister = 0x00;
|
||||
// private static final int kTemRegister = 0x02;
|
||||
// private static final int kLoCSTRegister = 0x04;
|
||||
// private static final int kHiCSTRegister = 0x06;
|
||||
// private static final int kQuadRegister = 0x08;
|
||||
// private static final int kFaultRegister = 0x0A;
|
||||
private static final int kPIDRegister = 0x0C;
|
||||
private static final int kSNHighRegister = 0x0E;
|
||||
private static final int kSNLowRegister = 0x10;
|
||||
// private static final int kSNHighRegister = 0x0E;
|
||||
// private static final int kSNLowRegister = 0x10;
|
||||
|
||||
private SPI m_spi;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import edu.wpi.first.util.sendable.Sendable;
|
||||
import edu.wpi.first.util.sendable.SendableBuilder;
|
||||
import edu.wpi.first.util.sendable.SendableRegistry;
|
||||
import edu.wpi.first.wpilibj.AnalogTriggerOutput.AnalogTriggerType;
|
||||
import java.lang.ref.Reference;
|
||||
|
||||
/** Class for creating and configuring Analog Triggers. */
|
||||
public class AnalogTrigger implements Sendable, AutoCloseable {
|
||||
@@ -20,7 +21,6 @@ public class AnalogTrigger implements Sendable, AutoCloseable {
|
||||
|
||||
private AnalogInput m_analogInput;
|
||||
|
||||
@SuppressWarnings({"PMD.SingularField", "PMD.UnusedPrivateField"})
|
||||
private DutyCycle m_dutyCycle;
|
||||
|
||||
private boolean m_ownsAnalog;
|
||||
@@ -80,6 +80,7 @@ public class AnalogTrigger implements Sendable, AutoCloseable {
|
||||
if (m_ownsAnalog && m_analogInput != null) {
|
||||
m_analogInput.close();
|
||||
}
|
||||
Reference.reachabilityFence(m_dutyCycle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,6 +48,8 @@ public final class DriverStation {
|
||||
|
||||
private static class HALJoystickAxesRaw {
|
||||
public int[] m_axes;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public int m_count;
|
||||
|
||||
HALJoystickAxesRaw(int count) {
|
||||
|
||||
@@ -208,6 +208,7 @@ public class Watchdog implements Closeable, Comparable<Watchdog> {
|
||||
m_suppressTimeoutMessage = suppress;
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
private static void updateAlarm() {
|
||||
if (m_watchdogs.isEmpty()) {
|
||||
NotifierJNI.cancelNotifierAlarm(m_notifier);
|
||||
|
||||
@@ -9,6 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import edu.wpi.first.wpilibj.motorcontrol.MockPWMMotorController;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
class DifferentialDriveTest {
|
||||
@Test
|
||||
void testArcadeDriveIK() {
|
||||
|
||||
@@ -10,6 +10,7 @@ import edu.wpi.first.math.geometry.Rotation2d;
|
||||
import edu.wpi.first.wpilibj.motorcontrol.MockPWMMotorController;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
class MecanumDriveTest {
|
||||
@Test
|
||||
void testCartesianIK() {
|
||||
|
||||
@@ -22,6 +22,7 @@ class ElevatorSimTest {
|
||||
void testStateSpaceSimWithElevator() {
|
||||
RoboRioSim.resetData();
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
var controller = new PIDController(10, 0, 0);
|
||||
|
||||
var sim =
|
||||
|
||||
@@ -52,6 +52,7 @@ public final class TestBench {
|
||||
public static final int DIOCrossConnectA1 = 6;
|
||||
|
||||
/** The Singleton instance of the Test Bench. */
|
||||
@SuppressWarnings("unused")
|
||||
private static TestBench instance = null;
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,7 +50,10 @@ public class TestSuite extends AbstractTestSuite {
|
||||
TestBench.out().println("Starting Tests");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final Logger WPILIBJ_ROOT_LOGGER = Logger.getLogger("edu.wpi.first.wpilibj");
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final Logger WPILIBJ_COMMAND_ROOT_LOGGER =
|
||||
Logger.getLogger("edu.wpi.first.wpilibj.command");
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ public class CircularBuffer<T> {
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >=
|
||||
* size())
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getLast() {
|
||||
// If there are no elements in the buffer, do nothing
|
||||
if (m_length == 0) {
|
||||
@@ -111,7 +110,6 @@ public class CircularBuffer<T> {
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >=
|
||||
* size())
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T removeFirst() {
|
||||
// If there are no elements in the buffer, do nothing
|
||||
if (m_length == 0) {
|
||||
@@ -131,7 +129,6 @@ public class CircularBuffer<T> {
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >=
|
||||
* size())
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T removeLast() {
|
||||
// If there are no elements in the buffer, do nothing
|
||||
if (m_length == 0) {
|
||||
|
||||
Reference in New Issue
Block a user