diff --git a/styleguide/pmd-ruleset.xml b/styleguide/pmd-ruleset.xml index 92d35dcb02..dc5c1da04e 100644 --- a/styleguide/pmd-ruleset.xml +++ b/styleguide/pmd-ruleset.xml @@ -19,4 +19,10 @@ + + + + + + diff --git a/wpilibc/athena/include/AnalogOutput.h b/wpilibc/athena/include/AnalogOutput.h index ef637d343b..93f397c4c9 100644 --- a/wpilibc/athena/include/AnalogOutput.h +++ b/wpilibc/athena/include/AnalogOutput.h @@ -28,6 +28,7 @@ class AnalogOutput : public SensorBase, public LiveWindowSendable { void SetVoltage(double voltage); double GetVoltage() const; + int GetChannel(); void UpdateTable() override; void StartLiveWindowMode() override; diff --git a/wpilibc/athena/include/I2C.h b/wpilibc/athena/include/I2C.h index 4229b43e6d..46ec058c28 100644 --- a/wpilibc/athena/include/I2C.h +++ b/wpilibc/athena/include/I2C.h @@ -35,7 +35,7 @@ class I2C : SensorBase { bool WriteBulk(uint8_t* data, int count); bool Read(int registerAddress, int count, uint8_t* data); bool ReadOnly(int count, uint8_t* buffer); - void Broadcast(int registerAddress, uint8_t data); + // void Broadcast(int registerAddress, uint8_t data); bool VerifySensor(int registerAddress, int count, const uint8_t* expected); private: diff --git a/wpilibc/athena/src/AnalogOutput.cpp b/wpilibc/athena/src/AnalogOutput.cpp index c0fba90629..5655590f28 100644 --- a/wpilibc/athena/src/AnalogOutput.cpp +++ b/wpilibc/athena/src/AnalogOutput.cpp @@ -59,6 +59,11 @@ AnalogOutput::AnalogOutput(int channel) { */ AnalogOutput::~AnalogOutput() { HAL_FreeAnalogOutputPort(m_port); } +/** + * Get the channel of this AnalogOutput. + */ +int AnalogOutput::GetChannel() { return m_channel; } + /** * Set the value of the analog output. * diff --git a/wpilibc/athena/src/I2C.cpp b/wpilibc/athena/src/I2C.cpp index 24be556457..03612798e1 100644 --- a/wpilibc/athena/src/I2C.cpp +++ b/wpilibc/athena/src/I2C.cpp @@ -159,8 +159,8 @@ bool I2C::ReadOnly(int count, uint8_t* buffer) { * @param registerAddress The register to write on all devices on the bus. * @param data The value to write to the devices. */ -[[gnu::warning("I2C::Broadcast() is not implemented.")]] void I2C::Broadcast( - int registerAddress, uint8_t data) {} +// [[gnu::warning("I2C::Broadcast() is not implemented.")]] void I2C::Broadcast( +// int registerAddress, uint8_t data) {} /** * Verify that a device's registers contain expected values. diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXL345_I2C.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXL345_I2C.java index c629ec0239..6532f437fc 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXL345_I2C.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXL345_I2C.java @@ -21,7 +21,7 @@ import edu.wpi.first.wpilibj.tables.ITable; /** * ADXL345 I2C Accelerometer. */ -@SuppressWarnings("TypeName") +@SuppressWarnings({"TypeName", "PMD.UnusedPrivateField"}) public class ADXL345_I2C extends SensorBase implements Accelerometer, LiveWindowSendable { private static final byte kAddress = 0x1D; diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXL345_SPI.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXL345_SPI.java index 92da70dad8..41b3f03d26 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXL345_SPI.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXL345_SPI.java @@ -21,7 +21,7 @@ import edu.wpi.first.wpilibj.tables.ITable; /** * ADXL345 SPI Accelerometer. */ -@SuppressWarnings({"TypeName"}) +@SuppressWarnings({"TypeName", "PMD.UnusedPrivateField"}) public class ADXL345_SPI extends SensorBase implements Accelerometer, LiveWindowSendable { private static final int kPowerCtlRegister = 0x2D; private static final int kDataFormatRegister = 0x31; diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXL362.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXL362.java index 5f08b5314b..0ee48bacdd 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXL362.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXL362.java @@ -22,6 +22,7 @@ import edu.wpi.first.wpilibj.tables.ITable; * *

This class allows access to an Analog Devices ADXL362 3-axis accelerometer. */ +@SuppressWarnings("PMD.UnusedPrivateField") public class ADXL362 extends SensorBase implements Accelerometer, LiveWindowSendable { private static final byte kRegWrite = 0x0A; private static final byte kRegRead = 0x0B; diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXRS450_Gyro.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXRS450_Gyro.java index 946fc743c7..dc7a736a4d 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXRS450_Gyro.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/ADXRS450_Gyro.java @@ -25,7 +25,7 @@ import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; * *

This class is for the digital ADXRS450 gyro sensor that connects via SPI. */ -@SuppressWarnings({"TypeName", "AbbreviationAsWordInName"}) +@SuppressWarnings({"TypeName", "AbbreviationAsWordInName", "PMD.UnusedPrivateField"}) public class ADXRS450_Gyro extends GyroBase implements Gyro, PIDSource, LiveWindowSendable { private static final double kSamplePeriod = 0.001; private static final double kCalibrationSampleTime = 5.0; diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogOutput.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogOutput.java index 6b9112e001..dc15349393 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogOutput.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogOutput.java @@ -47,6 +47,13 @@ public class AnalogOutput extends SensorBase implements LiveWindowSendable { m_channel = 0; } + /** + * Get the channel of this AnalogOutput. + */ + public int getChannel() { + return m_channel; + } + public void setVoltage(double voltage) { AnalogJNI.setAnalogOutput(m_port, voltage); } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CameraServer.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CameraServer.java index 561c515000..8f60d3c300 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CameraServer.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CameraServer.java @@ -55,8 +55,8 @@ public class CameraServer { private HashMap m_sinks; private HashMap m_tables; // indexed by source handle private ITable m_publishTable; - private VideoListener m_videoListener; - private int m_tableListener; + private VideoListener m_videoListener; //NOPMD + private int m_tableListener; //NOPMD private int m_nextPort; private String[] m_addresses; @@ -129,7 +129,7 @@ public class CameraServer { } } - @SuppressWarnings("JavadocMethod") + @SuppressWarnings({"JavadocMethod", "PMD.UnusedLocalVariable"}) private CameraServer() { m_sources = new HashMap(); m_sinks = new HashMap(); diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalOutput.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalOutput.java index d54bbd1520..d7af4e4990 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalOutput.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalOutput.java @@ -81,24 +81,37 @@ public class DigitalOutput extends DigitalSource implements LiveWindowSendable { return m_channel; } + /** + * Generate a single pulse. There can only be a single pulse going at any time. + * + * @param pulseLength The length of the pulse. + */ + public void pulse(final double pulseLength) { + DIOJNI.pulse(m_handle, pulseLength); + } + /** * Generate a single pulse. Write a pulse to the specified digital output channel. There can only * be a single pulse going at any time. * - * @param channel The channel to pulse. + * @param channel Unused * @param pulseLength The length of the pulse. + * @deprecated Use {@link #pulse(double)} instead. */ + @Deprecated + @SuppressWarnings("PMD.UnusedFormalParameter") public void pulse(final int channel, final double pulseLength) { DIOJNI.pulse(m_handle, pulseLength); } /** - * @param channel The channel to pulse. + * @param channel Unused * @param pulseLength The length of the pulse. * @deprecated Generate a single pulse. Write a pulse to the specified digital output channel. * There can only be a single pulse going at any time. */ @Deprecated + @SuppressWarnings("PMD.UnusedFormalParameter") public void pulse(final int channel, final int pulseLength) { double convertedPulse = pulseLength / 1.0e9 * (DIOJNI.getLoopTiming() * 25); System.err diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/I2C.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/I2C.java index b2678db49a..afbc59a499 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/I2C.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/I2C.java @@ -294,7 +294,7 @@ public class I2C extends SensorBase { < count; } - /** + /* * Send a broadcast write to all devices on the I2C bus. * *

This is not currently implemented! @@ -302,8 +302,8 @@ public class I2C extends SensorBase { * @param registerAddress The register to write on all devices on the bus. * @param data The value to write to the devices. */ - public void broadcast(int registerAddress, int data) { - } + // public void broadcast(int registerAddress, int data) { + // } /** * Verify that a device's registers contain expected values. diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Joystick.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Joystick.java index 223e33d341..f1724e4ec6 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Joystick.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Joystick.java @@ -201,6 +201,7 @@ public class Joystick extends JoystickBase { * GenericHID interface. * @return The state of the trigger. */ + @SuppressWarnings("PMD.UnusedFormalParameter") public boolean getTrigger(Hand hand) { return getRawButton(m_buttons[ButtonType.kTrigger.value]); } @@ -214,6 +215,7 @@ public class Joystick extends JoystickBase { * GenericHID interface. * @return The state of the top button. */ + @SuppressWarnings("PMD.UnusedFormalParameter") public boolean getTop(Hand hand) { return getRawButton(m_buttons[ButtonType.kTop.value]); } @@ -236,6 +238,7 @@ public class Joystick extends JoystickBase { * GenericHID interface. * @return The state of the bumper (always false) */ + @SuppressWarnings("PMD.UnusedFormalParameter") public boolean getBumper(Hand hand) { return false; } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Relay.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Relay.java index 48a5347e16..0f9d153df7 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Relay.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Relay.java @@ -75,7 +75,6 @@ public class Relay extends SensorBase implements MotorSafety, LiveWindowSendable private int m_forwardHandle = 0; private int m_reverseHandle = 0; - private long m_port; private Direction m_direction; diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/RobotBase.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/RobotBase.java index 5a6a3ca6a8..5a351f45ac 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/RobotBase.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/RobotBase.java @@ -189,6 +189,7 @@ public abstract class RobotBase { /** * Starting point for the applications. */ + @SuppressWarnings("PMD.UnusedFormalParameter") public static void main(String... args) { initializeHardwareConfiguration(); diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Ultrasonic.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Ultrasonic.java index 55f7525273..3b5bb4c19c 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Ultrasonic.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Ultrasonic.java @@ -40,10 +40,6 @@ public class Ultrasonic extends SensorBase implements PIDSource, LiveWindowSenda // Time (sec) for the ping trigger pulse. private static final double kPingTime = 10 * 1e-6; - // Priority that the ultrasonic round robin task runs. - private static final int kPriority = 90; - // Max time (ms) between readings. - private static final double kMaxUltrasonicTime = 0.1; private static final double kSpeedOfSoundInchesPerSec = 1130.0 * 12.0; // head of the ultrasonic sensor list private static Ultrasonic m_firstSensor = null; @@ -84,7 +80,7 @@ public class Ultrasonic extends SensorBase implements PIDSource, LiveWindowSenda } if (ultrasonic.isEnabled()) { // Do the ping - ultrasonic.m_pingChannel.pulse(m_pingChannel.getChannel(), kPingTime); + ultrasonic.m_pingChannel.pulse(kPingTime); } ultrasonic = ultrasonic.m_nextSensor; Timer.delay(.1); // wait for ping to return @@ -288,7 +284,7 @@ public class Ultrasonic extends SensorBase implements PIDSource, LiveWindowSenda // single sensor m_counter.reset(); // reset the counter to zero (invalid data now) // do the ping to start getting a single range - m_pingChannel.pulse(m_pingChannel.getChannel(), kPingTime); + m_pingChannel.pulse(kPingTime); } /** diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/XboxController.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/XboxController.java index 11821162e7..d5bd1588fa 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/XboxController.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/XboxController.java @@ -100,6 +100,7 @@ public class XboxController extends GamepadBase { * GenericHID interface. * @return The state of the trigger (always false) */ + @SuppressWarnings("PMD.UnusedFormalParameter") public boolean getTrigger(Hand hand) { return false; } @@ -112,6 +113,7 @@ public class XboxController extends GamepadBase { * GenericHID interface. * @return The state of the top button (always false) */ + @SuppressWarnings("PMD.UnusedFormalParameter") public boolean getTop(Hand hand) { return false; } diff --git a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/HLUsageReporting.java b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/HLUsageReporting.java index 092426b9af..7e15b09d36 100644 --- a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/HLUsageReporting.java +++ b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/HLUsageReporting.java @@ -57,6 +57,7 @@ public class HLUsageReporting { public void reportScheduler() { } + @SuppressWarnings("PMD.UnusedFormalParameter") public void reportPIDController(int num) { }