-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
- Loading branch information
1 parent
a19e6ab
commit e404907
Showing
14 changed files
with
223 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Build | ||
|
||
on: [pull_request, push] | ||
|
||
jobs: | ||
build: | ||
name: "Build Java" | ||
runs-on: ubuntu-latest | ||
container: wpilib/roborio-cross-ubuntu:2024-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Compile robot code | ||
run: ./gradlew build | ||
|
||
format: | ||
name: "Lint and Format Java" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Fetch all history and metadata | ||
run: | | ||
git checkout -b pr | ||
git branch -f master origin/master | ||
- uses: actions/setup-java@v4 | ||
with: | ||
java-version: 17 | ||
distribution: temurin | ||
- uses: gradle/gradle-build-action@v3 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.8 | ||
- name: Install wpiformat | ||
run: pip3 install wpiformat | ||
- name: Run | ||
run: wpiformat | ||
- name: Check output | ||
run: git --no-pager diff --exit-code HEAD | ||
- name: Run spotless | ||
run: ./gradlew build -PwithJavaFormat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="CurtinFRC 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 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> | ||
|
||
<description>PMD Ruleset for Curtin FRC Projects</description> | ||
|
||
<exclude-pattern>.*/*JNI.*</exclude-pattern> | ||
|
||
<rule ref="category/java/bestpractices.xml"> | ||
<exclude name="AccessorClassGeneration" /> | ||
<exclude name="AccessorMethodGeneration" /> | ||
<exclude name="AvoidPrintStackTrace" /> | ||
<exclude name="AvoidReassigningCatchVariables" /> | ||
<exclude name="AvoidReassigningParameters" /> | ||
<exclude name="AvoidUsingHardCodedIP" /> | ||
<exclude name="ConstantsInInterface" /> | ||
<exclude name="JUnitAssertionsShouldIncludeMessage" /> | ||
<exclude name="JUnitTestContainsTooManyAsserts" /> | ||
<exclude name="JUnitTestsShouldIncludeAssert" /> | ||
<exclude name="JUnit4TestShouldUseAfterAnnotation" /> | ||
<exclude name="JUnit4TestShouldUseBeforeAnnotation" /> | ||
<exclude name="JUnit4TestShouldUseTestAnnotation" /> | ||
<exclude name="LooseCoupling" /> | ||
<exclude name="PreserveStackTrace" /> | ||
<exclude name="ReplaceHashtableWithMap" /> | ||
<exclude name="ReplaceVectorWithList" /> | ||
<exclude name="SwitchStmtsShouldHaveDefault" /> | ||
<exclude name="SystemPrintln" /> | ||
<exclude name="UseVarargs" /> | ||
</rule> | ||
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod"> | ||
<properties> | ||
<property name="violationSuppressRegex" | ||
value=".*'.*Arguments\(\)'.*" /> | ||
</properties> | ||
</rule> | ||
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable"> | ||
<properties> | ||
<property name="violationSuppressXPath" value="//Resource" /> | ||
</properties> | ||
</rule> | ||
|
||
<rule ref="category/java/design.xml"> | ||
<exclude name="AvoidThrowingRawExceptionTypes" /> | ||
<exclude name="AvoidThrowingNewInstanceOfSameException" /> | ||
<exclude name="CognitiveComplexity" /> | ||
<exclude name="CouplingBetweenObjects" /> | ||
<exclude name="CyclomaticComplexity" /> | ||
<exclude name="DataClass" /> | ||
<exclude name="ExceptionAsFlowControl" /> | ||
<exclude name="ExcessiveImports" /> | ||
<exclude name="ExcessiveParameterList" /> | ||
<exclude name="ExcessivePublicCount" /> | ||
<exclude name="GodClass" /> | ||
<exclude name="LawOfDemeter" /> | ||
<exclude name="LoosePackageCoupling" /> | ||
<exclude name="NPathComplexity" /> | ||
<exclude name="NcssCount" /> | ||
<exclude name="TooManyFields" /> | ||
<exclude name="TooManyMethods" /> | ||
</rule> | ||
|
||
<rule ref="category/java/errorprone.xml"> | ||
<exclude name="AssignmentToNonFinalStatic" /> | ||
<exclude name="AvoidCatchingThrowable" /> | ||
<exclude name="AvoidDuplicateLiterals" /> | ||
<exclude name="AvoidLiteralsInIfCondition" /> | ||
<exclude name="CloseResource" /> | ||
<exclude name="ConstructorCallsOverridableMethod" /> | ||
<exclude name="DoNotTerminateVM" /> | ||
<exclude name="EmptyCatchBlock" /> | ||
<exclude name="FinalizeDoesNotCallSuperFinalize" /> | ||
<exclude name="JUnitSpelling" /> | ||
<exclude name="MissingSerialVersionUID" /> | ||
<exclude name="NonSerializableClass" /> | ||
<exclude name="NullAssignment" /> | ||
</rule> | ||
|
||
<rule ref="category/java/multithreading.xml"> | ||
<exclude name="AvoidSynchronizedAtMethodLevel" /> | ||
<exclude name="AvoidUsingVolatile" /> | ||
<exclude name="DoNotUseThreads" /> | ||
<exclude name="UseConcurrentHashMap" /> | ||
</rule> | ||
|
||
<rule ref="category/java/performance.xml"> | ||
<exclude name="AvoidInstantiatingObjectsInLoops" /> | ||
</rule> | ||
|
||
<rule name="UnnecessaryCastRule" language="java" | ||
message="Avoid unnecessary casts" | ||
class="net.sourceforge.pmd.lang.java.rule.codestyle.UnnecessaryCastRule" | ||
externalInfoUrl="https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryCastRule.java" /> | ||
|
||
<!-- Custom Rules --> | ||
<rule name="UseRequireNonNull" | ||
message="Use Objects.requireNonNull() instead of throwing a NullPointerException yourself." | ||
language="java" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"> | ||
<description>Use Objects.requireNonNull() instead of throwing a | ||
NullPointerException yourself.</description> | ||
<properties> | ||
<property name="xpath"> | ||
<value> | ||
<![CDATA[ | ||
//IfStatement[child::Expression//NullLiteral]/Statement//ThrowStatement/Expression/PrimaryExpression/PrimaryPrefix/AllocationExpression/ClassOrInterfaceType[@Image='NullPointerException'] | ||
]]> | ||
</value> | ||
</property> | ||
</properties> | ||
<priority>3</priority> | ||
<example> | ||
<![CDATA[ | ||
public class Example { | ||
public Example(Object example) { | ||
if (example == null) { | ||
throw new NullPointerException(); | ||
} | ||
} | ||
} | ||
]]> | ||
</example> | ||
</rule> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters