Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Autonomous #22

Draft
wants to merge 99 commits into
base: master
Choose a base branch
from
Draft

Create Autonomous #22

wants to merge 99 commits into from

Conversation

NotMePipe
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Feb 22, 2022

Codecov Report

Merging #22 (94bf62c) into master (3e929cc) will decrease coverage by 2.32%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #22      +/-   ##
===========================================
- Coverage      9.74%   7.42%   -2.33%     
  Complexity       17      17              
===========================================
  Files            18      22       +4     
  Lines           677     889     +212     
  Branches         44      80      +36     
===========================================
  Hits             66      66              
- Misses          611     823     +212     
Impacted Files Coverage Δ
src/main/java/frc/robot/Autonomous.java 0.00% <0.00%> (ø)
src/main/java/frc/robot/DriveModule.java 0.00% <0.00%> (ø)
src/main/java/frc/robot/Drivetrain.java 0.00% <0.00%> (ø)
src/main/java/frc/robot/JsonAutonomous.java 0.00% <0.00%> (ø)
src/main/java/frc/robot/Manipulation.java 0.00% <0.00%> (ø)
src/main/java/frc/robot/Robot.java 0.00% <0.00%> (ø)
src/main/java/frc/robot/Shooter.java 0.00% <0.00%> (ø)
src/main/java/frc/robot/logging/LoggableGyro.java 0.00% <ø> (ø)

Impacted file tree graph

}
} else if(u.equals(AutoInstruction.Unit.CURRENT)) {
//amount: motor current to stop at
if(driveCurrent(ai.args.get(0), ai.args.get(0), ai.amount)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge this if statement with the enclosing one.

* Creates a JsonAutonomous from the specified file
* @param file The location of the file to parse
*/
public JsonAutonomous(String file, LoggableGyro gyro, Drivetrain drive, Shooter shooter, Manipulation manipulation) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is longer than 100 characters (found 121).

}
}

private void shoot(AutoInstruction ai) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method shoot has 30 lines of code (exceeds 25 allowed). Consider refactoring.

}
} else if(u.equals(AutoInstruction.Unit.FEET) || u.equals(AutoInstruction.Unit.INCHES)) {
//amount: feet/inches to drive
if(driveDistance(ai.args.get(0), ai.args.get(0), (u.equals(AutoInstruction.Unit.INCHES) ? ai.amount * TICKS_PER_INCH : (ai.amount * TICKS_PER_INCH) * 12))) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is longer than 100 characters (found 169).

@@ -95,12 +120,20 @@ public void robotPeriodic() {

@Override
public void autonomousInit() {
gyro.reset();

auto = new JsonAutonomous("/home/lvuser/deploy/autos/auto-test.json", gyro, drive, shooter, manipulation);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is longer than 100 characters (found 114).

if(drive.getAverageCurrent() < current) {
drive.drive(leftPower, rightPower, false);
} else {
//drive.drive(0, 0);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of commented-out lines of code should be removed.

}

private void shoot(AutoInstruction ai) {
AutoInstruction.Unit u = ai.unit;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this useless assignment to local variable "u".

private void shoot(AutoInstruction ai) {
AutoInstruction.Unit u = ai.unit;
System.out.println(shooter.getSpeed());
//shooter.setPower(SHOOTER_SPEED);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of commented-out lines of code should be removed.


private static final double TICKS_PER_ROTATION = 16750; //TODO: Update value for 2022 robot
private static final double TICKS_PER_INCH = TICKS_PER_ROTATION / (6 * Math.PI); //TODO: Update formula for 2022 robot
private static final double SHOOTER_SPEED = 1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this unused "SHOOTER_SPEED" private field.

private Drivetrain drive;

private Shooter shooter;
private Manipulation manipulation;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this unused "manipulation" private field.

return false;
}

public boolean driveCurrent(double leftPower, double rightPower, double current) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

return false;
}

private boolean driveTime(double leftPower, double rightPower, double time) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

public void drive(double leftSpeed, double rightSpeed) { // Probably implement deadbands later
left.setSpeed(leftSpeed);
right.setSpeed(rightSpeed);
public void drive(double leftValue, double rightValue, boolean power) { // Probably implement deadbands later
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is longer than 100 characters (found 113).


public class Shooter implements Loggable {
TalonFX shooterMotor;
Shooter(int shooterID) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'CTOR_DEF' should be separated from previous statement.

@@ -95,12 +121,22 @@ public void robotPeriodic() {

@Override
public void autonomousInit() {
gyro.reset();

auto = new JsonAutonomous("/home/lvuser/deploy/autos/shooter-test.json", gyro, drive, shooter, manipulation);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is longer than 100 characters (found 117).

parseFile(file);
}

public void parseFile(String file) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor this method to reduce its Cognitive Complexity from 23 to the 15 allowed.

}
} else if (u.equals(AutoInstruction.Unit.CURRENT)) {
// amount: motor current to stop at
if (driveCurrent(ai.args.get(0), ai.args.get(0), ai.amount)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge this if statement with the enclosing one.

private void shoot(AutoInstruction ai) {
AutoInstruction.Unit u = ai.unit;
System.out.println(shooter.getSpeed());
// shooter.setPower(SHOOTER_SPEED);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of commented-out lines of code should be removed.

if (drive.getAverageCurrent() < current) {
drive.drive(leftPower, rightPower, false);
} else {
// drive.drive(0, 0);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of commented-out lines of code should be removed.

System.out.println(shooter.getSpeed());
// shooter.setPower(SHOOTER_SPEED);
/*
* if(u == AutoInstruction.Unit.SPEED) { if(shooter.getSpeed() < SHOOTER_SPEED) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of commented-out lines of code should be removed.

parseFile(file);
}

public void parseFile(String file) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method parseFile has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.

parseFile(file);
}

public void parseFile(String file) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method parseFile has 29 lines of code (exceeds 25 allowed). Consider refactoring.


public class JsonAutonomous extends Autonomous implements Loggable {

private static final double TICKS_PER_ROTATION = 16750; // TODO: Update value for 2022 robot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO found

public class JsonAutonomous extends Autonomous implements Loggable {

private static final double TICKS_PER_ROTATION = 16750; // TODO: Update value for 2022 robot
private static final double TICKS_PER_INCH = TICKS_PER_ROTATION / (6 * Math.PI); // TODO: Update
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO found

Co-authored-by: NotMePipe <[email protected]>
Co-authored-by: theblindbandet <[email protected]>
parseFile(file);
}

public void parseFile(String file) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor this method to reduce its Cognitive Complexity from 26 to the 15 allowed.

parseFile(file);
}

public void parseFile(String file) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method parseFile has 33 lines of code (exceeds 25 allowed). Consider refactoring.

parseFile(file);
}

public void parseFile(String file) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method parseFile has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.

reset();
}
}
} else if (u == AutoInstruction.Unit.POWER) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

private void shoot(AutoInstruction ai) {
AutoInstruction.Unit u = ai.unit;

if (u == AutoInstruction.Unit.SPEED) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

@@ -0,0 +1,315 @@
package frc.robot;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File JsonAutonomous.java has 255 lines of code (exceeds 250 allowed). Consider refactoring.

@@ -95,12 +121,21 @@ public void robotPeriodic() {

@Override
public void autonomousInit() {
gyro.reset();

auto = new JsonAutonomous(JsonAutonomous.getAutoPath("shooter-test.json"), gyro, drive, shooter, manipulation);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is longer than 100 characters (found 119).

@codeclimate
Copy link

codeclimate bot commented Apr 9, 2022

Code Climate has analyzed commit 94bf62c and detected 36 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 11
Duplication 6
Clarity 2
Style 15
Bug Risk 2

Note: there are 3 critical issues.

The test coverage on the diff in this pull request is 0.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 7.4% (-2.2% change).

View more on Code Climate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants