Update and enable PMD 6.3.0 (#1107)

This commit is contained in:
Austin Shalit
2018-06-03 10:00:53 -07:00
committed by Peter Johnson
parent 8eafe7f325
commit e548a5f705
156 changed files with 619 additions and 325 deletions

View File

@@ -8,9 +8,10 @@
package edu.wpi.first.wpilibj;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import java.nio.file.Files;
import java.util.Enumeration;
import java.util.jar.Manifest;
@@ -188,9 +189,9 @@ public abstract class RobotBase implements AutoCloseable {
if (propVal == null) {
return defaultValue;
}
if (propVal.equalsIgnoreCase("false")) {
if ("false".equalsIgnoreCase(propVal)) {
return false;
} else if (propVal.equalsIgnoreCase("true")) {
} else if ("true".equalsIgnoreCase(propVal)) {
return true;
} else {
throw new IllegalStateException(propVal);
@@ -218,7 +219,8 @@ public abstract class RobotBase implements AutoCloseable {
/**
* Starting point for the applications.
*/
@SuppressWarnings("PMD.UnusedFormalParameter")
@SuppressWarnings({"PMD.AvoidInstantiatingObjectsInLoops", "PMD.AvoidCatchingThrowable",
"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
public static void main(String... args) {
if (!HAL.initialize(500, 0)) {
throw new IllegalStateException("Failed to initialize. Terminating");
@@ -232,7 +234,8 @@ public abstract class RobotBase implements AutoCloseable {
} else {
Enumeration<URL> resources = null;
try {
resources = RobotBase.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
resources = Thread.currentThread()
.getContextClassLoader().getResources("META-INF/MANIFEST.MF");
} catch (IOException ex) {
ex.printStackTrace();
}
@@ -273,7 +276,7 @@ public abstract class RobotBase implements AutoCloseable {
file.createNewFile();
try (FileOutputStream output = new FileOutputStream(file)) {
try (OutputStream output = Files.newOutputStream(file.toPath())) {
output.write("Java ".getBytes());
output.write(WPILibVersion.Version.getBytes());
}