Upgrade maven deps to latest versions and fix new linter errors (#3772)

This also makes the Gradle build work with JDK 17.

The extra JVM args in gradle.properties works around a bug with spotless
and JDK 17: https://github.com/diffplug/spotless/issues/834

PMD.CloseResource was ignored because it's almost always a false
positive, and there are many of them.
This commit is contained in:
Tyler Veness
2021-12-09 12:20:08 -08:00
committed by GitHub
parent 441f2ed9b0
commit 7269a170fb
100 changed files with 306 additions and 338 deletions

View File

@@ -6,7 +6,6 @@ package edu.wpi.first.wpilibj;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.params.provider.Arguments.arguments;
import edu.wpi.first.wpilibj.util.Color;
@@ -63,13 +62,13 @@ class AddressableLEDBufferTest {
buffer.setLED(2, Color.kFirstRed);
buffer.setLED(3, Color.kFirstBlue);
assertTrue(buffer.getLED(0).equals(Color.kFirstBlue));
assertTrue(buffer.getLED(1).equals(Color.kDenim));
assertTrue(buffer.getLED(2).equals(Color.kFirstRed));
assertTrue(buffer.getLED(3).equals(Color.kFirstBlue));
assertTrue(buffer.getLED8Bit(0).equals(firstBlueColor8Bit));
assertTrue(buffer.getLED8Bit(1).equals(denimColor8Bit));
assertTrue(buffer.getLED8Bit(2).equals(firstRedColor8Bit));
assertTrue(buffer.getLED8Bit(3).equals(firstBlueColor8Bit));
assertEquals(Color.kFirstBlue, buffer.getLED(0));
assertEquals(Color.kDenim, buffer.getLED(1));
assertEquals(Color.kFirstRed, buffer.getLED(2));
assertEquals(Color.kFirstBlue, buffer.getLED(3));
assertEquals(firstBlueColor8Bit, buffer.getLED8Bit(0));
assertEquals(denimColor8Bit, buffer.getLED8Bit(1));
assertEquals(firstRedColor8Bit, buffer.getLED8Bit(2));
assertEquals(firstBlueColor8Bit, buffer.getLED8Bit(3));
}
}

View File

@@ -12,7 +12,7 @@ import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.simulation.AnalogGyroSim;
import org.junit.jupiter.api.Test;
public class AnalogGyroTest {
class AnalogGyroTest {
@Test
void testInitializeWithAnalogInput() {
HAL.initialize(500, 0);

View File

@@ -11,7 +11,7 @@ import edu.wpi.first.wpilibj.simulation.AnalogInputSim;
import edu.wpi.first.wpilibj.simulation.RoboRioSim;
import org.junit.jupiter.api.Test;
public class AnalogPotentiometerTest {
class AnalogPotentiometerTest {
@Test
void testInitializeWithAnalogInput() {
HAL.initialize(500, 0);

View File

@@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import edu.wpi.first.wpilibj.simulation.SimHooks;
import org.junit.jupiter.api.Test;
public class DebouncerTest {
class DebouncerTest {
@Test
void debounceRisingTest() {
var debouncer = new Debouncer(0.02, Debouncer.DebounceType.kRising);

View File

@@ -12,7 +12,7 @@ import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.simulation.DIOSim;
import org.junit.jupiter.api.Test;
public class DigitalOutputTest {
class DigitalOutputTest {
@Test
void testDefaultFunctions() {
try (DigitalOutput output = new DigitalOutput(0)) {

View File

@@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import edu.wpi.first.hal.util.AllocationException;
import org.junit.jupiter.api.Test;
public class DoubleSolenoidTestCTRE {
class DoubleSolenoidTestCTRE {
@Test
void testValidInitialization() {
try (DoubleSolenoid solenoid = new DoubleSolenoid(3, PneumaticsModuleType.CTREPCM, 2, 3)) {

View File

@@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import edu.wpi.first.hal.util.AllocationException;
import org.junit.jupiter.api.Test;
public class DoubleSolenoidTestREV {
class DoubleSolenoidTestREV {
@Test
void testValidInitialization() {
try (DoubleSolenoid solenoid = new DoubleSolenoid(3, PneumaticsModuleType.REVPH, 2, 3)) {

View File

@@ -12,7 +12,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.Test;
public class InterruptTest {
class InterruptTest {
@Test
void testAsynchronousInterrupt() {
AtomicBoolean hasFired = new AtomicBoolean(false);

View File

@@ -19,7 +19,7 @@ class PS4ControllerTest {
@ParameterizedTest
@EnumSource(value = PS4Controller.Button.class)
@SuppressWarnings({"VariableDeclarationUsageDistance"})
public void testButtons(PS4Controller.Button button)
void testButtons(PS4Controller.Button button)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
HAL.initialize(500, 0);
PS4Controller joy = new PS4Controller(2);
@@ -60,7 +60,7 @@ class PS4ControllerTest {
@ParameterizedTest
@EnumSource(value = PS4Controller.Axis.class)
@SuppressWarnings({"VariableDeclarationUsageDistance"})
public void testAxes(PS4Controller.Axis axis)
void testAxes(PS4Controller.Axis axis)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
HAL.initialize(500, 0);
PS4Controller joy = new PS4Controller(2);

View File

@@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
public class SensorUtilTest {
class SensorUtilTest {
@Test
void checkAnalogInputChannel() {
assertThrows(IllegalArgumentException.class, () -> SensorUtil.checkAnalogInputChannel(100));

View File

@@ -12,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import edu.wpi.first.hal.util.AllocationException;
import org.junit.jupiter.api.Test;
public class SolenoidTestCTRE {
class SolenoidTestCTRE {
@Test
void testValidInitialization() {
try (Solenoid solenoid = new Solenoid(3, PneumaticsModuleType.CTREPCM, 2)) {

View File

@@ -12,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import edu.wpi.first.hal.util.AllocationException;
import org.junit.jupiter.api.Test;
public class SolenoidTestREV {
class SolenoidTestREV {
@Test
void testValidInitialization() {
try (Solenoid solenoid = new Solenoid(3, PneumaticsModuleType.REVPH, 2)) {

View File

@@ -11,9 +11,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import edu.wpi.first.wpilibj.simulation.UltrasonicSim;
import org.junit.jupiter.api.Test;
public class UltrasonicTest {
class UltrasonicTest {
@Test
public void testUltrasonic() {
void testUltrasonic() {
try (Ultrasonic ultrasonic = new Ultrasonic(0, 1)) {
UltrasonicSim sim = new UltrasonicSim(ultrasonic);

View File

@@ -34,19 +34,20 @@ public abstract class UtilityClassTest<T> {
}
@Test
public void singleConstructorTest() {
void singleConstructorTest() {
assertEquals(1, m_clazz.getDeclaredConstructors().length, "More than one constructor defined");
}
@Test
public void constructorPrivateTest() {
void constructorPrivateTest() {
Constructor<?> constructor = m_clazz.getDeclaredConstructors()[0];
assertFalse(constructor.canAccess(null), "Constructor is not private");
}
@Test
public void constructorReflectionTest() {
@SuppressWarnings("PMD.AvoidAccessibilityAlteration")
void constructorReflectionTest() {
Constructor<?> constructor = m_clazz.getDeclaredConstructors()[0];
constructor.setAccessible(true);
assertThrows(InvocationTargetException.class, constructor::newInstance);

View File

@@ -19,7 +19,7 @@ class XboxControllerTest {
@ParameterizedTest
@EnumSource(value = XboxController.Button.class)
@SuppressWarnings({"VariableDeclarationUsageDistance"})
public void testButtons(XboxController.Button button)
void testButtons(XboxController.Button button)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
HAL.initialize(500, 0);
XboxController joy = new XboxController(2);
@@ -60,7 +60,7 @@ class XboxControllerTest {
@ParameterizedTest
@EnumSource(value = XboxController.Axis.class)
@SuppressWarnings({"VariableDeclarationUsageDistance"})
public void testAxes(XboxController.Axis axis)
void testAxes(XboxController.Axis axis)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
HAL.initialize(500, 0);
XboxController joy = new XboxController(2);

View File

@@ -15,7 +15,7 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class ShuffleboardInstanceTest {
class ShuffleboardInstanceTest {
private NetworkTableInstance m_ntInstance;
private ShuffleboardInstance m_shuffleboardInstance;

View File

@@ -9,8 +9,8 @@ import static org.junit.jupiter.api.Assertions.assertSame;
import edu.wpi.first.wpilibj.UtilityClassTest;
import org.junit.jupiter.api.Test;
public class ShuffleboardTest extends UtilityClassTest<Shuffleboard> {
public ShuffleboardTest() {
class ShuffleboardTest extends UtilityClassTest<Shuffleboard> {
ShuffleboardTest() {
super(Shuffleboard.class);
}

View File

@@ -15,7 +15,7 @@ import edu.wpi.first.wpilibj.interfaces.Accelerometer;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
public class ADXL345SimTest {
class ADXL345SimTest {
@ParameterizedTest
@EnumSource(Accelerometer.Range.class)
void testInitI2C(Accelerometer.Range range) {

View File

@@ -13,7 +13,7 @@ import edu.wpi.first.wpilibj.interfaces.Accelerometer;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
public class ADXL362SimTest {
class ADXL362SimTest {
@ParameterizedTest
@EnumSource(Accelerometer.Range.class)
void testAccel(Accelerometer.Range range) {

View File

@@ -11,9 +11,9 @@ import edu.wpi.first.wpilibj.AnalogEncoder;
import edu.wpi.first.wpilibj.AnalogInput;
import org.junit.jupiter.api.Test;
public class AnalogEncoderSimTest {
class AnalogEncoderSimTest {
@Test
public void testBasic() {
void testBasic() {
try (var analogInput = new AnalogInput(0);
var analogEncoder = new AnalogEncoder(analogInput)) {
var encoderSim = new AnalogEncoderSim(analogEncoder);

View File

@@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
class DifferentialDrivetrainSimTest {
@Test
public void testConvergence() {
void testConvergence() {
var motor = DCMotor.getNEO(2);
var plant =
LinearSystemId.createDrivetrainVelocitySystem(
@@ -96,7 +96,7 @@ class DifferentialDrivetrainSimTest {
}
@Test
public void testCurrent() {
void testCurrent() {
var motor = DCMotor.getNEO(2);
var plant =
LinearSystemId.createDrivetrainVelocitySystem(
@@ -126,7 +126,7 @@ class DifferentialDrivetrainSimTest {
}
@Test
public void testModelStability() {
void testModelStability() {
var motor = DCMotor.getNEO(2);
var plant =
LinearSystemId.createDrivetrainVelocitySystem(

View File

@@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
public class DriverStationSimTest {
class DriverStationSimTest {
@Test
void testEnabled() {
HAL.initialize(500, 0);
@@ -192,7 +192,7 @@ public class DriverStationSimTest {
@ParameterizedTest
@EnumSource(DriverStation.MatchType.class)
public void testMatchType(DriverStation.MatchType matchType) {
void testMatchType(DriverStation.MatchType matchType) {
HAL.initialize(500, 0);
DriverStationSim.resetData();
@@ -202,7 +202,7 @@ public class DriverStationSimTest {
}
@Test
public void testReplayNumber() {
void testReplayNumber() {
HAL.initialize(500, 0);
DriverStationSim.resetData();
@@ -212,7 +212,7 @@ public class DriverStationSimTest {
}
@Test
public void testMatchNumber() {
void testMatchNumber() {
HAL.initialize(500, 0);
DriverStationSim.resetData();
@@ -222,7 +222,7 @@ public class DriverStationSimTest {
}
@Test
public void testMatchTime() {
void testMatchTime() {
HAL.initialize(500, 0);
DriverStationSim.resetData();
@@ -238,7 +238,7 @@ public class DriverStationSimTest {
}
@Test
public void testSetGameSpecificMessage() {
void testSetGameSpecificMessage() {
HAL.initialize(500, 0);
DriverStationSim.resetData();
@@ -249,7 +249,7 @@ public class DriverStationSimTest {
}
@Test
public void testSetEventName() {
void testSetEventName() {
HAL.initialize(500, 0);
DriverStationSim.resetData();

View File

@@ -17,10 +17,10 @@ import edu.wpi.first.wpilibj.RobotController;
import edu.wpi.first.wpilibj.motorcontrol.PWMVictorSPX;
import org.junit.jupiter.api.Test;
public class ElevatorSimTest {
class ElevatorSimTest {
@Test
@SuppressWarnings({"LocalVariableName", "resource"})
public void testStateSpaceSimWithElevator() {
void testStateSpaceSimWithElevator() {
RoboRioSim.resetData();
var controller = new PIDController(10, 0, 0);
@@ -61,7 +61,7 @@ public class ElevatorSimTest {
}
@Test
public void testMinMax() {
void testMinMax() {
var plant =
LinearSystemId.createElevatorSystem(
DCMotor.getVex775Pro(4), 8.0, 0.75 * 25.4 / 1000.0, 14.67);
@@ -92,7 +92,7 @@ public class ElevatorSimTest {
}
@Test
public void testStability() {
void testStability() {
var sim = new ElevatorSim(DCMotor.getVex775Pro(4), 100, 4, Units.inchesToMeters(0.5), 0, 10);
sim.setState(VecBuilder.fill(0, 0));

View File

@@ -15,7 +15,7 @@ import edu.wpi.first.wpilibj.simulation.testutils.DoubleCallback;
import edu.wpi.first.wpilibj.simulation.testutils.IntCallback;
import org.junit.jupiter.api.Test;
public class RoboRioSimTest {
class RoboRioSimTest {
@Test
void testFPGAButton() {
RoboRioSim.resetData();

View File

@@ -11,7 +11,7 @@ import edu.wpi.first.math.system.plant.DCMotor;
import edu.wpi.first.math.util.Units;
import org.junit.jupiter.api.Test;
public class SingleJointedArmSimTest {
class SingleJointedArmSimTest {
SingleJointedArmSim m_sim =
new SingleJointedArmSim(
DCMotor.getVex775Pro(2),
@@ -24,7 +24,7 @@ public class SingleJointedArmSimTest {
true);
@Test
public void testArmDisabled() {
void testArmDisabled() {
m_sim.setState(VecBuilder.fill(0.0, 0.0));
for (int i = 0; i < 12 / 0.02; i++) {