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:
Tyler Veness
2021-06-09 07:01:00 -07:00
committed by GitHub
parent 8284075ee4
commit c1e128bd5a
93 changed files with 154 additions and 326 deletions

View File

@@ -23,7 +23,6 @@ import org.ejml.simple.SimpleMatrix;
* @param <R> The number of rows in this matrix.
* @param <C> The number of columns in this matrix.
*/
@SuppressWarnings("PMD.ExcessivePublicCount")
public class Matrix<R extends Num, C extends Num> {
protected final SimpleMatrix m_storage;
@@ -531,7 +530,6 @@ public class Matrix<R extends Num, C extends Num> {
* @throws RuntimeException if the matrix could not be decomposed(ie. is not positive
* semidefinite).
*/
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
public Matrix<R, C> lltDecompose(boolean lowerTriangular) {
SimpleMatrix temp = m_storage.copy();

View File

@@ -216,7 +216,6 @@ public final class SimpleMatrixUtils {
* @throws RuntimeException if the matrix could not be decomposed (ie. is not positive
* semidefinite).
*/
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
public static SimpleMatrix lltDecompose(SimpleMatrix src, boolean lowerTriangular) {
SimpleMatrix temp = src.copy();

View File

@@ -171,7 +171,6 @@ public class VecBuilder<N extends Num> extends MatBuilder<N, N1> {
* @param n9 the ninth element.
* @param n10 the tenth element.
*/
@SuppressWarnings("PMD.ExcessiveParameterList")
public static Vector<N10> fill(
double n1,
double n2,

View File

@@ -101,7 +101,7 @@ public class ExtendedKalmanFilter<States extends Num, Inputs extends Num, Output
* @param addFuncX A function that adds two state vectors.
* @param dtSeconds Nominal discretization timestep.
*/
@SuppressWarnings({"ParameterName", "PMD.ExcessiveParameterList"})
@SuppressWarnings("ParameterName")
public ExtendedKalmanFilter(
Nat<States> states,
Nat<Inputs> inputs,

View File

@@ -60,7 +60,7 @@ public class KalmanFilterLatencyCompensator<S extends Num, I extends Num, O exte
* @param globalMeasurementCorrect The function take calls correct() on the observer.
* @param timestampSeconds The timestamp of the measurement.
*/
@SuppressWarnings({"ParameterName", "PMD.AvoidInstantiatingObjectsInLoops"})
@SuppressWarnings("ParameterName")
public <R extends Num> void applyPastGlobalMeasurement(
Nat<R> rows,
KalmanTypeFilter<S, I, O> observer,

View File

@@ -26,7 +26,7 @@ import org.ejml.simple.SimpleMatrix;
* an estimate of the true covariance (as opposed to a linearized version of it). This means that
* the UKF works with nonlinear systems.
*/
@SuppressWarnings({"MemberName", "ClassTypeParameterName", "PMD.TooManyFields"})
@SuppressWarnings({"MemberName", "ClassTypeParameterName"})
public class UnscentedKalmanFilter<States extends Num, Inputs extends Num, Outputs extends Num>
implements KalmanTypeFilter<States, Inputs, Outputs> {
@@ -108,7 +108,7 @@ public class UnscentedKalmanFilter<States extends Num, Inputs extends Num, Outpu
* @param addFuncX A function that adds two state vectors.
* @param nominalDtSeconds Nominal discretization timestep.
*/
@SuppressWarnings({"ParameterName", "PMD.ExcessiveParameterList"})
@SuppressWarnings("ParameterName")
public UnscentedKalmanFilter(
Nat<States> states,
Nat<Outputs> outputs,
@@ -144,7 +144,7 @@ public class UnscentedKalmanFilter<States extends Num, Inputs extends Num, Outpu
reset();
}
@SuppressWarnings({"ParameterName", "LocalVariableName", "PMD.CyclomaticComplexity"})
@SuppressWarnings({"ParameterName", "LocalVariableName"})
static <S extends Num, C extends Num> Pair<Matrix<C, N1>, Matrix<C, C>> unscentedTransform(
Nat<S> s,
Nat<C> dim,

View File

@@ -83,7 +83,7 @@ public class SwerveDriveKinematics {
* attainable max velocity. Use the {@link #normalizeWheelSpeeds(SwerveModuleState[], double)
* normalizeWheelSpeeds} function to rectify this issue.
*/
@SuppressWarnings({"LocalVariableName", "PMD.AvoidInstantiatingObjectsInLoops"})
@SuppressWarnings("LocalVariableName")
public SwerveModuleState[] toSwerveModuleStates(
ChassisSpeeds chassisSpeeds, Translation2d centerOfRotationMeters) {
if (!centerOfRotationMeters.equals(m_prevCoR)) {

View File

@@ -48,7 +48,6 @@ public final class SplineHelper {
* @param waypoints The waypoints
* @return List of splines.
*/
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public static QuinticHermiteSpline[] getQuinticSplinesFromWaypoints(List<Pose2d> waypoints) {
QuinticHermiteSpline[] splines = new QuinticHermiteSpline[waypoints.size() - 1];
for (int i = 0; i < waypoints.size() - 1; ++i) {
@@ -79,11 +78,7 @@ public final class SplineHelper {
* @return A vector of cubic hermite splines that interpolate through the provided waypoints and
* control vectors.
*/
@SuppressWarnings({
"LocalVariableName",
"PMD.ExcessiveMethodLength",
"PMD.AvoidInstantiatingObjectsInLoops"
})
@SuppressWarnings("LocalVariableName")
public static CubicHermiteSpline[] getCubicSplinesFromControlVectors(
Spline.ControlVector start, Translation2d[] waypoints, Spline.ControlVector end) {
@@ -208,7 +203,7 @@ public final class SplineHelper {
* @param controlVectors The control vectors.
* @return A vector of quintic hermite splines that interpolate through the provided waypoints.
*/
@SuppressWarnings({"LocalVariableName", "PMD.AvoidInstantiatingObjectsInLoops"})
@SuppressWarnings("LocalVariableName")
public static QuinticHermiteSpline[] getQuinticSplinesFromControlVectors(
Spline.ControlVector[] controlVectors) {
QuinticHermiteSpline[] splines = new QuinticHermiteSpline[controlVectors.length - 1];

View File

@@ -96,7 +96,6 @@ public final class SplineParameterizer {
* @throws MalformedSplineException When the spline is malformed (e.g. has close adjacent points
* with approximately opposing headings)
*/
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public static List<PoseWithCurvature> parameterize(Spline spline, double t0, double t1) {
var splinePoints = new ArrayList<PoseWithCurvature>();

View File

@@ -152,7 +152,6 @@ public class Trajectory {
* @param transform The transform to transform the trajectory by.
* @return The transformed trajectory.
*/
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public Trajectory transformBy(Transform2d transform) {
var firstState = m_states.get(0);
var firstPose = firstState.poseMeters;
@@ -214,7 +213,6 @@ public class Trajectory {
* @param other The trajectory to concatenate.
* @return The concatenated trajectory.
*/
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public Trajectory concatenate(Trajectory other) {
// If this is a default constructed trajectory with no states, then we can
// simply return the rhs trajectory.

View File

@@ -138,7 +138,6 @@ public final class TrajectoryGenerator {
* @param config The configuration for the trajectory.
* @return The generated trajectory.
*/
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public static Trajectory generateTrajectory(
ControlVectorList controlVectors, TrajectoryConfig config) {
final var flip = new Transform2d(new Translation2d(), Rotation2d.fromDegrees(180.0));

View File

@@ -54,12 +54,6 @@ public final class TrajectoryParameterizer {
* from a -&gt; b -&gt; ... -&gt; z as defined in the waypoints.
* @return The trajectory.
*/
@SuppressWarnings({
"PMD.ExcessiveMethodLength",
"PMD.CyclomaticComplexity",
"PMD.NPathComplexity",
"PMD.AvoidInstantiatingObjectsInLoops"
})
public static Trajectory timeParameterizeTrajectory(
List<PoseWithCurvature> points,
List<TrajectoryConstraint> constraints,

View File

@@ -23,7 +23,6 @@ public final class TrajectoryUtil {
* @param elements A double[] containing the raw elements of the trajectory.
* @return A trajectory created from the elements.
*/
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private static Trajectory createTrajectoryFromElements(double[] elements) {
// Make sure that the elements have the correct length.
if (elements.length % 7 != 0) {