mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Don't force public variables to use Hungarian notation (#8774)
People generally have expressed a dislike for the Hungarian notation used in member variables, especially in examples/templates, and our styleguide shouldn't be forced on downstream consumers, so this removes all Hungarian notation from the examples/templates. There are _some_ benefits to Hungarian for private member variables (like knowing what's a member vs. local in a PR review) so we'll keep private member variables the same for now, but public variables should no longer use Hungarian notation, since it looks much worse. A new PMD XPath rule has been added to accomplish this goal. Some other non-compliant variables were fixed for the new rule.
This commit is contained in:
@@ -12,7 +12,6 @@ public enum EdgeConfiguration {
|
||||
FALLING_EDGE(false);
|
||||
|
||||
/** True if triggering on rising edge. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final boolean rising;
|
||||
|
||||
EdgeConfiguration(boolean rising) {
|
||||
|
||||
@@ -68,7 +68,6 @@ public class DifferentialDrive extends RobotDriveBase implements Sendable, AutoC
|
||||
*
|
||||
* <p>Uses normalized voltage [-1.0..1.0].
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class WheelVelocities {
|
||||
/** Left wheel velocity. */
|
||||
public double left;
|
||||
|
||||
@@ -70,7 +70,6 @@ public class MecanumDrive extends RobotDriveBase implements Sendable, AutoClosea
|
||||
*
|
||||
* <p>Uses normalized voltage [-1.0..1.0].
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class WheelVelocities {
|
||||
/** Front-left wheel velocity. */
|
||||
public double frontLeft;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package org.wpilib.driverstation;
|
||||
|
||||
/** Represents a finger on a touchpad. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final class TouchpadFinger {
|
||||
/** Whether the finger is touching the touchpad. */
|
||||
public final boolean down;
|
||||
|
||||
@@ -66,15 +66,15 @@ public final class DriverStationBackend {
|
||||
}
|
||||
|
||||
private static final class HALJoystickTouchpadFinger {
|
||||
public float m_x;
|
||||
public float m_y;
|
||||
public boolean m_down;
|
||||
float m_x;
|
||||
float m_y;
|
||||
boolean m_down;
|
||||
}
|
||||
|
||||
private static class HALJoystickTouchpad {
|
||||
public final HALJoystickTouchpadFinger[] m_fingers =
|
||||
final HALJoystickTouchpadFinger[] m_fingers =
|
||||
new HALJoystickTouchpadFinger[DriverStationJNI.MAX_JOYSTICK_TOUCHPAD_FINGERS];
|
||||
public int m_count;
|
||||
int m_count;
|
||||
|
||||
HALJoystickTouchpad() {
|
||||
for (int i = 0; i < m_fingers.length; i++) {
|
||||
@@ -84,9 +84,9 @@ public final class DriverStationBackend {
|
||||
}
|
||||
|
||||
private static class HALJoystickTouchpads {
|
||||
public final HALJoystickTouchpad[] m_touchpads =
|
||||
final HALJoystickTouchpad[] m_touchpads =
|
||||
new HALJoystickTouchpad[DriverStationJNI.MAX_JOYSTICK_TOUCHPADS];
|
||||
public int m_count;
|
||||
int m_count;
|
||||
|
||||
HALJoystickTouchpads() {
|
||||
for (int i = 0; i < m_touchpads.length; i++) {
|
||||
@@ -96,13 +96,13 @@ public final class DriverStationBackend {
|
||||
}
|
||||
|
||||
private static final class HALJoystickButtons {
|
||||
public long m_buttons;
|
||||
public long m_available;
|
||||
long m_buttons;
|
||||
long m_available;
|
||||
}
|
||||
|
||||
private static class HALJoystickAxes {
|
||||
public final float[] m_axes;
|
||||
public int m_available;
|
||||
final float[] m_axes;
|
||||
int m_available;
|
||||
|
||||
HALJoystickAxes(int count) {
|
||||
m_axes = new float[count];
|
||||
@@ -110,10 +110,10 @@ public final class DriverStationBackend {
|
||||
}
|
||||
|
||||
private static class HALJoystickAxesRaw {
|
||||
public final short[] m_axes;
|
||||
final short[] m_axes;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public int m_available;
|
||||
int m_available;
|
||||
|
||||
HALJoystickAxesRaw(int count) {
|
||||
m_axes = new short[count];
|
||||
@@ -121,8 +121,8 @@ public final class DriverStationBackend {
|
||||
}
|
||||
|
||||
private static class HALJoystickPOVs {
|
||||
public final byte[] m_povs;
|
||||
public int m_available;
|
||||
final byte[] m_povs;
|
||||
int m_available;
|
||||
|
||||
HALJoystickPOVs(int count) {
|
||||
m_povs = new byte[count];
|
||||
@@ -151,7 +151,6 @@ public final class DriverStationBackend {
|
||||
return "<" + id + ">";
|
||||
}
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
private static class MatchDataSender {
|
||||
private static final String kSmartDashboardType = "FMSInfo";
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ public abstract class RobotBase implements AutoCloseable {
|
||||
false,
|
||||
event -> {
|
||||
if (event.is(NetworkTableEvent.Kind.CONNECTED)) {
|
||||
HAL.reportUsage("NT/" + event.connInfo.remote_id, "");
|
||||
HAL.reportUsage("NT/" + event.connInfo.remoteId, "");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.wpilib.units.measure.Time;
|
||||
*/
|
||||
public class TimedRobot extends IterativeRobotBase {
|
||||
/** Default loop period. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public static final double DEFAULT_PERIOD = 0.02;
|
||||
|
||||
// The C pointer to the notifier object. We don't use it directly, it is
|
||||
|
||||
@@ -57,7 +57,6 @@ public class ADXL345_I2C implements NTSendable, AutoCloseable {
|
||||
}
|
||||
|
||||
/** Container type for accelerations from all axes. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class AllAxes {
|
||||
/** Acceleration along the X axis in g-forces. */
|
||||
public double x;
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.wpilib.system.Timer;
|
||||
/** This class controls a REV ExpansionHub plugged in over USB to Systemcore. */
|
||||
public class ExpansionHub implements AutoCloseable {
|
||||
private static class DataStore implements AutoCloseable {
|
||||
public final int m_usbId;
|
||||
private final int m_usbId;
|
||||
private int m_refCount;
|
||||
private int m_reservedMotorMask;
|
||||
private int m_reservedServoMask;
|
||||
|
||||
@@ -17,13 +17,13 @@ import org.wpilib.system.SensorUtil;
|
||||
/** Module class for controlling a REV Robotics Pneumatic Hub. */
|
||||
public class PneumaticHub implements PneumaticsBase {
|
||||
private static class DataStore implements AutoCloseable {
|
||||
public final int m_module;
|
||||
public final int m_handle;
|
||||
private final int m_module;
|
||||
private final int m_handle;
|
||||
private final int m_busId;
|
||||
private int m_refCount;
|
||||
private int m_reservedMask;
|
||||
private boolean m_compressorReserved;
|
||||
public final int[] m_oneShotDurMs = new int[PortsJNI.getNumREVPHChannels()];
|
||||
private final int[] m_oneShotDurMs = new int[PortsJNI.getNumREVPHChannels()];
|
||||
private final Object m_reserveLock = new Object();
|
||||
|
||||
DataStore(int busId, int module) {
|
||||
|
||||
@@ -14,8 +14,8 @@ import org.wpilib.system.SensorUtil;
|
||||
/** Module class for controlling a Cross The Road Electronics Pneumatics Control Module. */
|
||||
public class PneumaticsControlModule implements PneumaticsBase {
|
||||
private static class DataStore implements AutoCloseable {
|
||||
public final int m_module;
|
||||
public final int m_handle;
|
||||
private final int m_module;
|
||||
private final int m_handle;
|
||||
private final int m_busId;
|
||||
private int m_refCount;
|
||||
private int m_reservedMask;
|
||||
|
||||
@@ -109,7 +109,7 @@ public class PeriodicPriorityQueue {
|
||||
* @param func The function whose callbacks should be removed.
|
||||
*/
|
||||
public void remove(Runnable func) {
|
||||
m_queue.removeIf(callback -> callback.m_func.equals(func));
|
||||
m_queue.removeIf(callback -> callback.func.equals(func));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,7 +163,7 @@ public class PeriodicPriorityQueue {
|
||||
"No callbacks to run! Did you make sure to call add() first?");
|
||||
}
|
||||
|
||||
NotifierJNI.setNotifierAlarm(notifier, callback.m_expirationTime, 0, true, true);
|
||||
NotifierJNI.setNotifierAlarm(notifier, callback.expirationTime, 0, true, true);
|
||||
|
||||
try {
|
||||
WPIUtilJNI.waitForObject(notifier);
|
||||
@@ -173,30 +173,28 @@ public class PeriodicPriorityQueue {
|
||||
|
||||
m_loopStartTimeMicros = RobotController.getMonotonicTime();
|
||||
|
||||
callback.m_func.run();
|
||||
callback.func.run();
|
||||
|
||||
// Increment the expiration time by the number of full periods it's behind
|
||||
// plus one to avoid rapid repeat fires from a large loop overrun. We
|
||||
// assume m_loopStartTime ≥ expirationTime rather than checking for it since
|
||||
// the callback wouldn't be running otherwise.
|
||||
callback.m_expirationTime +=
|
||||
callback.m_period
|
||||
+ (m_loopStartTimeMicros - callback.m_expirationTime)
|
||||
/ callback.m_period
|
||||
* callback.m_period;
|
||||
callback.expirationTime +=
|
||||
callback.period
|
||||
+ (m_loopStartTimeMicros - callback.expirationTime) / callback.period * callback.period;
|
||||
m_queue.add(callback);
|
||||
|
||||
// Process all other callbacks that are ready to run
|
||||
while (m_queue.peek().m_expirationTime <= m_loopStartTimeMicros) {
|
||||
while (m_queue.peek().expirationTime <= m_loopStartTimeMicros) {
|
||||
callback = m_queue.poll();
|
||||
|
||||
callback.m_func.run();
|
||||
callback.func.run();
|
||||
|
||||
callback.m_expirationTime +=
|
||||
callback.m_period
|
||||
+ (m_loopStartTimeMicros - callback.m_expirationTime)
|
||||
/ callback.m_period
|
||||
* callback.m_period;
|
||||
callback.expirationTime +=
|
||||
callback.period
|
||||
+ (m_loopStartTimeMicros - callback.expirationTime)
|
||||
/ callback.period
|
||||
* callback.period;
|
||||
m_queue.add(callback);
|
||||
}
|
||||
|
||||
@@ -223,13 +221,13 @@ public class PeriodicPriorityQueue {
|
||||
*/
|
||||
public static class Callback implements Comparable<Callback> {
|
||||
/** The function to execute when the callback fires. */
|
||||
public final Runnable m_func;
|
||||
public final Runnable func;
|
||||
|
||||
/** The period at which to run the callback in microseconds. */
|
||||
public final long m_period;
|
||||
public final long period;
|
||||
|
||||
/** The next scheduled execution time in monotonic timestamp microseconds. */
|
||||
public long m_expirationTime;
|
||||
public long expirationTime;
|
||||
|
||||
/**
|
||||
* Construct a callback container.
|
||||
@@ -240,13 +238,13 @@ public class PeriodicPriorityQueue {
|
||||
* @param offset The offset from the common starting time in microseconds.
|
||||
*/
|
||||
public Callback(Runnable func, long startTime, long period, long offset) {
|
||||
this.m_func = func;
|
||||
this.m_period = period;
|
||||
this.m_expirationTime =
|
||||
this.func = func;
|
||||
this.period = period;
|
||||
this.expirationTime =
|
||||
startTime
|
||||
+ offset
|
||||
+ (1 + (RobotController.getMonotonicTime() - startTime - offset) / this.m_period)
|
||||
* this.m_period;
|
||||
+ (1 + (RobotController.getMonotonicTime() - startTime - offset) / this.period)
|
||||
* this.period;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,7 +278,7 @@ public class PeriodicPriorityQueue {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object rhs) {
|
||||
return rhs instanceof Callback callback && m_expirationTime == callback.m_expirationTime;
|
||||
return rhs instanceof Callback callback && expirationTime == callback.expirationTime;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,7 +288,7 @@ public class PeriodicPriorityQueue {
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Long.hashCode(m_expirationTime);
|
||||
return Long.hashCode(expirationTime);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,7 +304,7 @@ public class PeriodicPriorityQueue {
|
||||
public int compareTo(Callback rhs) {
|
||||
// Elements with sooner expiration times are sorted as lesser. The head of
|
||||
// Java's PriorityQueue is the least element.
|
||||
return Long.compare(m_expirationTime, rhs.m_expirationTime);
|
||||
return Long.compare(expirationTime, rhs.expirationTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,23 +31,18 @@ public final class AlertSim {
|
||||
}
|
||||
|
||||
/** The handle of the alert. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final int handle;
|
||||
|
||||
/** The group of the alert. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final String group;
|
||||
|
||||
/** The text of the alert. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final String text;
|
||||
|
||||
/** The time the alert became active. 0 if not active. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long activeStartTime;
|
||||
|
||||
/** The level of the alert (HIGH, MEDIUM, or LOW). */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final Level level;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user