mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Disable frivolous PMD warnings and enable PMD in ntcore (#3419)
Some valid warnings like throwing NullPointerException or using a for loop instead of System.arraycopy() were fixed. Abstract classes marked with PMD.AbstractClassWithoutAbstractMethod were made concrete because they already had protected constructors. Fixes #1697.
This commit is contained in:
@@ -27,7 +27,6 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
* @deprecated All APIs which use this have been deprecated.
|
||||
*/
|
||||
@Deprecated(since = "2020", forRemoval = true)
|
||||
@SuppressWarnings("PMD.TooManyFields")
|
||||
public class PIDBase implements PIDInterface, PIDOutput, Sendable, AutoCloseable {
|
||||
public static final double kDefaultPeriod = 0.05;
|
||||
private static int instances;
|
||||
@@ -81,9 +80,6 @@ public class PIDBase implements PIDInterface, PIDOutput, Sendable, AutoCloseable
|
||||
private double m_setpoint;
|
||||
private double m_prevSetpoint;
|
||||
|
||||
@SuppressWarnings("PMD.UnusedPrivateField")
|
||||
private double m_error;
|
||||
|
||||
private double m_result;
|
||||
|
||||
private LinearFilter m_filter;
|
||||
@@ -199,7 +195,7 @@ public class PIDBase implements PIDInterface, PIDOutput, Sendable, AutoCloseable
|
||||
* Read the input, calculate the output accordingly, and write to the output. This should only be
|
||||
* called by the PIDTask and is created during initialization.
|
||||
*/
|
||||
@SuppressWarnings({"LocalVariableName", "PMD.ExcessiveMethodLength", "PMD.NPathComplexity"})
|
||||
@SuppressWarnings("LocalVariableName")
|
||||
protected void calculate() {
|
||||
if (m_pidInput == null || m_pidOutput == null) {
|
||||
return;
|
||||
@@ -291,7 +287,6 @@ public class PIDBase implements PIDInterface, PIDOutput, Sendable, AutoCloseable
|
||||
m_thisMutex.lock();
|
||||
try {
|
||||
m_prevError = error;
|
||||
m_error = error;
|
||||
m_totalError = totalError;
|
||||
m_result = result;
|
||||
} finally {
|
||||
|
||||
@@ -36,7 +36,6 @@ import java.util.Enumeration;
|
||||
* @see CommandGroup
|
||||
* @see IllegalUseOfCommandException
|
||||
*/
|
||||
@SuppressWarnings("PMD.GodClass")
|
||||
public abstract class Command implements Sendable, AutoCloseable {
|
||||
/** The time since this command was initialized. */
|
||||
private double m_startTime = -1;
|
||||
|
||||
@@ -30,13 +30,13 @@ import java.util.Vector;
|
||||
*/
|
||||
public class CommandGroup extends Command {
|
||||
/** The commands in this group (stored in entries). */
|
||||
@SuppressWarnings({"PMD.LooseCoupling", "PMD.UseArrayListInsteadOfVector"})
|
||||
@SuppressWarnings("PMD.UseArrayListInsteadOfVector")
|
||||
private final Vector<Entry> m_commands = new Vector<>();
|
||||
/*
|
||||
* Intentionally package private
|
||||
*/
|
||||
/** The active children in this group (stored in entries). */
|
||||
@SuppressWarnings({"PMD.LooseCoupling", "PMD.UseArrayListInsteadOfVector"})
|
||||
@SuppressWarnings("PMD.UseArrayListInsteadOfVector")
|
||||
final Vector<Entry> m_children = new Vector<>();
|
||||
/** The current command, -1 signifies that none have been run. */
|
||||
private int m_currentCommandIndex = -1;
|
||||
@@ -205,7 +205,7 @@ public class CommandGroup extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"MethodName", "PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
|
||||
@SuppressWarnings("MethodName")
|
||||
void _execute() {
|
||||
Entry entry = null;
|
||||
Command cmd = null;
|
||||
|
||||
@@ -15,6 +15,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
@@ -46,8 +47,7 @@ public final class Scheduler implements Sendable, AutoCloseable {
|
||||
}
|
||||
|
||||
/** A hashtable of active {@link Command Commands} to their {@link LinkedListElement}. */
|
||||
@SuppressWarnings("PMD.LooseCoupling")
|
||||
private final Hashtable<Command, LinkedListElement> m_commandTable = new Hashtable<>();
|
||||
private final Map<Command, LinkedListElement> m_commandTable = new Hashtable<>();
|
||||
/** The {@link Set} of all {@link Subsystem Subsystems}. */
|
||||
private final Set m_subsystems = new Set();
|
||||
/** The first {@link Command} in the list. */
|
||||
@@ -59,13 +59,12 @@ public final class Scheduler implements Sendable, AutoCloseable {
|
||||
/** Whether or not we are currently disabled. */
|
||||
private boolean m_disabled;
|
||||
/** A list of all {@link Command Commands} which need to be added. */
|
||||
@SuppressWarnings({"PMD.LooseCoupling", "PMD.UseArrayListInsteadOfVector"})
|
||||
@SuppressWarnings("PMD.UseArrayListInsteadOfVector")
|
||||
private final Vector<Command> m_additions = new Vector<>();
|
||||
/**
|
||||
* A list of all {@link edu.wpi.first.wpilibj.buttons.Trigger.ButtonScheduler Buttons}. It is
|
||||
* created lazily.
|
||||
*/
|
||||
@SuppressWarnings("PMD.LooseCoupling")
|
||||
private Vector<ButtonScheduler> m_buttons;
|
||||
|
||||
private boolean m_runningCommandsChanged;
|
||||
@@ -129,7 +128,7 @@ public final class Scheduler implements Sendable, AutoCloseable {
|
||||
*
|
||||
* @param command the {@link Command} to add
|
||||
*/
|
||||
@SuppressWarnings({"MethodName", "PMD.CyclomaticComplexity"})
|
||||
@SuppressWarnings("MethodName")
|
||||
private void _add(Command command) {
|
||||
if (command == null) {
|
||||
return;
|
||||
@@ -194,7 +193,6 @@ public final class Scheduler implements Sendable, AutoCloseable {
|
||||
* <li>Add Defaults
|
||||
* </ol>
|
||||
*/
|
||||
@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
|
||||
public void run() {
|
||||
m_runningCommandsChanged = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user