mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01: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) 2016-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-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. */
|
||||
@@ -20,7 +20,7 @@ public final class MockHardwareExtension implements BeforeAllCallback {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeAll(ExtensionContext context) throws Exception {
|
||||
public void beforeAll(ExtensionContext context) {
|
||||
getRoot(context).getStore(Namespace.GLOBAL).getOrComputeIfAbsent("HAL Initalized", key -> {
|
||||
initializeHardware();
|
||||
return true;
|
||||
|
||||
@@ -26,7 +26,7 @@ class TrapezoidProfileTest {
|
||||
* @param val2 Second operand in comparison.
|
||||
*/
|
||||
private static void assertLessThanOrEquals(double val1, double val2) {
|
||||
assertTrue(val1 <= val2, Double.toString(val1) + " is greater than " + val2);
|
||||
assertTrue(val1 <= val2, val1 + " is greater than " + val2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-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. */
|
||||
@@ -48,7 +48,7 @@ public abstract class UtilityClassTest {
|
||||
public void constructorReflectionTest() {
|
||||
Constructor constructor = m_clazz.getDeclaredConstructors()[0];
|
||||
constructor.setAccessible(true);
|
||||
assertThrows(InvocationTargetException.class, () -> constructor.newInstance());
|
||||
assertThrows(InvocationTargetException.class, constructor::newInstance);
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
|
||||
@@ -23,9 +23,7 @@ class WatchdogTest {
|
||||
void enableDisableTest() {
|
||||
final AtomicInteger watchdogCounter = new AtomicInteger(0);
|
||||
|
||||
final Watchdog watchdog = new Watchdog(0.4, () -> {
|
||||
watchdogCounter.addAndGet(1);
|
||||
});
|
||||
final Watchdog watchdog = new Watchdog(0.4, () -> watchdogCounter.addAndGet(1));
|
||||
|
||||
System.out.println("Run 1");
|
||||
watchdog.enable();
|
||||
@@ -69,9 +67,7 @@ class WatchdogTest {
|
||||
void resetTest() {
|
||||
final AtomicInteger watchdogCounter = new AtomicInteger(0);
|
||||
|
||||
final Watchdog watchdog = new Watchdog(0.4, () -> {
|
||||
watchdogCounter.addAndGet(1);
|
||||
});
|
||||
final Watchdog watchdog = new Watchdog(0.4, () -> watchdogCounter.addAndGet(1));
|
||||
|
||||
watchdog.enable();
|
||||
try {
|
||||
@@ -94,9 +90,7 @@ class WatchdogTest {
|
||||
void setTimeoutTest() {
|
||||
final AtomicInteger watchdogCounter = new AtomicInteger(0);
|
||||
|
||||
final Watchdog watchdog = new Watchdog(1.0, () -> {
|
||||
watchdogCounter.addAndGet(1);
|
||||
});
|
||||
final Watchdog watchdog = new Watchdog(1.0, () -> watchdogCounter.addAndGet(1));
|
||||
|
||||
watchdog.enable();
|
||||
try {
|
||||
@@ -146,9 +140,7 @@ class WatchdogTest {
|
||||
void epochsTest() {
|
||||
final AtomicInteger watchdogCounter = new AtomicInteger(0);
|
||||
|
||||
final Watchdog watchdog = new Watchdog(0.4, () -> {
|
||||
watchdogCounter.addAndGet(1);
|
||||
});
|
||||
final Watchdog watchdog = new Watchdog(0.4, () -> watchdogCounter.addAndGet(1));
|
||||
|
||||
System.out.println("Run 1");
|
||||
watchdog.enable();
|
||||
@@ -194,12 +186,8 @@ class WatchdogTest {
|
||||
final AtomicInteger watchdogCounter1 = new AtomicInteger(0);
|
||||
final AtomicInteger watchdogCounter2 = new AtomicInteger(0);
|
||||
|
||||
final Watchdog watchdog1 = new Watchdog(0.2, () -> {
|
||||
watchdogCounter1.addAndGet(1);
|
||||
});
|
||||
final Watchdog watchdog2 = new Watchdog(0.6, () -> {
|
||||
watchdogCounter2.addAndGet(1);
|
||||
});
|
||||
final Watchdog watchdog1 = new Watchdog(0.2, () -> watchdogCounter1.addAndGet(1));
|
||||
final Watchdog watchdog2 = new Watchdog(0.6, () -> watchdogCounter2.addAndGet(1));
|
||||
|
||||
watchdog2.enable();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user