Skip to content

Create Autonomous#22

Draft
NotMePipe wants to merge 99 commits into
masterfrom
autonomous
Draft

Create Autonomous#22
NotMePipe wants to merge 99 commits into
masterfrom
autonomous

Conversation

@NotMePipe
Copy link
Copy Markdown
Contributor

No description provided.

@codecov
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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).

Comment thread src/main/java/frc/robot/Robot.java Outdated
public void autonomousInit() {
gyro.reset();

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

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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.

Comment thread src/main/java/frc/robot/Drivetrain.java Outdated
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
Copy Markdown

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
Copy Markdown

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.

Comment thread src/main/java/frc/robot/Robot.java Outdated
public void autonomousInit() {
gyro.reset();

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

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).

GingerJakeDaBoi and others added 3 commits March 21, 2022 20:17
Co-authored-by: theblindbandet <me@thisismy.computer>
Co-authored-by: theblindbandet <me@thisismy.computer>
parseFile(file);
}

public void parseFile(String file) {
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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 <mepipeofficial@gmail.com>
Co-authored-by: theblindbandet <me@thisismy.computer>
parseFile(file);
}

public void parseFile(String file) {
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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.

NotMePipe and others added 3 commits March 22, 2022 19:33
As a plus, it also works in simulations now!

Co-authored-by: theblindbandet <me@thisismy.computer>
@@ -0,0 +1,315 @@
package frc.robot;
Copy link
Copy Markdown

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.

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

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

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).

@qlty-cloud-legacy
Copy link
Copy Markdown

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