diff --git a/styleguide/pmd-ruleset.xml b/styleguide/pmd-ruleset.xml
new file mode 100644
index 0000000000..92d35dcb02
--- /dev/null
+++ b/styleguide/pmd-ruleset.xml
@@ -0,0 +1,22 @@
+
+
Users should override this method for initialization code which will be called each time the * robot enters test mode. */ + @SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation") public void testInit() { System.out.println("Default IterativeRobot.testInit() method... Overload me!"); } @@ -283,6 +284,7 @@ public class IterativeRobot extends RobotBase { * disconnected. For most use cases the variable timing will not be an issue. If your code does * require guaranteed fixed periodic timing, consider using Notifier or PIDController instead. */ + @SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation") public void testPeriodic() { if (m_tmpFirstRun) { System.out.println("Default IterativeRobot.testPeriodic() method... Overload me!"); diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/RobotDrive.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/RobotDrive.java index 4d76c32337..fc729bca54 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/RobotDrive.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/RobotDrive.java @@ -282,12 +282,12 @@ public class RobotDrive implements MotorSafety { rightValue = limit(rightValue); if (squaredInputs) { if (leftValue >= 0.0) { - leftValue = (leftValue * leftValue); + leftValue = leftValue * leftValue; } else { leftValue = -(leftValue * leftValue); } if (rightValue >= 0.0) { - rightValue = (rightValue * rightValue); + rightValue = rightValue * rightValue; } else { rightValue = -(rightValue * rightValue); } @@ -395,12 +395,12 @@ public class RobotDrive implements MotorSafety { // square the inputs (while preserving the sign) to increase fine control // while permitting full power if (moveValue >= 0.0) { - moveValue = (moveValue * moveValue); + moveValue = moveValue * moveValue; } else { moveValue = -(moveValue * moveValue); } if (rotateValue >= 0.0) { - rotateValue = (rotateValue * rotateValue); + rotateValue = rotateValue * rotateValue; } else { rotateValue = -(rotateValue * rotateValue); } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SampleRobot.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SampleRobot.java index dd971a033c..e7fb048b95 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SampleRobot.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SampleRobot.java @@ -83,6 +83,7 @@ public class SampleRobot extends RobotBase { * Test code should go here. Users should add test code to this method that should run while the * robot is in test mode. */ + @SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation") public void test() { System.out.println("Default test() method running, consider providing your own"); } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SensorBase.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SensorBase.java index 4ebac1b451..c2ede4ab99 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SensorBase.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SensorBase.java @@ -89,10 +89,10 @@ public abstract class SensorBase { protected static void checkSolenoidModule(final int moduleNumber) { if (!SolenoidJNI.checkSolenoidModule(moduleNumber)) { StringBuilder buf = new StringBuilder(); - buf.append("Requested solenoid module is out of range. Minimumm: 0, Maximum: "); - buf.append(kPCMModules); - buf.append(", Requested: "); - buf.append(moduleNumber); + buf.append("Requested solenoid module is out of range. Minimumm: 0, Maximum: ") + .append(kPCMModules) + .append(", Requested: ") + .append(moduleNumber); throw new IndexOutOfBoundsException(buf.toString()); } } @@ -106,10 +106,10 @@ public abstract class SensorBase { protected static void checkDigitalChannel(final int channel) { if (!DIOJNI.checkDIOChannel(channel)) { StringBuilder buf = new StringBuilder(); - buf.append("Requested DIO channel is out of range. Minimumm: 0, Maximum: "); - buf.append(kDigitalChannels); - buf.append(", Requested: "); - buf.append(channel); + buf.append("Requested DIO channel is out of range. Minimumm: 0, Maximum: ") + .append(kDigitalChannels) + .append(", Requested: ") + .append(channel); throw new IndexOutOfBoundsException(buf.toString()); } } @@ -123,10 +123,10 @@ public abstract class SensorBase { protected static void checkRelayChannel(final int channel) { if (!RelayJNI.checkRelayChannel(channel)) { StringBuilder buf = new StringBuilder(); - buf.append("Requested relay channel is out of range. Minimumm: 0, Maximum: "); - buf.append(kRelayChannels); - buf.append(", Requested: "); - buf.append(channel); + buf.append("Requested relay channel is out of range. Minimumm: 0, Maximum: ") + .append(kRelayChannels) + .append(", Requested: ") + .append(channel); throw new IndexOutOfBoundsException(buf.toString()); } } @@ -140,10 +140,10 @@ public abstract class SensorBase { protected static void checkPWMChannel(final int channel) { if (!PWMJNI.checkPWMChannel(channel)) { StringBuilder buf = new StringBuilder(); - buf.append("Requested PWM channel is out of range. Minimumm: 0, Maximum: "); - buf.append(kPwmChannels); - buf.append(", Requested: "); - buf.append(channel); + buf.append("Requested PWM channel is out of range. Minimumm: 0, Maximum: ") + .append(kPwmChannels) + .append(", Requested: ") + .append(channel); throw new IndexOutOfBoundsException(buf.toString()); } } @@ -157,10 +157,10 @@ public abstract class SensorBase { protected static void checkAnalogInputChannel(final int channel) { if (!AnalogJNI.checkAnalogInputChannel(channel)) { StringBuilder buf = new StringBuilder(); - buf.append("Requested analog input channel is out of range. Minimumm: 0, Maximum: "); - buf.append(kAnalogInputChannels); - buf.append(", Requested: "); - buf.append(channel); + buf.append("Requested analog input channel is out of range. Minimumm: 0, Maximum: ") + .append(kAnalogInputChannels) + .append(", Requested: ") + .append(channel); throw new IndexOutOfBoundsException(buf.toString()); } } @@ -174,10 +174,10 @@ public abstract class SensorBase { protected static void checkAnalogOutputChannel(final int channel) { if (!AnalogJNI.checkAnalogOutputChannel(channel)) { StringBuilder buf = new StringBuilder(); - buf.append("Requested analog output channel is out of range. Minimumm: 0, Maximum: "); - buf.append(kAnalogOutputChannels); - buf.append(", Requested: "); - buf.append(channel); + buf.append("Requested analog output channel is out of range. Minimumm: 0, Maximum: ") + .append(kAnalogOutputChannels) + .append(", Requested: ") + .append(channel); throw new IndexOutOfBoundsException(buf.toString()); } } @@ -190,10 +190,10 @@ public abstract class SensorBase { protected static void checkSolenoidChannel(final int channel) { if (!SolenoidJNI.checkSolenoidChannel(channel)) { StringBuilder buf = new StringBuilder(); - buf.append("Requested solenoid channel is out of range. Minimumm: 0, Maximum: "); - buf.append(kSolenoidChannels); - buf.append(", Requested: "); - buf.append(channel); + buf.append("Requested solenoid channel is out of range. Minimumm: 0, Maximum: ") + .append(kSolenoidChannels) + .append(", Requested: ") + .append(channel); throw new IndexOutOfBoundsException(buf.toString()); } } @@ -207,10 +207,10 @@ public abstract class SensorBase { protected static void checkPDPChannel(final int channel) { if (!PDPJNI.checkPDPChannel(channel)) { StringBuilder buf = new StringBuilder(); - buf.append("Requested PDP channel is out of range. Minimumm: 0, Maximum: "); - buf.append(kPDPChannels); - buf.append(", Requested: "); - buf.append(channel); + buf.append("Requested PDP channel is out of range. Minimumm: 0, Maximum: ") + .append(kPDPChannels) + .append(", Requested: ") + .append(channel); throw new IndexOutOfBoundsException(buf.toString()); } } @@ -223,10 +223,10 @@ public abstract class SensorBase { protected static void checkPDPModule(final int module) { if (!PDPJNI.checkPDPModule(module)) { StringBuilder buf = new StringBuilder(); - buf.append("Requested PDP module is out of range. Minimumm: 0, Maximum: "); - buf.append(kPDPModules); - buf.append(", Requested: "); - buf.append(module); + buf.append("Requested PDP module is out of range. Minimumm: 0, Maximum: ") + .append(kPDPModules) + .append(", Requested: ") + .append(module); throw new IndexOutOfBoundsException(buf.toString()); } } diff --git a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/buttons/Trigger.java b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/buttons/Trigger.java index d0cd695b06..5457fb4a1a 100644 --- a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/buttons/Trigger.java +++ b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/buttons/Trigger.java @@ -39,10 +39,9 @@ public abstract class Trigger implements Sendable { * * @return whether get() return true or the internal table for SmartDashboard use is pressed. */ + @SuppressWarnings("PMD.UselessParentheses") private boolean grab() { - // FIXME make is connected work? - return get() - || (m_table != null /* && m_table.isConnected() */ && m_table.getBoolean("pressed", false)); + return get() || (m_table != null && m_table.getBoolean("pressed", false)); } diff --git a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/command/LinkedListElement.java b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/command/LinkedListElement.java index 7dd500ead6..055150a879 100644 --- a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/command/LinkedListElement.java +++ b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/command/LinkedListElement.java @@ -46,6 +46,7 @@ class LinkedListElement { } } + @SuppressWarnings("PMD.EmptyIfStmt") public LinkedListElement remove() { if (m_previous == null && m_next == null) { // no-op