Test Failed
Push — master ( 08f71e...df8093 )
by John
02:02
created

isFinished()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
package org.usfirst.frc.team3695.robot.commands;
2
3
import edu.wpi.first.wpilibj.command.Command;
4
import org.usfirst.frc.team3695.robot.Robot;
5
import org.usfirst.frc.team3695.robot.util.Util;
6
7
/** Toggle PID */
8
public class ToggleCommandKillPID extends Command {
9
	
10
	public static Boolean PID_ENABLED;
0 ignored issues
show
Security introduced by
public static fields should always be marked final to prevent them being overwritten in unexpected ways. Consider making PID_ENABLED final.

See this CWE advisory on why this is a security issue.

Loading history...
11
12
    public ToggleCommandKillPID() {
13
        requires(Robot.SUB_DRIVE);
14
        PID_ENABLED = true;
0 ignored issues
show
Bug Multi Threading introduced by
Lazy initializations of static fields like PID_ENABLED should be synchronized.
Loading history...
15
    }
16
17
    protected void initialize() {
18
    	PID_ENABLED = !PID_ENABLED;
0 ignored issues
show
Bug Multi Threading introduced by
Instance methods writing to static fields may lead to concurrency problems. Consider making the enclosing method static or removing this assignment to a static field.

If you really need to set this static field, consider writing a thread-safe setter and atomic getter.

Loading history...
Bug Multi Threading introduced by
Lazy initializations of static fields like PID_ENABLED should be synchronized.
Loading history...
19
    	if (PID_ENABLED) {
20
    		Robot.SUB_DRIVE.pid.setPIDF(Util.getAndSetDouble("P", .5),
0 ignored issues
show
Comprehensibility introduced by
Consider assigning this magic number .5 to a constant.

Using constants for hard-coded numbers is a best practice. A constant’s name can explain the rationale behind this magic number. It is also easier to find if you ever need to change it.

Loading history...
21
                    					Util.getAndSetDouble("I", 0),
22
                    					Util.getAndSetDouble("D", 0),
23
                    					Util.getAndSetDouble("F", 0));
24
    	} else {
25
    		Robot.SUB_DRIVE.pid.setPIDF(0,0,0,0);
26
    	}
27
    }
28
29
    protected void execute() { }
30
31
    protected boolean isFinished() {
32
        return true;
33
    }
34
35
    protected void end() {}
36
37
    protected void interrupted() {}
38
}
39