mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Disable frivolous PMD warnings and enable PMD in ntcore (#3419)
Some valid warnings like throwing NullPointerException or using a for loop instead of System.arraycopy() were fixed. Abstract classes marked with PMD.AbstractClassWithoutAbstractMethod were made concrete because they already had protected constructors. Fixes #1697.
This commit is contained in:
@@ -52,7 +52,7 @@ public class LinearSystemLoopTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"LocalVariableName", "PMD.AvoidInstantiatingObjectsInLoops"})
|
||||
@SuppressWarnings("LocalVariableName")
|
||||
public void testStateSpaceEnabled() {
|
||||
|
||||
m_loop.reset(VecBuilder.fill(0, 0));
|
||||
@@ -82,7 +82,7 @@ public class LinearSystemLoopTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"LocalVariableName", "PMD.AvoidInstantiatingObjectsInLoops"})
|
||||
@SuppressWarnings("LocalVariableName")
|
||||
public void testFlywheelEnabled() {
|
||||
|
||||
LinearSystem<N1, N1, N1> plant =
|
||||
|
||||
@@ -21,7 +21,6 @@ class RamseteControllerTest {
|
||||
private static final double kAngularTolerance = Math.toRadians(2);
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
|
||||
void testReachesReference() {
|
||||
final var controller = new RamseteController(2.0, 0.7);
|
||||
var robotPose = new Pose2d(2.7, 23.0, Rotation2d.fromDegrees(0.0));
|
||||
|
||||
@@ -22,11 +22,7 @@ import java.util.Random;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class DifferentialDrivePoseEstimatorTest {
|
||||
@SuppressWarnings({
|
||||
"LocalVariableName",
|
||||
"PMD.ExcessiveMethodLength",
|
||||
"PMD.AvoidInstantiatingObjectsInLoops"
|
||||
})
|
||||
@SuppressWarnings("LocalVariableName")
|
||||
@Test
|
||||
public void testAccuracy() {
|
||||
var estimator =
|
||||
|
||||
@@ -98,11 +98,7 @@ public class ExtendedKalmanFilterTest {
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings({
|
||||
"LocalVariableName",
|
||||
"PMD.AvoidInstantiatingObjectsInLoops",
|
||||
"PMD.ExcessiveMethodLength"
|
||||
})
|
||||
@SuppressWarnings("LocalVariableName")
|
||||
@Test
|
||||
public void testConvergence() {
|
||||
double dtSeconds = 0.00505;
|
||||
|
||||
@@ -72,7 +72,6 @@ public class KalmanFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
|
||||
public void testSwerveKFStationary() {
|
||||
|
||||
var random = new Random();
|
||||
@@ -121,7 +120,6 @@ public class KalmanFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
|
||||
public void testSwerveKFMovingWithoutAccelerating() {
|
||||
|
||||
var random = new Random();
|
||||
@@ -178,7 +176,7 @@ public class KalmanFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"LocalVariableName", "PMD.AvoidInstantiatingObjectsInLoops"})
|
||||
@SuppressWarnings("LocalVariableName")
|
||||
public void testSwerveKFMovingOverTrajectory() {
|
||||
|
||||
var random = new Random();
|
||||
|
||||
@@ -20,11 +20,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MecanumDrivePoseEstimatorTest {
|
||||
@Test
|
||||
@SuppressWarnings({
|
||||
"LocalVariableName",
|
||||
"PMD.AvoidInstantiatingObjectsInLoops",
|
||||
"PMD.ExcessiveMethodLength"
|
||||
})
|
||||
@SuppressWarnings("LocalVariableName")
|
||||
public void testAccuracy() {
|
||||
var kinematics =
|
||||
new MecanumDriveKinematics(
|
||||
|
||||
@@ -20,11 +20,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
public class SwerveDrivePoseEstimatorTest {
|
||||
@Test
|
||||
@SuppressWarnings({
|
||||
"LocalVariableName",
|
||||
"PMD.AvoidInstantiatingObjectsInLoops",
|
||||
"PMD.ExcessiveMethodLength"
|
||||
})
|
||||
@SuppressWarnings("LocalVariableName")
|
||||
public void testAccuracy() {
|
||||
var kinematics =
|
||||
new SwerveDriveKinematics(
|
||||
|
||||
@@ -103,11 +103,7 @@ public class UnscentedKalmanFilterTest {
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings({
|
||||
"LocalVariableName",
|
||||
"PMD.AvoidInstantiatingObjectsInLoops",
|
||||
"PMD.ExcessiveMethodLength"
|
||||
})
|
||||
@SuppressWarnings("LocalVariableName")
|
||||
@Test
|
||||
public void testConvergence() {
|
||||
double dtSeconds = 0.00505;
|
||||
@@ -293,7 +289,7 @@ public class UnscentedKalmanFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"LocalVariableName", "ParameterName", "PMD.AvoidInstantiatingObjectsInLoops"})
|
||||
@SuppressWarnings({"LocalVariableName", "ParameterName"})
|
||||
public void testLinearUKF() {
|
||||
var dt = 0.020;
|
||||
var plant = LinearSystemId.identifyVelocitySystem(0.02, 0.006);
|
||||
|
||||
@@ -23,7 +23,7 @@ class CubicHermiteSplineTest {
|
||||
private static final double kMaxDy = 0.00127;
|
||||
private static final double kMaxDtheta = 0.0872;
|
||||
|
||||
@SuppressWarnings({"ParameterName", "PMD.UnusedLocalVariable"})
|
||||
@SuppressWarnings("ParameterName")
|
||||
private void run(Pose2d a, List<Translation2d> waypoints, Pose2d b) {
|
||||
// Start the timer.
|
||||
// var start = System.nanoTime();
|
||||
|
||||
@@ -20,7 +20,7 @@ class QuinticHermiteSplineTest {
|
||||
private static final double kMaxDy = 0.00127;
|
||||
private static final double kMaxDtheta = 0.0872;
|
||||
|
||||
@SuppressWarnings({"ParameterName", "PMD.UnusedLocalVariable"})
|
||||
@SuppressWarnings("ParameterName")
|
||||
private void run(Pose2d a, Pose2d b) {
|
||||
// Start the timer.
|
||||
// var start = System.nanoTime();
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.Collections;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class DifferentialDriveKinematicsConstraintTest {
|
||||
@SuppressWarnings({"LocalVariableName", "PMD.AvoidInstantiatingObjectsInLoops"})
|
||||
@SuppressWarnings("LocalVariableName")
|
||||
@Test
|
||||
void testDifferentialDriveKinematicsConstraint() {
|
||||
double maxVelocity = Units.feetToMeters(12.0); // 12 feet per second
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Collections;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class DifferentialDriveVoltageConstraintTest {
|
||||
@SuppressWarnings({"LocalVariableName", "PMD.AvoidInstantiatingObjectsInLoops"})
|
||||
@SuppressWarnings("LocalVariableName")
|
||||
@Test
|
||||
void testDifferentialDriveVoltageConstraint() {
|
||||
// Pick an unreasonably large kA to ensure the constraint has to do some work
|
||||
|
||||
@@ -10,7 +10,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
|
||||
class TrapezoidProfileTest {
|
||||
private static final double kDt = 0.01;
|
||||
|
||||
|
||||
@@ -19,6 +19,12 @@ import org.junit.jupiter.api.DynamicTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestFactory;
|
||||
|
||||
// Declaring this class abstract prevents UtilityClassTest from running on itself and throwing the
|
||||
// following exception:
|
||||
//
|
||||
// org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered
|
||||
// for parameter [java.lang.Class<T> arg0] in constructor [protected
|
||||
// edu.wpi.first.wpilibj.UtilityClassTest(java.lang.Class<T>)].
|
||||
@SuppressWarnings("PMD.AbstractClassWithoutAbstractMethod")
|
||||
public abstract class UtilityClassTest<T> {
|
||||
private final Class<T> m_clazz;
|
||||
|
||||
Reference in New Issue
Block a user