Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,51 @@
# BSOS Becker Summer of Swerve
# BSOS - Becker Summer of Swerve

## Workflow
How do we want to manage our Github workflow?


## Coding conventions
What Style Guide is used. How to install?

### Using the Google Java Style Guide in Visual Studio Code

The purpose of implementing a process to use a style guide is to make the code-base easier to read. Without it, style inconsistency can become an issue when several people are actively participating in a shared workspace. Follow the steps below to setup live linting using *Checkstyle for Java*. We will be using a slighly modified version of the Java style guide from Google.

1. Copy *google_checks.xml* to the project's root from https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
2. Install *Checkstyle for Java* from VS Code extensions
3. Update *settings.json* by adding the following:

```
"[java]": {
"editor.tabSize": 4,
"editor.detectIndentation": false,
"editor.insertSpaces": true
},
"editor.formatOnSave": false,
"java.checkstyle.configuration": "${workspaceFolder}/google_checks.xml",
"java.checkstyle.version": "10.3",
```
4. Apply 4607-specific settings:

For member naming *m_lowerCamelCase*, replace

<module name="MemberName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>

with

<module name="MemberName">
<property name="format" value="^m_[a-z][a-z0-9][a-zA-Z0-9]*$"/>


For further information, see the following:

- https://code.visualstudio.com/docs/java/java-linting
- https://checkstyle.sourceforge.io/
- https://google.github.io/styleguide/javaguide.html

### Error Reports

If your build is failing and you want to see more information, check the build/reports folder. There you can find reports generated by checkstyle, pmd, and spotbugs. Just double click on the `.html` files to open them in your web browser. You should also check your console as error prone does not produce a report as well as to see which plugin is causing the build to fail.


## Unit testing
rules
rules
32 changes: 32 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2022.4.1"
id "com.github.spotbugs" version "5.0.8"
id "net.ltgt.errorprone" version "2.0.2"
id "pmd"
id 'checkstyle'
}

sourceCompatibility = JavaVersion.VERSION_11
Expand Down Expand Up @@ -66,6 +70,34 @@ dependencies {
simulationRelease wpi.sim.enableRelease()

testImplementation 'junit:junit:4.13.1'

errorprone("com.google.errorprone:error_prone_core:2.14.0")
}

spotbugsMain {
excludeFilter = file("config/spotbugsexclude.xml")
reports {
html {
required = true
outputLocation = file("$buildDir/reports/spotbugs/main/spotbugs.html")
stylesheet = 'fancy-hist.xsl'
}
}
}

pmd {
consoleOutput = true
toolVersion = "6.46.0"
rulesMinimumPriority = 5
ruleSetFiles = files("config/pmdruleset.xml")
ruleSets = [] // This needs to be here otherwise the custom ruleset doesn't work.
}

checkstyle {
toolVersion = '10.3'
ignoreFailures = false
maxWarnings = 0
config = resources.text.fromUri("https://raw.githubusercontent.com/FRC4607/common/main/google_checks.xml")
}

// Simulation configuration (e.g. environment variables).
Expand Down
18 changes: 18 additions & 0 deletions config/pmdruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>

<ruleset name="Ruleset"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">

<description>
A ruleset with changes to make WPILib programming easier.
</description>

<rule ref="category/java/errorprone.xml">
<exclude name="BeanMembersShouldSerialize" />
</rule>
<rule ref="category/java/bestpractices.xml" />
<rule ref="category/java/multithreading.xml" />
<rule ref="category/java/performance.xml" />
</ruleset>
5 changes: 5 additions & 0 deletions config/spotbugsexclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<FindBugsFilter>
<Match>
<Bug pattern="EI_EXPOSE_REP, EI_EXPOSE_REP2" />
</Match>
</FindBugsFilter>
10 changes: 5 additions & 5 deletions gradlew
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
mavenCentral()
String frcYear = '2022'
File frcHome
if (OperatingSystem.current().isWindows()) {
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
package frc.robot;

/**
* The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean
* constants. This class should not be used for any other purpose. All constants should be declared
* The Constants class provides a convenient place for teams to hold robot-wide
* numerical or boolean
* constants. This class should not be used for any other purpose. All constants
* should be declared
* globally (i.e. public static). Do not put anything functional in this class.
*
* <p>It is advised to statically import this class (or one of its inner classes) wherever the
* <p>It is advised to statically import this class (or one of its inner classes)
* wherever the
* constants are needed, to reduce verbosity.
*/
public final class Constants {}
public final class Constants {
}
27 changes: 16 additions & 11 deletions src/main/java/frc/robot/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@
import edu.wpi.first.wpilibj.RobotBase;

/**
* Do NOT add any static variables to this class, or any initialization at all. Unless you know what
* you are doing, do not modify this file except to change the parameter class to the startRobot
* Do NOT add any static variables to this class, or any initialization at all.
* Unless you know what
* you are doing, do not modify this file except to change the parameter class
* to the startRobot
* call.
*/
public final class Main {
private Main() {}
private Main() {
}

/**
* Main initialization function. Do not perform any initialization here.
*
* <p>If you change your main robot class, change the parameter type.
*/
public static void main(String... args) {
RobotBase.startRobot(Robot::new);
}
/**
* Main initialization function. Do not perform any initialization here.
*
* <p>
* If you change your main robot class, change the parameter type.
* </p>
*/
public static void main(String... args) {
RobotBase.startRobot(Robot::new);
}
}
Loading