mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Checkstyle 8.1 (#584)
Added a few checks too: - SimplifyBooleanExpression - SimplifyBooleanReturn - StringLiteralEquality - UnnecessaryParentheses
This commit is contained in:
committed by
Peter Johnson
parent
3cfcbe9a95
commit
ddd5aeba19
@@ -41,7 +41,7 @@ subprojects {
|
||||
apply plugin: 'checkstyle'
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "6.18"
|
||||
toolVersion = "8.1"
|
||||
configFile = new File(rootDir, "styleguide/checkstyle.xml")
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
<module name="NewlineAtEndOfFile">
|
||||
<property name="lineSeparator" value="lf"/>
|
||||
</module>
|
||||
|
||||
<module name="SuppressWarningsFilter" />
|
||||
|
||||
@@ -84,6 +87,10 @@
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="FallThrough"/>
|
||||
<module name="SimplifyBooleanExpression"/>
|
||||
<module name="SimplifyBooleanReturn"/>
|
||||
<module name="StringLiteralEquality"/>
|
||||
<module name="UnnecessaryParentheses"/>
|
||||
<module name="UpperEll"/>
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="EmptyLineSeparator">
|
||||
|
||||
@@ -5,4 +5,5 @@
|
||||
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
|
||||
<suppressions>
|
||||
<suppress files=".*sim.*" checks="[a-zA-Z0-9]*"/>
|
||||
<suppress files="edu.wpi.first.wpilibj.util.WPILibVersion" checks="[a-zA-Z0-9]*"/>
|
||||
</suppressions>
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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().
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<String> getKeys() {
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class MotorEncoderTest extends AbstractComsSetup {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the test
|
||||
* Constructs the test.
|
||||
*
|
||||
* @param mef The fixture under test.
|
||||
*/
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public abstract class MotorEncoderFixture<T extends SpeedController> 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
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user