diff --git a/build.gradle b/build.gradle index 3420711f2e..04f3ed4474 100644 --- a/build.gradle +++ b/build.gradle @@ -41,7 +41,7 @@ subprojects { apply plugin: 'checkstyle' checkstyle { - toolVersion = "6.18" + toolVersion = "8.1" configFile = new File(rootDir, "styleguide/checkstyle.xml") } diff --git a/styleguide/checkstyle.xml b/styleguide/checkstyle.xml index 584f8c8a8a..9fd8de97ea 100644 --- a/styleguide/checkstyle.xml +++ b/styleguide/checkstyle.xml @@ -30,6 +30,9 @@ + + + @@ -84,6 +87,10 @@ + + + + diff --git a/styleguide/suppressions.xml b/styleguide/suppressions.xml index b969deece0..9c98b44a35 100644 --- a/styleguide/suppressions.xml +++ b/styleguide/suppressions.xml @@ -5,4 +5,5 @@ "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd"> + diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogGyro.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogGyro.java index c291db607c..a31c925edd 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogGyro.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogGyro.java @@ -53,7 +53,7 @@ public class AnalogGyro extends GyroBase implements Gyro, PIDSource, LiveWindowS } /** - * Gyro constructor using the channel number + * Gyro constructor using the channel number. * * @param channel The analog channel the gyro is connected to. Gyros can only be used on on-board * channels 0-1. diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Compressor.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Compressor.java index 589b1d7eff..5df3bff255 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Compressor.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Compressor.java @@ -137,14 +137,18 @@ public class Compressor extends SensorBase implements LiveWindowSendable { } /** - * @return true if PCM sticky fault is set : Compressor output appears to be shorted. + * If PCM sticky fault is set : Compressor output appears to be shorted. + * + * @return true if PCM sticky fault is set. */ public boolean getCompressorShortedStickyFault() { return CompressorJNI.getCompressorShortedStickyFault(m_compressorHandle); } /** - * @return true if PCM is in fault state : Compressor output appears to be shorted. + * If PCM is in fault state : Compressor output appears to be shorted. + * + * @return true if PCM is in fault state. */ public boolean getCompressorShortedFault() { return CompressorJNI.getCompressorShortedFault(m_compressorHandle); diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java index 931aefdc3e..c263f8f13d 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java @@ -27,7 +27,7 @@ public class DigitalGlitchFilter extends SensorBase { public DigitalGlitchFilter() { synchronized (m_mutex) { int index = 0; - while (m_filterAllocated[index] != false && index < m_filterAllocated.length) { + while (m_filterAllocated[index] && index < m_filterAllocated.length) { index++; } if (index != m_filterAllocated.length) { diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalInput.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalInput.java index a601895b6b..624e13d7e7 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalInput.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalInput.java @@ -61,7 +61,7 @@ public class DigitalInput extends DigitalSource implements LiveWindowSendable { } /** - * Get the channel of the digital input + * Get the channel of the digital input. * * @return The GPIO channel number that this object represents. */ 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 153c358746..77b22b650e 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalOutput.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalOutput.java @@ -74,7 +74,9 @@ public class DigitalOutput extends DigitalSource implements LiveWindowSendable { } /** - * @return The GPIO channel number that this object represents. + * Get the GPIO channel number that this object represents. + * + * @return The GPIO channel number. */ @Override public int getChannel() { diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DriverStation.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DriverStation.java index 12e4c2c020..37e6b5b529 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DriverStation.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DriverStation.java @@ -102,7 +102,7 @@ public class DriverStation implements RobotState.Interface { private long m_lastControlWordUpdate; /** - * Gets an instance of the DriverStation + * Gets an instance of the DriverStation. * * @return The DriverStation. */ @@ -519,8 +519,8 @@ public class DriverStation implements RobotState.Interface { } /** - * Has a new control packet from the driver station arrived since the last time this function was - * called? + * Gets if a new control packet from the driver station arrived since the last time this function + * was called. * * @return True if the control data has been updated since the last call. */ @@ -528,11 +528,10 @@ public class DriverStation implements RobotState.Interface { return HAL.isNewControlData(); } - @SuppressWarnings({"SummaryJavadoc", "JavadocMethod"}) /** - * Is the driver station attached to a Field Management System? + * Gets if the driver station attached to a Field Management System. * - * @return True if the robot is competing on a field being controlled by a Field Management System + * @return true if the robot is competing on a field being controlled by a Field Management System */ public boolean isFMSAttached() { synchronized (m_controlWordMutex) { diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Encoder.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Encoder.java index 01d3c1af1b..bd5e47fb4f 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Encoder.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Encoder.java @@ -295,6 +295,8 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, LiveW } /** + * Get the FPGA index of the encoder. + * * @return The Encoder's FPGA index. */ @SuppressWarnings("AbbreviationAsWordInName") diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java index 521c98ffa6..2b9c679308 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java @@ -105,7 +105,7 @@ public abstract class InterruptableSensorBase extends SensorBase { } /** - * Allocate the interrupt + * Allocate the interrupt. * * @param watcher true if the interrupt should be in synchronous mode where the user program will * have to explicitly wait for the interrupt to occur. diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Resource.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Resource.java index 07e0d77fd5..094bde3f33 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Resource.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Resource.java @@ -67,7 +67,7 @@ public final class Resource { */ public int allocate() throws CheckedAllocationException { for (int i = 0; i < m_size; i++) { - if (m_numAllocated[i] == false) { + if (!m_numAllocated[i]) { m_numAllocated[i] = true; return i; } @@ -87,7 +87,7 @@ public final class Resource { if (index >= m_size || index < 0) { throw new CheckedAllocationException("Index " + index + " out of range"); } - if (m_numAllocated[index] == true) { + if (m_numAllocated[index]) { throw new CheckedAllocationException("Resource at index " + index + " already allocated"); } m_numAllocated[index] = true; @@ -102,7 +102,7 @@ public final class Resource { * @param index The index of the resource to free. */ public void free(final int index) { - if (m_numAllocated[index] == false) { + if (!m_numAllocated[index]) { throw new AllocationException("No resource available to be freed"); } m_numAllocated[index] = false; 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 3c43354940..ecd1acdac3 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/RobotBase.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/RobotBase.java @@ -73,6 +73,8 @@ public abstract class RobotBase { } /** + * Get if the robot is a simulation. + * * @return If the robot is running in simulation. */ public static boolean isSimulation() { @@ -80,6 +82,8 @@ public abstract class RobotBase { } /** + * Get if the robot is real. + * * @return If the robot is running in the real world. */ public static boolean isReal() { 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 eb08d4fb78..e0af5cde37 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/RobotDrive.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/RobotDrive.java @@ -503,10 +503,10 @@ public class RobotDrive implements MotorSafety { double sinD = Math.sin(dirInRad); double[] wheelSpeeds = new double[kMaxNumberOfMotors]; - wheelSpeeds[MotorType.kFrontLeft.value] = (sinD * magnitude + rotation); - wheelSpeeds[MotorType.kFrontRight.value] = (cosD * magnitude - rotation); - wheelSpeeds[MotorType.kRearLeft.value] = (cosD * magnitude + rotation); - wheelSpeeds[MotorType.kRearRight.value] = (sinD * magnitude - rotation); + wheelSpeeds[MotorType.kFrontLeft.value] = sinD * magnitude + rotation; + wheelSpeeds[MotorType.kFrontRight.value] = cosD * magnitude - rotation; + wheelSpeeds[MotorType.kRearLeft.value] = cosD * magnitude + rotation; + wheelSpeeds[MotorType.kRearRight.value] = sinD * magnitude - rotation; normalize(wheelSpeeds); diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SPI.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SPI.java index bda0f08e4b..5ecc98ca10 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SPI.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SPI.java @@ -234,7 +234,7 @@ public class SPI extends SensorBase { } /** - * Perform a simultaneous read/write transaction with the device + * Perform a simultaneous read/write transaction with the device. * * @param dataToSend The data to be written out to the device. Must be created using * ByteBuffer.allocateDirect(). diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SerialPort.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SerialPort.java index d14f7beb18..be53917d80 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SerialPort.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SerialPort.java @@ -273,7 +273,7 @@ public class SerialPort { } /** - * Write a string to the serial port + * Write a string to the serial port. * * @param data The string to write to the serial port. * @return The number of bytes actually written into the port. diff --git a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/CircularBuffer.java b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/CircularBuffer.java index 75ad7c1aeb..bb95a3c5ee 100644 --- a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/CircularBuffer.java +++ b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/CircularBuffer.java @@ -20,6 +20,8 @@ public class CircularBuffer { private int m_length = 0; /** + * Create a CircularBuffer with the provided size. + * * @param size The size of the circular buffer. */ public CircularBuffer(int size) { @@ -124,6 +126,8 @@ public class CircularBuffer { } /** + * Get the element at the provided index relative to the start of the buffer. + * * @return Element at index starting from front of buffer. */ public double get(int index) { diff --git a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/PIDController.java b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/PIDController.java index 4b5696ae69..56ece7baba 100644 --- a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/PIDController.java +++ b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/PIDController.java @@ -130,7 +130,7 @@ public class PIDController implements PIDInterface, LiveWindowSendable, Controll } /** - * Allocate a PID object with the given constants for P, I, D, and F + * Allocate a PID object with the given constants for P, I, D, and F. * * @param Kp the proportional coefficient * @param Ki the integral coefficient @@ -170,7 +170,7 @@ public class PIDController implements PIDInterface, LiveWindowSendable, Controll } /** - * Allocate a PID object with the given constants for P, I, D and period + * Allocate a PID object with the given constants for P, I, D and period. * * @param Kp the proportional coefficient * @param Ki the integral coefficient diff --git a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java index 89a138ed7c..356c95ab58 100644 --- a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java +++ b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java @@ -99,6 +99,8 @@ public class SmartDashboard { } /** + * Get the keys stored in the SmartDashboard table of NetworkTables. + * * @param types bitmask of types; 0 is treated as a "don't care". * @return keys currently in the table */ @@ -107,6 +109,8 @@ public class SmartDashboard { } /** + * Get the keys stored in the SmartDashboard table of NetworkTables. + * * @return keys currently in the table. */ public static Set getKeys() { diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/PIDToleranceTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/PIDToleranceTest.java index ddf7009de0..86927d1b9e 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/PIDToleranceTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/PIDToleranceTest.java @@ -96,12 +96,12 @@ public class PIDToleranceTest { assertFalse("Error was in tolerance when it should not have been. Error was " + m_pid.getAvgError(), m_pid.onTarget()); //half of percent tolerance away from setPoint - m_inp.m_val = m_setPoint + (m_tolerance) / 200 * m_range; + m_inp.m_val = m_setPoint + m_tolerance / 200 * m_range; Timer.delay(1.0); assertTrue("Error was not in tolerance when it should have been. Error was " + m_pid.getAvgError(), m_pid.onTarget()); //double percent tolerance away from setPoint - m_inp.m_val = m_setPoint + (m_tolerance) / 50 * m_range; + m_inp.m_val = m_setPoint + m_tolerance / 50 * m_range; Timer.delay(1.0); assertFalse("Error was in tolerance when it should not have been. Error was " + m_pid.getAvgError(), m_pid.onTarget()); diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/MockCommand.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/MockCommand.java index f58f5ae41f..d8169c5270 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/MockCommand.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/MockCommand.java @@ -70,6 +70,8 @@ public class MockCommand extends Command { } /** + * Get what value the isFinished method will return. + * * @return what value the isFinished method will return. */ public boolean isHasFinished() { @@ -77,6 +79,8 @@ public class MockCommand extends Command { } /** + * Set what value the isFinished method will return. + * * @param hasFinished set what value the isFinished method will return. */ public void setHasFinished(boolean hasFinished) { diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java index f29cf9f806..86205b26a5 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java @@ -44,7 +44,7 @@ public class MotorEncoderTest extends AbstractComsSetup { } /** - * Constructs the test + * Constructs the test. * * @param mef The fixture under test. */ diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PCMTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PCMTest.java index dbf871a7ec..3f9c329549 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PCMTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PCMTest.java @@ -161,21 +161,21 @@ public class PCMTest extends AbstractComsSetup { Timer.delay(kSolenoidDelayTime); assertTrue("Solenoid #1 did not turn off", fakeSolenoid1.get()); assertTrue("Solenoid #2 did not turn off", fakeSolenoid2.get()); - assertTrue("DoubleSolenoid did not report off", (solenoid.get() == DoubleSolenoid.Value.kOff)); + assertTrue("DoubleSolenoid did not report off", solenoid.get() == DoubleSolenoid.Value.kOff); solenoid.set(DoubleSolenoid.Value.kForward); Timer.delay(kSolenoidDelayTime); assertFalse("Solenoid #1 did not turn on", fakeSolenoid1.get()); assertTrue("Solenoid #2 did not turn off", fakeSolenoid2.get()); - assertTrue("DoubleSolenoid did not report Forward", (solenoid.get() == DoubleSolenoid.Value - .kForward)); + assertTrue("DoubleSolenoid did not report Forward", solenoid.get() == DoubleSolenoid.Value + .kForward); solenoid.set(DoubleSolenoid.Value.kReverse); Timer.delay(kSolenoidDelayTime); assertTrue("Solenoid #1 did not turn off", fakeSolenoid1.get()); assertFalse("Solenoid #2 did not turn on", fakeSolenoid2.get()); - assertTrue("DoubleSolenoid did not report Reverse", (solenoid.get() == DoubleSolenoid.Value - .kReverse)); + assertTrue("DoubleSolenoid did not report Reverse", solenoid.get() == DoubleSolenoid.Value + .kReverse); solenoid.free(); } diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/MotorEncoderFixture.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/MotorEncoderFixture.java index fad7f8c104..e516578fb9 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/MotorEncoderFixture.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/MotorEncoderFixture.java @@ -139,7 +139,7 @@ public abstract class MotorEncoderFixture implements */ public boolean isMotorSpeedWithinRange(double value, double accuracy) { initialize(); - return Math.abs((Math.abs(m_motor.get()) - Math.abs(value))) < Math.abs(accuracy); + return Math.abs(Math.abs(m_motor.get()) - Math.abs(value)) < Math.abs(accuracy); } @Override diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLanucher.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLanucher.java index 3f4b8fbd0f..2f3dd6d927 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLanucher.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLanucher.java @@ -23,7 +23,7 @@ import java.io.File; public class AntJunitLanucher { /** - * Main entry point for jenkins + * Main entry point for jenkins. * * @param args Arguments passed to java. */ diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestBench.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestBench.java index ec7608e8bd..5840f542d5 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestBench.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestBench.java @@ -343,7 +343,7 @@ public final class TestBench { false)); encoderPortPairs.addAll(getPairArray(getDIOCrossConnect().get(1), getDIOCrossConnect().get(0), false)); - assert (encoderPortPairs.size() == 8); + assert encoderPortPairs.size() == 8; return encoderPortPairs; } diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestSuite.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestSuite.java index de0ccf4e1c..3eeca7c090 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestSuite.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestSuite.java @@ -153,7 +153,7 @@ public class TestSuite extends AbstractTestSuite { /** * Parses the arguments passed at runtime and runs the appropriate tests based upon these - * arguments + * arguments. * * @param args the args passed into the program at runtime * @return the restults of the tests that have run. If no tests were run then null is returned.