mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[build] Upgrade to PMD 7.2.0 (#6718)
This commit is contained in:
@@ -281,11 +281,11 @@ public class AprilTagFieldLayout {
|
||||
private static class FieldDimensions {
|
||||
@SuppressWarnings("MemberName")
|
||||
@JsonProperty(value = "length")
|
||||
public double fieldLength;
|
||||
public final double fieldLength;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
@JsonProperty(value = "width")
|
||||
public double fieldWidth;
|
||||
public final double fieldWidth;
|
||||
|
||||
@JsonCreator()
|
||||
FieldDimensions(
|
||||
|
||||
@@ -15,7 +15,7 @@ public final class OpenCvLoader {
|
||||
static boolean libraryLoaded;
|
||||
|
||||
/** Sets whether JNI should be loaded in the static block. */
|
||||
public static class Helper {
|
||||
public static final class Helper {
|
||||
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,7 +64,10 @@ public class VideoListener implements AutoCloseable {
|
||||
|
||||
private static final ReentrantLock s_lock = new ReentrantLock();
|
||||
private static final Map<Integer, Consumer<VideoEvent>> s_listeners = new HashMap<>();
|
||||
|
||||
@SuppressWarnings("PMD.SingularField")
|
||||
private static Thread s_thread;
|
||||
|
||||
private static int s_poller;
|
||||
private static boolean s_waitQueue;
|
||||
private static final Condition s_waitQueueCond = s_lock.newCondition();
|
||||
|
||||
@@ -212,5 +212,5 @@ public class VideoProperty {
|
||||
}
|
||||
|
||||
int m_handle;
|
||||
private Kind m_kind;
|
||||
private final Kind m_kind;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ package edu.wpi.first.hal;
|
||||
/**
|
||||
* JNI wrapper for library <b>FRC_NetworkCommunication</b><br>.
|
||||
*/
|
||||
@SuppressWarnings("PMD.MissingStaticMethodInNonInstantiatableClass")
|
||||
public final class FRCNetComm {
|
||||
/**
|
||||
* Resource type from UsageReporting.
|
||||
|
||||
@@ -9,6 +9,7 @@ package edu.wpi.first.hal;
|
||||
/**
|
||||
* JNI wrapper for library <b>FRC_NetworkCommunication</b><br>.
|
||||
*/
|
||||
@SuppressWarnings("PMD.MissingStaticMethodInNonInstantiatableClass")
|
||||
public final class FRCNetComm {
|
||||
/**
|
||||
* Resource type from UsageReporting.
|
||||
|
||||
@@ -82,7 +82,7 @@ public final class HAL extends JNIWrapper {
|
||||
|
||||
private static final List<Runnable> s_simPeriodicBefore = new ArrayList<>();
|
||||
|
||||
public static class SimPeriodicBeforeCallback implements AutoCloseable {
|
||||
public static final class SimPeriodicBeforeCallback implements AutoCloseable {
|
||||
private SimPeriodicBeforeCallback(Runnable r) {
|
||||
m_run = r;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public final class HAL extends JNIWrapper {
|
||||
|
||||
private static final List<Runnable> s_simPeriodicAfter = new ArrayList<>();
|
||||
|
||||
public static class SimPeriodicAfterCallback implements AutoCloseable {
|
||||
public static final class SimPeriodicAfterCallback implements AutoCloseable {
|
||||
private SimPeriodicAfterCallback(Runnable r) {
|
||||
m_run = r;
|
||||
}
|
||||
|
||||
@@ -541,14 +541,7 @@ public final class NetworkTableEntry implements Publisher, Subscriber {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof NetworkTableEntry)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_handle == ((NetworkTableEntry) other).m_handle;
|
||||
return other == this || other instanceof NetworkTableEntry entry && m_handle == entry.m_handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,7 +43,6 @@ import us.hebi.quickbuf.ProtoMessage;
|
||||
* kept to the NetworkTableInstance returned by this function to keep it from being garbage
|
||||
* collected.
|
||||
*/
|
||||
@SuppressWarnings("PMD.CouplingBetweenObjects")
|
||||
public final class NetworkTableInstance implements AutoCloseable {
|
||||
/** Client/server mode flag values (as returned by {@link #getNetworkMode()}). */
|
||||
public enum NetworkMode {
|
||||
@@ -493,7 +492,10 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
private static class ListenerStorage implements AutoCloseable {
|
||||
private final ReentrantLock m_lock = new ReentrantLock();
|
||||
private final Map<Integer, Consumer<NetworkTableEvent>> m_listeners = new HashMap<>();
|
||||
|
||||
@SuppressWarnings("PMD.SingularField")
|
||||
private Thread m_thread;
|
||||
|
||||
private int m_poller;
|
||||
private boolean m_waitQueue;
|
||||
private final Event m_waitQueueEvent = new Event();
|
||||
@@ -1239,10 +1241,7 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
return other instanceof NetworkTableInstance inst && m_handle == inst.m_handle;
|
||||
return other == this || other instanceof NetworkTableInstance inst && m_handle == inst.m_handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -154,12 +154,10 @@ public final class NetworkTableValue {
|
||||
{% endfor %}
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
return other instanceof NetworkTableValue ntOther
|
||||
&& m_type == ntOther.m_type
|
||||
&& m_value.equals(ntOther.m_value);
|
||||
return other == this
|
||||
|| other instanceof NetworkTableValue ntOther
|
||||
&& m_type == ntOther.m_type
|
||||
&& m_value.equals(ntOther.m_value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -942,14 +942,7 @@ public final class NetworkTableEntry implements Publisher, Subscriber {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof NetworkTableEntry)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_handle == ((NetworkTableEntry) other).m_handle;
|
||||
return other == this || other instanceof NetworkTableEntry entry && m_handle == entry.m_handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,7 +43,6 @@ import us.hebi.quickbuf.ProtoMessage;
|
||||
* kept to the NetworkTableInstance returned by this function to keep it from being garbage
|
||||
* collected.
|
||||
*/
|
||||
@SuppressWarnings("PMD.CouplingBetweenObjects")
|
||||
public final class NetworkTableInstance implements AutoCloseable {
|
||||
/** Client/server mode flag values (as returned by {@link #getNetworkMode()}). */
|
||||
public enum NetworkMode {
|
||||
@@ -773,7 +772,10 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
private static class ListenerStorage implements AutoCloseable {
|
||||
private final ReentrantLock m_lock = new ReentrantLock();
|
||||
private final Map<Integer, Consumer<NetworkTableEvent>> m_listeners = new HashMap<>();
|
||||
|
||||
@SuppressWarnings("PMD.SingularField")
|
||||
private Thread m_thread;
|
||||
|
||||
private int m_poller;
|
||||
private boolean m_waitQueue;
|
||||
private final Event m_waitQueueEvent = new Event();
|
||||
@@ -1519,10 +1521,7 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
return other instanceof NetworkTableInstance inst && m_handle == inst.m_handle;
|
||||
return other == this || other instanceof NetworkTableInstance inst && m_handle == inst.m_handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -646,12 +646,10 @@ public final class NetworkTableValue {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
return other instanceof NetworkTableValue ntOther
|
||||
&& m_type == ntOther.m_type
|
||||
&& m_value.equals(ntOther.m_value);
|
||||
return other == this
|
||||
|| other instanceof NetworkTableValue ntOther
|
||||
&& m_type == ntOther.m_type
|
||||
&& m_value.equals(ntOther.m_value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.function.Consumer;
|
||||
import us.hebi.quickbuf.ProtoMessage;
|
||||
|
||||
/** A network table that knows its subtable path. */
|
||||
@SuppressWarnings("PMD.CouplingBetweenObjects")
|
||||
public final class NetworkTable {
|
||||
/** The path separator for sub-tables and keys. */
|
||||
public static final char PATH_SEPARATOR = '/';
|
||||
|
||||
@@ -164,12 +164,10 @@ public final class ProtobufTopic<T> extends Topic {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
return other instanceof ProtobufTopic<?> topic
|
||||
&& super.equals(topic)
|
||||
&& m_proto == topic.m_proto;
|
||||
return other == this
|
||||
|| other instanceof ProtobufTopic<?> topic
|
||||
&& super.equals(topic)
|
||||
&& m_proto == topic.m_proto;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -164,12 +164,10 @@ public final class StructArrayTopic<T> extends Topic {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
return other instanceof StructArrayTopic<?> topic
|
||||
&& super.equals(topic)
|
||||
&& m_struct == topic.m_struct;
|
||||
return other == this
|
||||
|| other instanceof StructArrayTopic<?> topic
|
||||
&& super.equals(topic)
|
||||
&& m_struct == topic.m_struct;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -163,12 +163,10 @@ public final class StructTopic<T> extends Topic {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
return other instanceof StructTopic<?> topic
|
||||
&& super.equals(topic)
|
||||
&& m_struct == topic.m_struct;
|
||||
return other == this
|
||||
|| other instanceof StructTopic<?> topic
|
||||
&& super.equals(topic)
|
||||
&& m_struct == topic.m_struct;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,7 @@ checkstyle {
|
||||
apply plugin: 'pmd'
|
||||
|
||||
pmd {
|
||||
toolVersion = '6.55.0'
|
||||
toolVersion = '7.2.0'
|
||||
consoleOutput = true
|
||||
reportsDir = file("$project.buildDir/reports/pmd")
|
||||
ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml"))
|
||||
|
||||
@@ -38,24 +38,28 @@
|
||||
value=".*'.*Arguments\(\)'.*" />
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable">
|
||||
<properties>
|
||||
<property name="violationSuppressXPath" value="//Resource"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<rule ref="category/java/design.xml">
|
||||
<exclude name="AvoidThrowingRawExceptionTypes" />
|
||||
<exclude name="AvoidThrowingNewInstanceOfSameException" />
|
||||
<exclude name="CognitiveComplexity" />
|
||||
<exclude name="CouplingBetweenObjects" />
|
||||
<exclude name="CyclomaticComplexity" />
|
||||
<exclude name="DataClass" />
|
||||
<exclude name="ExcessiveClassLength" />
|
||||
<exclude name="ExceptionAsFlowControl" />
|
||||
<exclude name="ExcessiveImports" />
|
||||
<exclude name="ExcessiveMethodLength" />
|
||||
<exclude name="ExcessiveParameterList" />
|
||||
<exclude name="ExcessivePublicCount" />
|
||||
<exclude name="GodClass" />
|
||||
<exclude name="LawOfDemeter" />
|
||||
<exclude name="LoosePackageCoupling" />
|
||||
<exclude name="NPathComplexity" />
|
||||
<exclude name="NcssConstructorCount" />
|
||||
<exclude name="NcssCount" />
|
||||
<exclude name="NcssMethodCount" />
|
||||
<exclude name="TooManyFields" />
|
||||
<exclude name="TooManyMethods" />
|
||||
</rule>
|
||||
@@ -67,10 +71,8 @@
|
||||
<exclude name="AvoidLiteralsInIfCondition" />
|
||||
<exclude name="CloseResource" />
|
||||
<exclude name="ConstructorCallsOverridableMethod" />
|
||||
<exclude name="DataflowAnomalyAnalysis" />
|
||||
<exclude name="DoNotTerminateVM" />
|
||||
<exclude name="EmptyCatchBlock" />
|
||||
<exclude name="EmptyWhileStmt" />
|
||||
<exclude name="FinalizeDoesNotCallSuperFinalize" />
|
||||
<exclude name="JUnitSpelling" />
|
||||
<exclude name="MissingSerialVersionUID" />
|
||||
@@ -86,7 +88,6 @@
|
||||
</rule>
|
||||
|
||||
<rule ref="category/java/performance.xml">
|
||||
<exclude name="AvoidUsingShortType" />
|
||||
<exclude name="AvoidInstantiatingObjectsInLoops" />
|
||||
</rule>
|
||||
|
||||
@@ -98,7 +99,7 @@
|
||||
<!-- Custom Rules -->
|
||||
<rule name="UseRequireNonNull"
|
||||
message="Use Objects.requireNonNull() instead of throwing a NullPointerException yourself."
|
||||
language="java" class="net.sourceforge.pmd.lang.rule.XPathRule">
|
||||
language="java" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
|
||||
<description>Use Objects.requireNonNull() instead of throwing a
|
||||
NullPointerException yourself.</description>
|
||||
<properties>
|
||||
|
||||
@@ -41,6 +41,7 @@ public class ParallelRaceGroup extends Command {
|
||||
*
|
||||
* @param commands Commands to add to the group.
|
||||
*/
|
||||
@SuppressWarnings("PMD.UseArraysAsList")
|
||||
public final void addCommands(Command... commands) {
|
||||
if (!m_finished) {
|
||||
throw new IllegalStateException(
|
||||
|
||||
@@ -38,6 +38,7 @@ public class SequentialCommandGroup extends Command {
|
||||
*
|
||||
* @param commands Commands to add, in order of execution.
|
||||
*/
|
||||
@SuppressWarnings("PMD.UseArraysAsList")
|
||||
public final void addCommands(Command... commands) {
|
||||
if (m_currentCommandIndex != -1) {
|
||||
throw new IllegalStateException(
|
||||
|
||||
@@ -51,7 +51,7 @@ class SwerveControllerCommandTest {
|
||||
new SwerveModuleState(0, Rotation2d.kZero)
|
||||
};
|
||||
|
||||
private SwerveModulePosition[] m_modulePositions =
|
||||
private final SwerveModulePosition[] m_modulePositions =
|
||||
new SwerveModulePosition[] {
|
||||
new SwerveModulePosition(0, Rotation2d.kZero),
|
||||
new SwerveModulePosition(0, Rotation2d.kZero),
|
||||
|
||||
@@ -840,7 +840,7 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
|
||||
if (calc_crc == imu_crc) {
|
||||
// Timestamp is at buffer[i]
|
||||
m_dt = ((double) buffer[i] - previous_timestamp) / 1000000.0;
|
||||
m_dt = (buffer[i] - previous_timestamp) / 1000000.0;
|
||||
|
||||
// Scale sensor data
|
||||
gyro_rate_x = (toShort(buffer[i + 5], buffer[i + 6]) * 0.04);
|
||||
|
||||
@@ -825,7 +825,7 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
|
||||
// Could be multiple data sets in the buffer. Handle each one.
|
||||
for (int i = 0; i < data_to_read; i += dataset_len) {
|
||||
// Timestamp is at buffer[i]
|
||||
m_dt = ((double) buffer[i] - previous_timestamp) / 1000000.0;
|
||||
m_dt = (buffer[i] - previous_timestamp) / 1000000.0;
|
||||
|
||||
/*
|
||||
* System.out.println(((toInt(buffer[i + 3], buffer[i + 4], buffer[i + 5],
|
||||
|
||||
@@ -168,7 +168,7 @@ public class DigitalGlitchFilter implements Sendable, AutoCloseable {
|
||||
public long getPeriodNanoSeconds() {
|
||||
int fpgaCycles = getPeriodCycles();
|
||||
|
||||
return (long) fpgaCycles * 1000L / (long) (SensorUtil.kSystemClockTicksPerMicrosecond / 4);
|
||||
return fpgaCycles * 1000L / (SensorUtil.kSystemClockTicksPerMicrosecond / 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,7 +11,6 @@ import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.hal.MatchInfoData;
|
||||
import edu.wpi.first.networktables.BooleanPublisher;
|
||||
import edu.wpi.first.networktables.IntegerPublisher;
|
||||
import edu.wpi.first.networktables.NetworkTable;
|
||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||
import edu.wpi.first.networktables.StringPublisher;
|
||||
import edu.wpi.first.util.EventVector;
|
||||
@@ -32,13 +31,13 @@ public final class DriverStation {
|
||||
/** Number of Joystick ports. */
|
||||
public static final int kJoystickPorts = 6;
|
||||
|
||||
private static class HALJoystickButtons {
|
||||
private static final class HALJoystickButtons {
|
||||
public int m_buttons;
|
||||
public byte m_count;
|
||||
}
|
||||
|
||||
private static class HALJoystickAxes {
|
||||
public float[] m_axes;
|
||||
public final float[] m_axes;
|
||||
public int m_count;
|
||||
|
||||
HALJoystickAxes(int count) {
|
||||
@@ -47,7 +46,7 @@ public final class DriverStation {
|
||||
}
|
||||
|
||||
private static class HALJoystickAxesRaw {
|
||||
public int[] m_axes;
|
||||
public final int[] m_axes;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public int m_count;
|
||||
@@ -58,7 +57,7 @@ public final class DriverStation {
|
||||
}
|
||||
|
||||
private static class HALJoystickPOVs {
|
||||
public short[] m_povs;
|
||||
public final short[] m_povs;
|
||||
public int m_count;
|
||||
|
||||
HALJoystickPOVs(int count) {
|
||||
@@ -94,16 +93,14 @@ public final class DriverStation {
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
private static class MatchDataSender {
|
||||
NetworkTable table;
|
||||
StringPublisher typeMetadata;
|
||||
StringPublisher gameSpecificMessage;
|
||||
StringPublisher eventName;
|
||||
IntegerPublisher matchNumber;
|
||||
IntegerPublisher replayNumber;
|
||||
IntegerPublisher matchType;
|
||||
BooleanPublisher alliance;
|
||||
IntegerPublisher station;
|
||||
IntegerPublisher controlWord;
|
||||
final StringPublisher gameSpecificMessage;
|
||||
final StringPublisher eventName;
|
||||
final IntegerPublisher matchNumber;
|
||||
final IntegerPublisher replayNumber;
|
||||
final IntegerPublisher matchType;
|
||||
final BooleanPublisher alliance;
|
||||
final IntegerPublisher station;
|
||||
final IntegerPublisher controlWord;
|
||||
boolean oldIsRedAlliance = true;
|
||||
int oldStationNumber = 1;
|
||||
String oldEventName = "";
|
||||
@@ -114,9 +111,8 @@ public final class DriverStation {
|
||||
int oldControlWord;
|
||||
|
||||
MatchDataSender() {
|
||||
table = NetworkTableInstance.getDefault().getTable("FMSInfo");
|
||||
typeMetadata = table.getStringTopic(".type").publish();
|
||||
typeMetadata.set("FMSInfo");
|
||||
var table = NetworkTableInstance.getDefault().getTable("FMSInfo");
|
||||
table.getStringTopic(".type").publish().set("FMSInfo");
|
||||
gameSpecificMessage = table.getStringTopic("GameSpecificMessage").publish();
|
||||
gameSpecificMessage.set("");
|
||||
eventName = table.getStringTopic("EventName").publish();
|
||||
|
||||
@@ -25,7 +25,7 @@ public class PneumaticHub implements PneumaticsBase {
|
||||
private int m_refCount;
|
||||
private int m_reservedMask;
|
||||
private boolean m_compressorReserved;
|
||||
public int[] m_oneShotDurMs = new int[PortsJNI.getNumREVPHChannels()];
|
||||
public final int[] m_oneShotDurMs = new int[PortsJNI.getNumREVPHChannels()];
|
||||
private final Object m_reserveLock = new Object();
|
||||
|
||||
DataStore(int module) {
|
||||
|
||||
@@ -54,8 +54,7 @@ public class SPI implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
private int m_port;
|
||||
private int m_mode;
|
||||
private final int m_port;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -67,8 +66,7 @@ public class SPI implements AutoCloseable {
|
||||
|
||||
SPIJNI.spiInitialize(m_port);
|
||||
|
||||
m_mode = 0;
|
||||
SPIJNI.spiSetMode(m_port, m_mode);
|
||||
SPIJNI.spiSetMode(m_port, 0);
|
||||
|
||||
HAL.report(tResourceType.kResourceType_SPI, port.value + 1);
|
||||
}
|
||||
@@ -115,8 +113,7 @@ public class SPI implements AutoCloseable {
|
||||
* @param mode The mode to set.
|
||||
*/
|
||||
public final void setMode(Mode mode) {
|
||||
m_mode = mode.value & 0x3;
|
||||
SPIJNI.spiSetMode(m_port, m_mode);
|
||||
SPIJNI.spiSetMode(m_port, mode.value & 0x3);
|
||||
}
|
||||
|
||||
/** Configure the chip select line to be active high. */
|
||||
|
||||
@@ -44,7 +44,9 @@ public class Ultrasonic implements Sendable, AutoCloseable {
|
||||
private static Thread m_task;
|
||||
private static int m_instances;
|
||||
|
||||
@SuppressWarnings("PMD.SingularField")
|
||||
private SimDevice m_simDevice;
|
||||
|
||||
private SimBoolean m_simRangeValid;
|
||||
private SimDouble m_simRange;
|
||||
|
||||
@@ -57,7 +59,7 @@ public class Ultrasonic implements Sendable, AutoCloseable {
|
||||
* certainly break. Make sure to disable automatic mode before changing anything with the
|
||||
* sensors!!
|
||||
*/
|
||||
private static class UltrasonicChecker extends Thread {
|
||||
private static final class UltrasonicChecker extends Thread {
|
||||
@Override
|
||||
public synchronized void run() {
|
||||
while (m_automaticEnabled) {
|
||||
|
||||
@@ -31,6 +31,7 @@ public final class EventLoop {
|
||||
}
|
||||
|
||||
/** Poll all bindings. */
|
||||
@SuppressWarnings("PMD.UnusedAssignment")
|
||||
public void poll() {
|
||||
try {
|
||||
m_running = true;
|
||||
|
||||
@@ -17,7 +17,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl;
|
||||
* The LiveWindow class is the public interface for putting sensors and actuators on the LiveWindow.
|
||||
*/
|
||||
public final class LiveWindow {
|
||||
private static class Component implements AutoCloseable {
|
||||
private static final class Component implements AutoCloseable {
|
||||
@Override
|
||||
public void close() {
|
||||
if (m_namePub != null) {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SendableBuilderImpl implements NTSendableBuilder {
|
||||
void accept(T value, long time);
|
||||
}
|
||||
|
||||
private static class Property<P extends Publisher, S extends Subscriber>
|
||||
private static final class Property<P extends Publisher, S extends Subscriber>
|
||||
implements AutoCloseable {
|
||||
@Override
|
||||
@SuppressWarnings("PMD.AvoidCatchingGenericException")
|
||||
|
||||
@@ -72,7 +72,7 @@ public class SysIdRoutineLog {
|
||||
}
|
||||
|
||||
/** Logs data from a single motor during a SysIdRoutine. */
|
||||
public class MotorLog {
|
||||
public final class MotorLog {
|
||||
private final String m_motorName;
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,7 @@ public final class Constants {
|
||||
public static final double kWheelDiameterInches = 6;
|
||||
public static final double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * Math.PI) / (double) kEncoderCPR;
|
||||
(kWheelDiameterInches * Math.PI) / kEncoderCPR;
|
||||
}
|
||||
|
||||
public static final class ArmConstants {
|
||||
|
||||
@@ -28,7 +28,7 @@ public final class Constants {
|
||||
public static final double kWheelDiameterInches = 6;
|
||||
public static final double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * Math.PI) / (double) kEncoderCPR;
|
||||
(kWheelDiameterInches * Math.PI) / kEncoderCPR;
|
||||
}
|
||||
|
||||
public static final class ArmConstants {
|
||||
|
||||
@@ -28,7 +28,7 @@ public final class Constants {
|
||||
public static final double kWheelDiameterInches = 6;
|
||||
public static final double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * Math.PI) / (double) kEncoderCPR;
|
||||
(kWheelDiameterInches * Math.PI) / kEncoderCPR;
|
||||
}
|
||||
|
||||
public static final class ShooterConstants {
|
||||
@@ -37,7 +37,7 @@ public final class Constants {
|
||||
public static final int kEncoderCPR = 1024;
|
||||
public static final double kEncoderDistancePerPulse =
|
||||
// Distance units will be rotations
|
||||
1.0 / (double) kEncoderCPR;
|
||||
1.0 / kEncoderCPR;
|
||||
|
||||
public static final int kShooterMotorPort = 4;
|
||||
public static final int kFeederMotorPort = 5;
|
||||
|
||||
@@ -24,7 +24,7 @@ public final class Constants {
|
||||
public static final double kWheelDiameterInches = 6;
|
||||
public static final double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * Math.PI) / (double) kEncoderCPR;
|
||||
(kWheelDiameterInches * Math.PI) / kEncoderCPR;
|
||||
}
|
||||
|
||||
public static final class ClawConstants {
|
||||
|
||||
@@ -28,7 +28,7 @@ public final class Constants {
|
||||
public static final double kWheelDiameterInches = 6;
|
||||
public static final double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * Math.PI) / (double) kEncoderCPR;
|
||||
(kWheelDiameterInches * Math.PI) / kEncoderCPR;
|
||||
|
||||
public static final boolean kGyroReversed = false;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public final class Constants {
|
||||
public static final double kWheelDiameterInches = 6;
|
||||
public static final double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * Math.PI) / (double) kEncoderCPR;
|
||||
(kWheelDiameterInches * Math.PI) / kEncoderCPR;
|
||||
}
|
||||
|
||||
public static final class HatchConstants {
|
||||
|
||||
@@ -28,7 +28,7 @@ public final class Constants {
|
||||
public static final double kWheelDiameterInches = 6;
|
||||
public static final double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * Math.PI) / (double) kEncoderCPR;
|
||||
(kWheelDiameterInches * Math.PI) / kEncoderCPR;
|
||||
}
|
||||
|
||||
public static final class HatchConstants {
|
||||
|
||||
@@ -37,6 +37,7 @@ public class Robot extends TimedRobot {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("PMD.ConsecutiveLiteralAppends")
|
||||
public void robotPeriodic() {
|
||||
// Creates a string to hold current robot state information, including
|
||||
// alliance, enabled state, operation mode, and match time. The message
|
||||
|
||||
@@ -50,7 +50,7 @@ public final class Constants {
|
||||
public static final double kWheelDiameterMeters = 0.15;
|
||||
public static final double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterMeters * Math.PI) / (double) kEncoderCPR;
|
||||
(kWheelDiameterMeters * Math.PI) / kEncoderCPR;
|
||||
|
||||
// These are example values only - DO NOT USE THESE FOR YOUR OWN ROBOT!
|
||||
// These characterization values MUST be determined either experimentally or theoretically
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class Constants {
|
||||
public static final double kWheelDiameterMeters = Units.inchesToMeters(6);
|
||||
public static final double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterMeters * Math.PI) / (double) kEncoderCPR;
|
||||
(kWheelDiameterMeters * Math.PI) / kEncoderCPR;
|
||||
}
|
||||
|
||||
public static final class ShooterConstants {
|
||||
@@ -39,7 +39,7 @@ public final class Constants {
|
||||
public static final int kEncoderCPR = 1024;
|
||||
public static final double kEncoderDistancePerPulse =
|
||||
// Distance units will be rotations
|
||||
1.0 / (double) kEncoderCPR;
|
||||
1.0 / kEncoderCPR;
|
||||
|
||||
public static final int kShooterMotorPort = 4;
|
||||
public static final int kFeederMotorPort = 5;
|
||||
|
||||
@@ -84,11 +84,11 @@ public final class Constants {
|
||||
public static final double kWheelDiameterMeters = 0.15;
|
||||
public static final double kDriveEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterMeters * Math.PI) / (double) kEncoderCPR;
|
||||
(kWheelDiameterMeters * Math.PI) / kEncoderCPR;
|
||||
|
||||
public static final double kTurningEncoderDistancePerPulse =
|
||||
// Assumes the encoders are on a 1:1 reduction with the module shaft.
|
||||
(2 * Math.PI) / (double) kEncoderCPR;
|
||||
(2 * Math.PI) / kEncoderCPR;
|
||||
|
||||
public static final double kPModuleTurningController = 1;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class Constants {
|
||||
public static final double kWheelDiameterMeters = Units.inchesToMeters(6);
|
||||
public static final double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterMeters * Math.PI) / (double) kEncoderCPR;
|
||||
(kWheelDiameterMeters * Math.PI) / kEncoderCPR;
|
||||
}
|
||||
|
||||
public static final class ShooterConstants {
|
||||
@@ -39,7 +39,7 @@ public final class Constants {
|
||||
public static final int kEncoderCPR = 1024;
|
||||
public static final double kEncoderDistancePerPulse =
|
||||
// Distance units will be rotations
|
||||
1.0 / (double) kEncoderCPR;
|
||||
1.0 / kEncoderCPR;
|
||||
|
||||
public static final int kShooterMotorPort = 4;
|
||||
public static final int kFeederMotorPort = 5;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -299,11 +299,9 @@ public interface Measure<U extends Unit<U>> extends Comparable<Measure<U>> {
|
||||
* @return true if this measure is equivalent, false otherwise
|
||||
*/
|
||||
default boolean isEquivalent(Measure<?> other) {
|
||||
if (!this.unit().getBaseUnit().equals(other.unit().getBaseUnit())) {
|
||||
return false; // Disjoint units, not compatible
|
||||
}
|
||||
|
||||
return Math.abs(baseUnitMagnitude() - other.baseUnitMagnitude()) <= EQUIVALENCE_THRESHOLD;
|
||||
// Check for disjoint units that aren't compatible
|
||||
return this.unit().getBaseUnit().equals(other.unit().getBaseUnit())
|
||||
&& Math.abs(baseUnitMagnitude() - other.baseUnitMagnitude()) <= EQUIVALENCE_THRESHOLD;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
||||
@@ -66,9 +66,9 @@ public class Mult<A extends Unit<A>, B extends Unit<B>> extends Unit<Mult<A, B>>
|
||||
* @param b the second unit
|
||||
* @return the combined unit
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <A extends Unit<A>, B extends Unit<B>> Mult<A, B> combine(A a, B b) {
|
||||
final long key = ((long) a.hashCode()) << 32L | (((long) b.hashCode()) & 0xFFFFFFFFL);
|
||||
final long key = ((long) a.hashCode()) << 32L | (b.hashCode() & 0xFFFFFFFFL);
|
||||
if (cache.containsKey(key)) {
|
||||
return cache.get(key);
|
||||
}
|
||||
|
||||
@@ -78,8 +78,7 @@ public class Per<N extends Unit<N>, D extends Unit<D>> extends Unit<Per<N, D>> {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <N extends Unit<N>, D extends Unit<D>> Per<N, D> combine(
|
||||
N numerator, D denominator) {
|
||||
final long key =
|
||||
((long) numerator.hashCode()) << 32L | (((long) denominator.hashCode()) & 0xFFFFFFFFL);
|
||||
final long key = ((long) numerator.hashCode()) << 32L | (denominator.hashCode() & 0xFFFFFFFFL);
|
||||
|
||||
var existing = cache.get(key);
|
||||
if (existing != null) {
|
||||
|
||||
@@ -286,13 +286,11 @@ public class Unit<U extends Unit<U>> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
return o instanceof Unit<?> that
|
||||
&& m_name.equals(that.m_name)
|
||||
&& m_symbol.equals(that.m_symbol)
|
||||
&& this.equivalent(that);
|
||||
return this == o
|
||||
|| o instanceof Unit<?> that
|
||||
&& m_name.equals(that.m_name)
|
||||
&& m_symbol.equals(that.m_symbol)
|
||||
&& this.equivalent(that);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -69,7 +69,7 @@ public final class UnitBuilder<U extends Unit<U>> {
|
||||
}
|
||||
|
||||
/** Helper class used for safely chaining mapping builder calls. */
|
||||
public class MappingBuilder {
|
||||
public final class MappingBuilder {
|
||||
private final double m_minInput;
|
||||
private final double m_maxInput;
|
||||
|
||||
@@ -271,7 +271,7 @@ public final class UnitBuilder<U extends Unit<U>> {
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "PMD.AvoidAccessibilityAlteration"})
|
||||
private static <U extends Unit<U>> Constructor<? extends Unit<U>> getConstructor(U baseUnit)
|
||||
throws NoSuchMethodException {
|
||||
var baseClass = baseUnit.getClass();
|
||||
|
||||
@@ -419,7 +419,7 @@ public final class Units {
|
||||
* @param symbol the symbol of the new derived unit
|
||||
* @return the milli-unit
|
||||
*/
|
||||
@SuppressWarnings({"PMD.MethodName", "checkstyle:methodname"})
|
||||
@SuppressWarnings("checkstyle:methodname")
|
||||
public static <U extends Unit<U>> U Milli(Unit<U> baseUnit, String name, String symbol) {
|
||||
return derive(baseUnit).splitInto(1000).named(name).symbol(symbol).make();
|
||||
}
|
||||
@@ -431,7 +431,7 @@ public final class Units {
|
||||
* @param baseUnit the unit being derived from. This does not have to be the base unit of measure
|
||||
* @return the milli-unit
|
||||
*/
|
||||
@SuppressWarnings({"PMD.MethodName", "checkstyle:methodname"})
|
||||
@SuppressWarnings("checkstyle:methodname")
|
||||
public static <U extends Unit<U>> U Milli(Unit<U> baseUnit) {
|
||||
return Milli(
|
||||
baseUnit, "Milli" + baseUnit.name().toLowerCase(Locale.ROOT), "m" + baseUnit.symbol());
|
||||
@@ -447,7 +447,7 @@ public final class Units {
|
||||
* @param symbol the symbol of the new derived unit
|
||||
* @return the micro-unit
|
||||
*/
|
||||
@SuppressWarnings({"PMD.MethodName", "checkstyle:methodname"})
|
||||
@SuppressWarnings("checkstyle:methodname")
|
||||
public static <U extends Unit<U>> U Micro(Unit<U> baseUnit, String name, String symbol) {
|
||||
return derive(baseUnit).splitInto(1_000_000).named(name).symbol(symbol).make();
|
||||
}
|
||||
@@ -459,7 +459,7 @@ public final class Units {
|
||||
* @param baseUnit the unit being derived from. This does not have to be the base unit of measure
|
||||
* @return the micro-unit
|
||||
*/
|
||||
@SuppressWarnings({"PMD.MethodName", "checkstyle:methodname"})
|
||||
@SuppressWarnings("checkstyle:methodname")
|
||||
public static <U extends Unit<U>> U Micro(Unit<U> baseUnit) {
|
||||
return Micro(
|
||||
baseUnit, "Micro" + baseUnit.name().toLowerCase(Locale.ROOT), "u" + baseUnit.symbol());
|
||||
@@ -474,7 +474,7 @@ public final class Units {
|
||||
* @param symbol the symbol of the new derived unit
|
||||
* @return the kilo-unit
|
||||
*/
|
||||
@SuppressWarnings({"PMD.MethodName", "checkstyle:methodname"})
|
||||
@SuppressWarnings("checkstyle:methodname")
|
||||
public static <U extends Unit<U>> U Kilo(Unit<U> baseUnit, String name, String symbol) {
|
||||
return derive(baseUnit).aggregate(1000).named(name).symbol(symbol).make();
|
||||
}
|
||||
@@ -486,7 +486,7 @@ public final class Units {
|
||||
* @param baseUnit the unit being derived from. This does not have to be the base unit of measure
|
||||
* @return the kilo-unit
|
||||
*/
|
||||
@SuppressWarnings({"PMD.MethodName", "checkstyle:methodname"})
|
||||
@SuppressWarnings("checkstyle:methodname")
|
||||
public static <U extends Unit<U>> U Kilo(Unit<U> baseUnit) {
|
||||
return Kilo(
|
||||
baseUnit, "Kilo" + baseUnit.name().toLowerCase(Locale.ROOT), "K" + baseUnit.symbol());
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Velocity<D extends Unit<D>> extends Unit<Velocity<D>> {
|
||||
|
||||
/** Generates a cache key used for cache lookups. */
|
||||
private static long cacheKey(Unit<?> numerator, Unit<?> denominator) {
|
||||
return ((long) numerator.hashCode()) << 32L | (((long) denominator.hashCode()) & 0xFFFFFFFFL);
|
||||
return ((long) numerator.hashCode()) << 32L | (denominator.hashCode() & 0xFFFFFFFFL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -119,8 +119,7 @@ public class StructDescriptorDatabase {
|
||||
} else {
|
||||
// check for circular reference
|
||||
if (!theStruct.checkCircular(stack)) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("circular struct reference: ");
|
||||
StringBuilder builder = new StringBuilder("circular struct reference: ");
|
||||
boolean first = true;
|
||||
for (StructDescriptor elem : stack) {
|
||||
if (!first) {
|
||||
|
||||
@@ -92,10 +92,7 @@ public class XRPMotor implements MotorController {
|
||||
|
||||
@Override
|
||||
public boolean getInverted() {
|
||||
if (m_simInverted != null) {
|
||||
return m_simInverted.get();
|
||||
}
|
||||
return false;
|
||||
return m_simInverted != null && m_simInverted.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user