[build] Upgrade to PMD 7.2.0 (#6718)

This commit is contained in:
Gold856
2024-06-09 01:08:23 -04:00
committed by GitHub
parent e2dcbd016d
commit b0cc84a9c7
64 changed files with 148 additions and 183 deletions

View File

@@ -202,7 +202,7 @@ public class Matrix<R extends Num, C extends Num> {
* @return The mean value of this matrix.
*/
public final double mean() {
return this.elementSum() / (double) this.m_storage.getNumElements();
return this.elementSum() / this.m_storage.getNumElements();
}
/**
@@ -728,12 +728,10 @@ public class Matrix<R extends Num, C extends Num> {
*/
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
return other instanceof Matrix<?, ?> matrix
&& !MatrixFeatures_DDRM.hasUncountable(matrix.m_storage.getDDRM())
&& MatrixFeatures_DDRM.isEquals(this.m_storage.getDDRM(), matrix.m_storage.getDDRM());
return this == other
|| other instanceof Matrix<?, ?> matrix
&& !MatrixFeatures_DDRM.hasUncountable(matrix.m_storage.getDDRM())
&& MatrixFeatures_DDRM.isEquals(this.m_storage.getDDRM(), matrix.m_storage.getDDRM());
}
@Override

View File

@@ -71,12 +71,10 @@ public class Pair<A, B> {
*/
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
return obj instanceof Pair<?, ?> other
&& Objects.equals(m_first, other.getFirst())
&& Objects.equals(m_second, other.getSecond());
return obj == this
|| obj instanceof Pair<?, ?> other
&& Objects.equals(m_first, other.getFirst())
&& Objects.equals(m_second, other.getSecond());
}
@Override

View File

@@ -171,7 +171,7 @@ public class KalmanFilterLatencyCompensator<S extends Num, I extends Num, O exte
}
/** This class contains all the information about our observer at a given time. */
public class ObserverSnapshot {
public final class ObserverSnapshot {
/** The state estimate. */
public final Matrix<S, N1> xHat;

View File

@@ -271,7 +271,7 @@ public class PoseEstimator<T> {
* Represents an odometry record. The record contains the inputs provided as well as the pose that
* was observed based on these inputs, as well as the previous record and its inputs.
*/
private class InterpolationRecord implements Interpolatable<InterpolationRecord> {
private final class InterpolationRecord implements Interpolatable<InterpolationRecord> {
// The pose observed given the current sensor inputs and the previous pose.
private final Pose2d poseMeters;
@@ -325,13 +325,11 @@ public class PoseEstimator<T> {
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
return obj instanceof PoseEstimator<?>.InterpolationRecord record
&& Objects.equals(gyroAngle, record.gyroAngle)
&& Objects.equals(wheelPositions, record.wheelPositions)
&& Objects.equals(poseMeters, record.poseMeters);
return this == obj
|| obj instanceof PoseEstimator<?>.InterpolationRecord record
&& Objects.equals(gyroAngle, record.gyroAngle)
&& Objects.equals(wheelPositions, record.wheelPositions)
&& Objects.equals(poseMeters, record.poseMeters);
}
@Override

View File

@@ -391,13 +391,11 @@ public class ChassisSpeeds implements ProtobufSerializable, StructSerializable {
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
return o instanceof ChassisSpeeds c
&& vxMetersPerSecond == c.vxMetersPerSecond
&& vyMetersPerSecond == c.vyMetersPerSecond
&& omegaRadiansPerSecond == c.omegaRadiansPerSecond;
return o == this
|| o instanceof ChassisSpeeds c
&& vxMetersPerSecond == c.vxMetersPerSecond
&& vyMetersPerSecond == c.vyMetersPerSecond
&& omegaRadiansPerSecond == c.omegaRadiansPerSecond;
}
@Override

View File

@@ -105,6 +105,7 @@ public class CubicHermiteSpline extends Spline {
*
* @return The hermite basis matrix for cubic hermite spline interpolation.
*/
@SuppressWarnings("PMD.UnnecessaryVarargsArrayCreation")
private SimpleMatrix makeHermiteBasis() {
if (hermiteBasis == null) {
// Given P(i), P'(i), P(i+1), P'(i+1), the control vectors, we want to find
@@ -148,6 +149,7 @@ public class CubicHermiteSpline extends Spline {
* @param finalVector The control vector for the final point.
* @return The control vector matrix for a dimension.
*/
@SuppressWarnings("PMD.UnnecessaryVarargsArrayCreation")
private SimpleMatrix getControlVectorFromArrays(double[] initialVector, double[] finalVector) {
if (initialVector.length < 2 || finalVector.length < 2) {
throw new IllegalArgumentException("Size of vectors must be 2 or greater.");

View File

@@ -105,6 +105,7 @@ public class QuinticHermiteSpline extends Spline {
*
* @return The hermite basis matrix for quintic hermite spline interpolation.
*/
@SuppressWarnings("PMD.UnnecessaryVarargsArrayCreation")
private SimpleMatrix makeHermiteBasis() {
if (hermiteBasis == null) {
// Given P(i), P'(i), P"(i), P(i+1), P'(i+1), P"(i+1), the control vectors,
@@ -156,6 +157,7 @@ public class QuinticHermiteSpline extends Spline {
* @param finalVector The control vector for the final point.
* @return The control vector matrix for a dimension.
*/
@SuppressWarnings("PMD.UnnecessaryVarargsArrayCreation")
private SimpleMatrix getControlVectorFromArrays(double[] initialVector, double[] finalVector) {
if (initialVector.length != 3 || finalVector.length != 3) {
throw new IllegalArgumentException("Size of vectors must be 3");

View File

@@ -257,7 +257,7 @@ public final class SplineHelper {
CubicHermiteSpline cb = new CubicHermiteSpline(bInitial.x, bFinal.x, bInitial.y, bFinal.y);
// Calculate the second derivatives at the knot points.
SimpleMatrix bases = new SimpleMatrix(4, 1, true, new double[] {1, 1, 1, 1});
SimpleMatrix bases = new SimpleMatrix(4, 1, true, 1, 1, 1, 1);
SimpleMatrix combinedA = ca.getCoefficients().mult(bases);
double ddxA = combinedA.get(4, 0);

View File

@@ -57,7 +57,7 @@ public final class SplineParameterizer {
}
/** Exception for malformed splines. */
public static class MalformedSplineException extends RuntimeException {
public static final class MalformedSplineException extends RuntimeException {
/**
* Create a new exception with the given message.
*

View File

@@ -70,7 +70,7 @@ public class ExponentialProfile {
}
/** Profile constraints. */
public static class Constraints {
public static final class Constraints {
/** Maximum unsigned input voltage. */
public final double maxInput;