[build] Bring naming checkstyle rules up to date with Google Style guide (#1781)

Also update Checkstyle to 8.38.

Google changed their style guide from the last time we imported it. This PR brings in those naming changes. The change they made is allowing single letter member, parameter, and local variable names. They also added a lambda naming scheme and I thought it would be good to bring that in too.
This commit is contained in:
Austin Shalit
2020-12-29 09:27:48 -08:00
committed by GitHub
parent 8c8ec5e63e
commit 6e1919414e
70 changed files with 224 additions and 285 deletions

View File

@@ -50,7 +50,6 @@ public class ADXL345_SPI implements Accelerometer, Sendable, AutoCloseable {
/**
* The integer value representing this enumeration.
*/
@SuppressWarnings("MemberName")
public final byte value;
Axes(byte value) {

View File

@@ -46,7 +46,6 @@ public class ADXL362 implements Accelerometer, Sendable, AutoCloseable {
kY((byte) 0x02),
kZ((byte) 0x04);
@SuppressWarnings("MemberName")
public final byte value;
Axes(byte value) {

View File

@@ -112,7 +112,6 @@ public class AnalogTriggerOutput extends DigitalSource implements Sendable {
kRisingPulse(AnalogJNI.AnalogTriggerType.kRisingPulse),
kFallingPulse(AnalogJNI.AnalogTriggerType.kFallingPulse);
@SuppressWarnings("MemberName")
private final int value;
AnalogTriggerType(int value) {

View File

@@ -71,7 +71,7 @@ public final class CameraServer {
private int m_nextPort;
private String[] m_addresses;
@SuppressWarnings("JavadocMethod")
@SuppressWarnings("MissingJavadocMethod")
private static String makeSourceValue(int source) {
switch (VideoSource.getKindFromInt(CameraServerJNI.getSourceKind(source))) {
case kUsb:
@@ -93,12 +93,12 @@ public final class CameraServer {
}
}
@SuppressWarnings("JavadocMethod")
@SuppressWarnings("MissingJavadocMethod")
private static String makeStreamValue(String address, int port) {
return "mjpg:http://" + address + ":" + port + "/?action=stream";
}
@SuppressWarnings({"JavadocMethod", "PMD.AvoidUsingHardCodedIP"})
@SuppressWarnings({"MissingJavadocMethod", "PMD.AvoidUsingHardCodedIP"})
private synchronized String[] getSinkStreamValues(int sink) {
// Ignore all but MjpegServer
if (VideoSink.getKindFromInt(CameraServerJNI.getSinkKind(sink)) != VideoSink.Kind.kMjpeg) {
@@ -128,7 +128,7 @@ public final class CameraServer {
return values.toArray(new String[0]);
}
@SuppressWarnings({"JavadocMethod", "PMD.AvoidUsingHardCodedIP"})
@SuppressWarnings({"MissingJavadocMethod", "PMD.AvoidUsingHardCodedIP"})
private synchronized String[] getSourceStreamValues(int source) {
// Ignore all but HttpCamera
if (VideoSource.getKindFromInt(CameraServerJNI.getSourceKind(source))
@@ -163,7 +163,7 @@ public final class CameraServer {
return values;
}
@SuppressWarnings({"JavadocMethod", "PMD.AvoidUsingHardCodedIP"})
@SuppressWarnings({"MissingJavadocMethod", "PMD.AvoidUsingHardCodedIP"})
private synchronized void updateStreamValues() {
// Over all the sinks...
for (VideoSink i : m_sinks.values()) {
@@ -206,7 +206,7 @@ public final class CameraServer {
}
}
@SuppressWarnings("JavadocMethod")
@SuppressWarnings("MissingJavadocMethod")
private static String pixelFormatToString(PixelFormat pixelFormat) {
switch (pixelFormat) {
case kMJPEG:
@@ -226,13 +226,13 @@ public final class CameraServer {
/// Provide string description of video mode.
/// The returned string is "{width}x{height} {format} {fps} fps".
@SuppressWarnings("JavadocMethod")
@SuppressWarnings("MissingJavadocMethod")
private static String videoModeToString(VideoMode mode) {
return mode.width + "x" + mode.height + " " + pixelFormatToString(mode.pixelFormat)
+ " " + mode.fps + " fps";
}
@SuppressWarnings("JavadocMethod")
@SuppressWarnings("MissingJavadocMethod")
private static String[] getSourceModeValues(int sourceHandle) {
VideoMode[] modes = CameraServerJNI.enumerateSourceVideoModes(sourceHandle);
String[] modeStrings = new String[modes.length];
@@ -242,7 +242,7 @@ public final class CameraServer {
return modeStrings;
}
@SuppressWarnings({"JavadocMethod", "PMD.CyclomaticComplexity"})
@SuppressWarnings({"MissingJavadocMethod", "PMD.CyclomaticComplexity"})
private static void putSourcePropertyValue(NetworkTable table, VideoEvent event, boolean isNew) {
String name;
String infoName;
@@ -295,7 +295,7 @@ public final class CameraServer {
}
}
@SuppressWarnings({"JavadocMethod", "PMD.UnusedLocalVariable", "PMD.ExcessiveMethodLength",
@SuppressWarnings({"MissingJavadocMethod", "PMD.UnusedLocalVariable", "PMD.ExcessiveMethodLength",
"PMD.NPathComplexity"})
private CameraServer() {
m_defaultUsbDevice = new AtomicInteger();

View File

@@ -49,7 +49,6 @@ public class Counter implements CounterBase, PIDSource, Sendable, AutoCloseable
*/
kExternalDirection(3);
@SuppressWarnings("MemberName")
public final int value;
Mode(int value) {

View File

@@ -30,7 +30,6 @@ public interface CounterBase {
*/
k4X(2);
@SuppressWarnings("MemberName")
public final int value;
EncodingType(int value) {

View File

@@ -31,7 +31,6 @@ public class Encoder implements CounterBase, PIDSource, Sendable, AutoCloseable
public enum IndexingType {
kResetWhileHigh(0), kResetWhileLow(1), kResetOnFallingEdge(2), kResetOnRisingEdge(3);
@SuppressWarnings("MemberName")
public final int value;
IndexingType(int value) {
@@ -42,12 +41,10 @@ public class Encoder implements CounterBase, PIDSource, Sendable, AutoCloseable
/**
* The a source.
*/
@SuppressWarnings("MemberName")
protected DigitalSource m_aSource; // the A phase of the quad encoder
/**
* The b source.
*/
@SuppressWarnings("MemberName")
protected DigitalSource m_bSource; // the B phase of the quad encoder
/**
* The index source.

View File

@@ -14,7 +14,7 @@ import java.io.File;
* the RoboRIO path /home/lvuser in a simulation-compatible way.</p>
*/
public final class Filesystem {
private Filesystem() { }
private Filesystem() {}
/**
* Obtains the current working path that the program was launched with.

View File

@@ -39,7 +39,6 @@ public abstract class GenericHID {
kHIDFlight(23),
kHID1stPerson(24);
@SuppressWarnings("MemberName")
public final int value;
@SuppressWarnings("PMD.UseConcurrentHashMap")
private static final Map<Integer, HIDType> map = new HashMap<>();
@@ -65,7 +64,6 @@ public abstract class GenericHID {
public enum Hand {
kLeft(0), kRight(1);
@SuppressWarnings("MemberName")
public final int value;
Hand(int value) {

View File

@@ -24,7 +24,6 @@ public class I2C implements AutoCloseable {
public enum Port {
kOnboard(0), kMXP(1);
@SuppressWarnings("MemberName")
public final int value;
Port(int value) {

View File

@@ -14,11 +14,10 @@ import edu.wpi.first.hal.util.AllocationException;
* Base for sensors to be used with interrupts.
*/
public abstract class InterruptableSensorBase implements AutoCloseable {
@SuppressWarnings("JavadocMethod")
@SuppressWarnings("MissingJavadocMethod")
public enum WaitResult {
kTimeout(0x0), kRisingEdge(0x1), kFallingEdge(0x100), kBoth(0x101);
@SuppressWarnings("MemberName")
public final int value;
WaitResult(int value) {

View File

@@ -27,7 +27,6 @@ public class Joystick extends GenericHID {
public enum AxisType {
kX(0), kY(1), kZ(2), kTwist(3), kThrottle(4);
@SuppressWarnings("MemberName")
public final int value;
AxisType(int value) {
@@ -41,7 +40,6 @@ public class Joystick extends GenericHID {
public enum ButtonType {
kTrigger(1), kTop(2);
@SuppressWarnings("MemberName")
public final int value;
ButtonType(int value) {
@@ -55,7 +53,6 @@ public class Joystick extends GenericHID {
private enum Button {
kTrigger(1), kTop(2);
@SuppressWarnings("MemberName")
public final int value;
Button(int value) {
@@ -69,7 +66,6 @@ public class Joystick extends GenericHID {
private enum Axis {
kX(0), kY(1), kZ(2), kTwist(3), kThrottle(4), kNumAxes(5);
@SuppressWarnings("MemberName")
public final int value;
Axis(int value) {

View File

@@ -7,7 +7,6 @@ package edu.wpi.first.wpilibj;
@Deprecated(since = "2020", forRemoval = true)
@SuppressWarnings("SummaryJavadoc")
public interface PIDInterface {
@SuppressWarnings("ParameterName")
void setPID(double p, double i, double d);
double getP();

View File

@@ -267,7 +267,7 @@ public abstract class RobotBase implements AutoCloseable {
*/
public abstract void endCompetition();
@SuppressWarnings("JavadocMethod")
@SuppressWarnings("MissingJavadocMethod")
public static boolean getBooleanProperty(String name, boolean defaultValue) {
String propVal = System.getProperty(name);
if (propVal == null) {

View File

@@ -30,7 +30,6 @@ public class RobotDrive extends MotorSafety implements AutoCloseable {
public enum MotorType {
kFrontLeft(0), kFrontRight(1), kRearLeft(2), kRearRight(3);
@SuppressWarnings("MemberName")
public final int value;
MotorType(int value) {
@@ -445,29 +444,24 @@ public class RobotDrive extends MotorSafety implements AutoCloseable {
* @param gyroAngle The current angle reading from the gyro. Use this to implement field-oriented
* controls.
*/
@SuppressWarnings("ParameterName")
public void mecanumDrive_Cartesian(double x, double y, double rotation, double gyroAngle) {
if (!kMecanumCartesian_Reported) {
HAL.report(tResourceType.kResourceType_RobotDrive, tInstances.kRobotDrive_MecanumCartesian,
getNumMotors());
kMecanumCartesian_Reported = true;
}
@SuppressWarnings("LocalVariableName")
double xIn = x;
@SuppressWarnings("LocalVariableName")
double yIn = y;
// Negate y for the joystick.
yIn = -yIn;
y = -y;
// Compensate for gyro angle.
double[] rotated = rotateVector(xIn, yIn, gyroAngle);
xIn = rotated[0];
yIn = rotated[1];
double[] rotated = rotateVector(x, y, gyroAngle);
x = rotated[0];
y = rotated[1];
double[] wheelSpeeds = new double[kMaxNumberOfMotors];
wheelSpeeds[MotorType.kFrontLeft.value] = xIn + yIn + rotation;
wheelSpeeds[MotorType.kFrontRight.value] = -xIn + yIn - rotation;
wheelSpeeds[MotorType.kRearLeft.value] = -xIn + yIn + rotation;
wheelSpeeds[MotorType.kRearRight.value] = xIn + yIn - rotation;
wheelSpeeds[MotorType.kFrontLeft.value] = x + y + rotation;
wheelSpeeds[MotorType.kFrontRight.value] = -x + y - rotation;
wheelSpeeds[MotorType.kRearLeft.value] = -x + y + rotation;
wheelSpeeds[MotorType.kRearRight.value] = x + y - rotation;
normalize(wheelSpeeds);
m_frontLeftMotor.set(wheelSpeeds[MotorType.kFrontLeft.value] * m_maxOutput);
@@ -592,7 +586,6 @@ public class RobotDrive extends MotorSafety implements AutoCloseable {
/**
* Rotate a vector in Cartesian space.
*/
@SuppressWarnings("ParameterName")
protected static double[] rotateVector(double x, double y, double angle) {
double cosA = Math.cos(angle * (Math.PI / 180.0));
double sinA = Math.sin(angle * (Math.PI / 180.0));

View File

@@ -4,7 +4,7 @@
package edu.wpi.first.wpilibj;
@SuppressWarnings("JavadocMethod")
@SuppressWarnings("MissingJavadocMethod")
public final class RobotState {
public static boolean isDisabled() {
return DriverStation.getInstance().isDisabled();

View File

@@ -21,7 +21,6 @@ public class SPI implements AutoCloseable {
public enum Port {
kOnboardCS0(0), kOnboardCS1(1), kOnboardCS2(2), kOnboardCS3(3), kMXP(4);
@SuppressWarnings("MemberName")
public final int value;
Port(int value) {

View File

@@ -78,9 +78,9 @@ public final class SensorUtil {
if (!SolenoidJNI.checkSolenoidModule(moduleNumber)) {
StringBuilder buf = new StringBuilder();
buf.append("Requested solenoid module is out of range. Minimum: 0, Maximum: ")
.append(kPCMModules)
.append(", Requested: ")
.append(moduleNumber);
.append(kPCMModules)
.append(", Requested: ")
.append(moduleNumber);
throw new IllegalArgumentException(buf.toString());
}
}
@@ -95,9 +95,9 @@ public final class SensorUtil {
if (!DIOJNI.checkDIOChannel(channel)) {
StringBuilder buf = new StringBuilder();
buf.append("Requested DIO channel is out of range. Minimum: 0, Maximum: ")
.append(kDigitalChannels)
.append(", Requested: ")
.append(channel);
.append(kDigitalChannels)
.append(", Requested: ")
.append(channel);
throw new IllegalArgumentException(buf.toString());
}
}
@@ -112,9 +112,9 @@ public final class SensorUtil {
if (!RelayJNI.checkRelayChannel(channel)) {
StringBuilder buf = new StringBuilder();
buf.append("Requested relay channel is out of range. Minimum: 0, Maximum: ")
.append(kRelayChannels)
.append(", Requested: ")
.append(channel);
.append(kRelayChannels)
.append(", Requested: ")
.append(channel);
throw new IllegalArgumentException(buf.toString());
}
}
@@ -129,9 +129,9 @@ public final class SensorUtil {
if (!PWMJNI.checkPWMChannel(channel)) {
StringBuilder buf = new StringBuilder();
buf.append("Requested PWM channel is out of range. Minimum: 0, Maximum: ")
.append(kPwmChannels)
.append(", Requested: ")
.append(channel);
.append(kPwmChannels)
.append(", Requested: ")
.append(channel);
throw new IllegalArgumentException(buf.toString());
}
}
@@ -146,9 +146,9 @@ public final class SensorUtil {
if (!AnalogJNI.checkAnalogInputChannel(channel)) {
StringBuilder buf = new StringBuilder();
buf.append("Requested analog input channel is out of range. Minimum: 0, Maximum: ")
.append(kAnalogInputChannels)
.append(", Requested: ")
.append(channel);
.append(kAnalogInputChannels)
.append(", Requested: ")
.append(channel);
throw new IllegalArgumentException(buf.toString());
}
}
@@ -163,9 +163,9 @@ public final class SensorUtil {
if (!AnalogJNI.checkAnalogOutputChannel(channel)) {
StringBuilder buf = new StringBuilder();
buf.append("Requested analog output channel is out of range. Minimum: 0, Maximum: ")
.append(kAnalogOutputChannels)
.append(", Requested: ")
.append(channel);
.append(kAnalogOutputChannels)
.append(", Requested: ")
.append(channel);
throw new IllegalArgumentException(buf.toString());
}
}
@@ -179,9 +179,9 @@ public final class SensorUtil {
if (!SolenoidJNI.checkSolenoidChannel(channel)) {
StringBuilder buf = new StringBuilder();
buf.append("Requested solenoid channel is out of range. Minimum: 0, Maximum: ")
.append(kSolenoidChannels)
.append(", Requested: ")
.append(channel);
.append(kSolenoidChannels)
.append(", Requested: ")
.append(channel);
throw new IllegalArgumentException(buf.toString());
}
}
@@ -196,9 +196,9 @@ public final class SensorUtil {
if (!PDPJNI.checkPDPChannel(channel)) {
StringBuilder buf = new StringBuilder();
buf.append("Requested PDP channel is out of range. Minimum: 0, Maximum: ")
.append(kPDPChannels)
.append(", Requested: ")
.append(channel);
.append(kPDPChannels)
.append(", Requested: ")
.append(channel);
throw new IllegalArgumentException(buf.toString());
}
}
@@ -212,9 +212,9 @@ public final class SensorUtil {
if (!PDPJNI.checkPDPModule(module)) {
StringBuilder buf = new StringBuilder();
buf.append("Requested PDP module is out of range. Minimum: 0, Maximum: ")
.append(kPDPModules)
.append(", Requested: ")
.append(module);
.append(kPDPModules)
.append(", Requested: ")
.append(module);
throw new IllegalArgumentException(buf.toString());
}
}

View File

@@ -19,7 +19,6 @@ public class SerialPort implements AutoCloseable {
public enum Port {
kOnboard(0), kMXP(1), kUSB(2), kUSB1(2), kUSB2(3);
@SuppressWarnings("MemberName")
public final int value;
Port(int value) {
@@ -33,7 +32,6 @@ public class SerialPort implements AutoCloseable {
public enum Parity {
kNone(0), kOdd(1), kEven(2), kMark(3), kSpace(4);
@SuppressWarnings("MemberName")
public final int value;
Parity(int value) {
@@ -47,7 +45,6 @@ public class SerialPort implements AutoCloseable {
public enum StopBits {
kOne(10), kOnePointFive(15), kTwo(20);
@SuppressWarnings("MemberName")
public final int value;
StopBits(int value) {
@@ -61,7 +58,6 @@ public class SerialPort implements AutoCloseable {
public enum FlowControl {
kNone(0), kXonXoff(1), kRtsCts(2), kDtsDsr(4);
@SuppressWarnings("MemberName")
public final int value;
FlowControl(int value) {
@@ -75,7 +71,6 @@ public class SerialPort implements AutoCloseable {
public enum WriteBufferMode {
kFlushOnAccess(1), kFlushWhenFull(2);
@SuppressWarnings("MemberName")
public final int value;
WriteBufferMode(int value) {

View File

@@ -54,7 +54,7 @@ public class Timer {
*/
private final Object m_lock = new Object();
@SuppressWarnings("JavadocMethod")
@SuppressWarnings("MissingJavadocMethod")
public Timer() {
reset();
}

View File

@@ -19,16 +19,13 @@ public class PIDController implements Sendable, AutoCloseable {
private static int instances;
// Factor for "proportional" control
@SuppressWarnings("MemberName")
private double m_Kp;
private double m_kp;
// Factor for "integral" control
@SuppressWarnings("MemberName")
private double m_Ki;
private double m_ki;
// Factor for "derivative" control
@SuppressWarnings("MemberName")
private double m_Kd;
private double m_kd;
// The period (in seconds) of the loop that calls the controller
private final double m_period;
@@ -62,31 +59,29 @@ public class PIDController implements Sendable, AutoCloseable {
private double m_measurement;
/**
* Allocates a PIDController with the given constants for Kp, Ki, and Kd and a default period of
* Allocates a PIDController with the given constants for kp, ki, and kd and a default period of
* 0.02 seconds.
*
* @param Kp The proportional coefficient.
* @param Ki The integral coefficient.
* @param Kd The derivative coefficient.
* @param kp The proportional coefficient.
* @param ki The integral coefficient.
* @param kd The derivative coefficient.
*/
@SuppressWarnings("ParameterName")
public PIDController(double Kp, double Ki, double Kd) {
this(Kp, Ki, Kd, 0.02);
public PIDController(double kp, double ki, double kd) {
this(kp, ki, kd, 0.02);
}
/**
* Allocates a PIDController with the given constants for Kp, Ki, and Kd.
* Allocates a PIDController with the given constants for kp, ki, and kd.
*
* @param Kp The proportional coefficient.
* @param Ki The integral coefficient.
* @param Kd The derivative coefficient.
* @param kp The proportional coefficient.
* @param ki The integral coefficient.
* @param kd The derivative coefficient.
* @param period The period between controller updates in seconds.
*/
@SuppressWarnings("ParameterName")
public PIDController(double Kp, double Ki, double Kd, double period) {
m_Kp = Kp;
m_Ki = Ki;
m_Kd = Kd;
public PIDController(double kp, double ki, double kd, double period) {
m_kp = kp;
m_ki = ki;
m_kd = kd;
m_period = period;
@@ -106,45 +101,41 @@ public class PIDController implements Sendable, AutoCloseable {
*
* <p>Set the proportional, integral, and differential coefficients.
*
* @param Kp The proportional coefficient.
* @param Ki The integral coefficient.
* @param Kd The derivative coefficient.
* @param kp The proportional coefficient.
* @param ki The integral coefficient.
* @param kd The derivative coefficient.
*/
@SuppressWarnings("ParameterName")
public void setPID(double Kp, double Ki, double Kd) {
m_Kp = Kp;
m_Ki = Ki;
m_Kd = Kd;
public void setPID(double kp, double ki, double kd) {
m_kp = kp;
m_ki = ki;
m_kd = kd;
}
/**
* Sets the Proportional coefficient of the PID controller gain.
*
* @param Kp proportional coefficient
* @param kp proportional coefficient
*/
@SuppressWarnings("ParameterName")
public void setP(double Kp) {
m_Kp = Kp;
public void setP(double kp) {
m_kp = kp;
}
/**
* Sets the Integral coefficient of the PID controller gain.
*
* @param Ki integral coefficient
* @param ki integral coefficient
*/
@SuppressWarnings("ParameterName")
public void setI(double Ki) {
m_Ki = Ki;
public void setI(double ki) {
m_ki = ki;
}
/**
* Sets the Differential coefficient of the PID controller gain.
*
* @param Kd differential coefficient
* @param kd differential coefficient
*/
@SuppressWarnings("ParameterName")
public void setD(double Kd) {
m_Kd = Kd;
public void setD(double kd) {
m_kd = kd;
}
/**
@@ -153,7 +144,7 @@ public class PIDController implements Sendable, AutoCloseable {
* @return proportional coefficient
*/
public double getP() {
return m_Kp;
return m_kp;
}
/**
@@ -162,7 +153,7 @@ public class PIDController implements Sendable, AutoCloseable {
* @return integral coefficient
*/
public double getI() {
return m_Ki;
return m_ki;
}
/**
@@ -171,7 +162,7 @@ public class PIDController implements Sendable, AutoCloseable {
* @return differential coefficient
*/
public double getD() {
return m_Kd;
return m_kd;
}
/**
@@ -333,12 +324,12 @@ public class PIDController implements Sendable, AutoCloseable {
m_velocityError = (m_positionError - m_prevError) / m_period;
if (m_Ki != 0) {
if (m_ki != 0) {
m_totalError = MathUtil.clamp(m_totalError + m_positionError * m_period,
m_minimumIntegral / m_Ki, m_maximumIntegral / m_Ki);
m_minimumIntegral / m_ki, m_maximumIntegral / m_ki);
}
return m_Kp * m_positionError + m_Ki * m_totalError + m_Kd * m_velocityError;
return m_kp * m_positionError + m_ki * m_totalError + m_kd * m_velocityError;
}
/**

View File

@@ -23,7 +23,6 @@ public abstract class RobotDriveBase extends MotorSafety {
kFrontLeft(0), kFrontRight(1), kRearLeft(2), kRearRight(3), kLeft(0),
kRight(1), kBack(2);
@SuppressWarnings("MemberName")
public final int value;
MotorType(int value) {

View File

@@ -7,14 +7,14 @@ package edu.wpi.first.wpilibj.drive;
/**
* This is a 2D vector struct that supports basic vector operations.
*/
@SuppressWarnings("MemberName")
public class Vector2d {
@SuppressWarnings("MemberName")
public double x;
@SuppressWarnings("MemberName")
public double y;
public Vector2d() {}
@SuppressWarnings("ParameterName")
public Vector2d(double x, double y) {
this.x = x;
this.y = y;