mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
Java cleanups (#1776)
* Remove extra ';'s * Remove unnecessary conversions to String * Use StandardCharsets object * Replace infinite while with check for interrupted thread * Remove redundant local vars * Remove redundant throws clause * Remove redundant primitive wrapping * Fix malformed Nested class test * Remove unnecessary unboxing * Remove unnecessary explicit type argument * Replace lambdas with method references * Replace statement lambdas with expression lambdas * Replace null check with method call * Replace number comparison with method call * Fix broken javadoc comments * Replace Arrays.asList with singletonLists * Remove excessive lambda usage * Remove redundant string operation * Remove redundant type casts * Remove unnecessary returns * Remove redundant suppressions * Fix unresolved file reference * static analysis fixes
This commit is contained in:
committed by
Peter Johnson
parent
39561751fc
commit
df12fc2a86
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -15,7 +15,6 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
import org.junit.runners.model.InitializationError;
|
||||
|
||||
import edu.wpi.first.wpilibj.test.AbstractTestSuite.ClassMethodPair;
|
||||
|
||||
@@ -40,12 +39,12 @@ public class AbstractTestSuiteTest {
|
||||
TestForAbstractTestSuite m_testSuite;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
m_testSuite = new TestForAbstractTestSuite();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTestsMatchingAll() throws InitializationError {
|
||||
public void testGetTestsMatchingAll() {
|
||||
// when
|
||||
List<Class<?>> collectedTests = m_testSuite.getAllClassMatching(".*");
|
||||
// then
|
||||
@@ -53,7 +52,7 @@ public class AbstractTestSuiteTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTestsMatchingSample() throws InitializationError {
|
||||
public void testGetTestsMatchingSample() {
|
||||
// when
|
||||
List<Class<?>> collectedTests = m_testSuite.getAllClassMatching(".*Sample.*");
|
||||
// then
|
||||
@@ -61,7 +60,7 @@ public class AbstractTestSuiteTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTestsMatchingUnusual() throws InitializationError {
|
||||
public void testGetTestsMatchingUnusual() {
|
||||
// when
|
||||
List<Class<?>> collectedTests = m_testSuite.getAllClassMatching(".*Unusual.*");
|
||||
// then
|
||||
@@ -70,7 +69,7 @@ public class AbstractTestSuiteTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTestsFromSuiteMatchingAll() throws InitializationError {
|
||||
public void testGetTestsFromSuiteMatchingAll() {
|
||||
// when
|
||||
List<Class<?>> collectedTests = m_testSuite.getSuiteOrTestMatchingRegex(".*");
|
||||
// then
|
||||
@@ -78,7 +77,7 @@ public class AbstractTestSuiteTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTestsFromSuiteMatchingTest() throws InitializationError {
|
||||
public void testGetTestsFromSuiteMatchingTest() {
|
||||
// when
|
||||
List<Class<?>> collectedTests = m_testSuite.getSuiteOrTestMatchingRegex(".*Test.*");
|
||||
// then
|
||||
|
||||
@@ -80,7 +80,7 @@ public final class TestBench {
|
||||
* @return a freshly allocated Talon, Encoder pair
|
||||
*/
|
||||
public MotorEncoderFixture<Talon> getTalonPair() {
|
||||
MotorEncoderFixture<Talon> talonPair = new MotorEncoderFixture<Talon>() {
|
||||
return new MotorEncoderFixture<Talon>() {
|
||||
@Override
|
||||
protected Talon giveSpeedController() {
|
||||
return new Talon(kTalonChannel);
|
||||
@@ -101,7 +101,6 @@ public final class TestBench {
|
||||
return kTalonPDPChannel;
|
||||
}
|
||||
};
|
||||
return talonPair;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +110,7 @@ public final class TestBench {
|
||||
* @return a freshly allocated Victor, Encoder pair
|
||||
*/
|
||||
public MotorEncoderFixture<Victor> getVictorPair() {
|
||||
MotorEncoderFixture<Victor> vicPair = new MotorEncoderFixture<Victor>() {
|
||||
return new MotorEncoderFixture<Victor>() {
|
||||
@Override
|
||||
protected Victor giveSpeedController() {
|
||||
return new Victor(kVictorChannel);
|
||||
@@ -132,7 +131,6 @@ public final class TestBench {
|
||||
return kVictorPDPChannel;
|
||||
}
|
||||
};
|
||||
return vicPair;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +140,7 @@ public final class TestBench {
|
||||
* @return a freshly allocated Jaguar, Encoder pair
|
||||
*/
|
||||
public MotorEncoderFixture<Jaguar> getJaguarPair() {
|
||||
MotorEncoderFixture<Jaguar> jagPair = new MotorEncoderFixture<Jaguar>() {
|
||||
return new MotorEncoderFixture<Jaguar>() {
|
||||
@Override
|
||||
protected Jaguar giveSpeedController() {
|
||||
return new Jaguar(kJaguarChannel);
|
||||
@@ -163,7 +161,6 @@ public final class TestBench {
|
||||
return kJaguarPDPChannel;
|
||||
}
|
||||
};
|
||||
return jagPair;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,7 +169,8 @@ public final class TestBench {
|
||||
* @return a freshly allocated Servo's and a freshly allocated Gyroscope
|
||||
*/
|
||||
public TiltPanCameraFixture getTiltPanCam() {
|
||||
TiltPanCameraFixture tpcam = new TiltPanCameraFixture() {
|
||||
|
||||
return new TiltPanCameraFixture() {
|
||||
@Override
|
||||
protected AnalogGyro giveGyro() {
|
||||
AnalogGyro gyro = new AnalogGyro(kGyroChannel);
|
||||
@@ -197,13 +195,10 @@ public final class TestBench {
|
||||
return new Servo(kPanServoChannel);
|
||||
}
|
||||
};
|
||||
|
||||
return tpcam;
|
||||
}
|
||||
|
||||
public DIOCrossConnectFixture getDIOCrossConnectFixture(int inputPort, int outputPort) {
|
||||
DIOCrossConnectFixture dio = new DIOCrossConnectFixture(inputPort, outputPort);
|
||||
return dio;
|
||||
return new DIOCrossConnectFixture(inputPort, outputPort);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,7 +223,7 @@ public final class TestBench {
|
||||
|
||||
@SuppressWarnings("JavadocMethod")
|
||||
public static AnalogCrossConnectFixture getAnalogCrossConnectFixture() {
|
||||
AnalogCrossConnectFixture analogIO = new AnalogCrossConnectFixture() {
|
||||
return new AnalogCrossConnectFixture() {
|
||||
@Override
|
||||
protected AnalogOutput giveAnalogOutput() {
|
||||
return new AnalogOutput(0);
|
||||
@@ -239,12 +234,11 @@ public final class TestBench {
|
||||
return new AnalogInput(2);
|
||||
}
|
||||
};
|
||||
return analogIO;
|
||||
}
|
||||
|
||||
@SuppressWarnings("JavadocMethod")
|
||||
public static RelayCrossConnectFixture getRelayCrossConnectFixture() {
|
||||
RelayCrossConnectFixture relay = new RelayCrossConnectFixture() {
|
||||
return new RelayCrossConnectFixture() {
|
||||
@Override
|
||||
protected Relay giveRelay() {
|
||||
return new Relay(0);
|
||||
@@ -260,7 +254,6 @@ public final class TestBench {
|
||||
return new DigitalInput(19);
|
||||
}
|
||||
};
|
||||
return relay;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user