Giter Club home page Giter Club logo

Comments (1)

Gold856 avatar Gold856 commented on July 18, 2024

I fixed the XML validation errors and updated the exclusions:

diff --git a/shared/java/javastyle.gradle b/shared/java/javastyle.gradle
index 41ddb47e6..5c9a140ee 100644
--- a/shared/java/javastyle.gradle
+++ b/shared/java/javastyle.gradle
@@ -13,7 +13,7 @@ checkstyle {
 apply plugin: 'pmd'
 
 pmd {
-    toolVersion = '6.55.0'
+    toolVersion = '7.1.0'
     consoleOutput = true
     reportsDir = file("$project.buildDir/reports/pmd")
     ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml"))
diff --git a/styleguide/pmd-ruleset.xml b/styleguide/pmd-ruleset.xml
index 1f6577e6f..b965fc981 100644
--- a/styleguide/pmd-ruleset.xml
+++ b/styleguide/pmd-ruleset.xml
@@ -31,6 +31,7 @@
     <exclude name="SwitchStmtsShouldHaveDefault" />
     <exclude name="SystemPrintln" />
     <exclude name="UseVarargs" />
+    <exclude name="UnusedAssignment" />
   </rule>
   <rule ref="category/java/bestpractices.xml/UnusedPrivateMethod">
     <properties>
@@ -42,20 +43,18 @@
   <rule ref="category/java/design.xml">
     <exclude name="AvoidThrowingRawExceptionTypes" />
     <exclude name="CognitiveComplexity" />
+    <exclude name="CouplingBetweenObjects" />
     <exclude name="CyclomaticComplexity" />
     <exclude name="DataClass" />
-    <exclude name="ExcessiveClassLength" />
     <exclude name="ExcessiveImports" />
-    <exclude name="ExcessiveMethodLength" />
     <exclude name="ExcessiveParameterList" />
     <exclude name="ExcessivePublicCount" />
     <exclude name="GodClass" />
+    <exclude name="ImmutableField" />
     <exclude name="LawOfDemeter" />
     <exclude name="LoosePackageCoupling" />
     <exclude name="NPathComplexity" />
-    <exclude name="NcssConstructorCount" />
     <exclude name="NcssCount" />
-    <exclude name="NcssMethodCount" />
     <exclude name="TooManyFields" />
     <exclude name="TooManyMethods" />
   </rule>
@@ -67,10 +66,8 @@
     <exclude name="AvoidLiteralsInIfCondition" />
     <exclude name="CloseResource" />
     <exclude name="ConstructorCallsOverridableMethod" />
-    <exclude name="DataflowAnomalyAnalysis" />
     <exclude name="DoNotTerminateVM" />
     <exclude name="EmptyCatchBlock" />
-    <exclude name="EmptyWhileStmt" />
     <exclude name="FinalizeDoesNotCallSuperFinalize" />
     <exclude name="JUnitSpelling" />
     <exclude name="MissingSerialVersionUID" />
@@ -86,7 +83,6 @@
   </rule>
 
   <rule ref="category/java/performance.xml">
-    <exclude name="AvoidUsingShortType" />
     <exclude name="AvoidInstantiatingObjectsInLoops" />
   </rule>
 
@@ -98,7 +94,7 @@
   <!-- Custom Rules -->
   <rule name="UseRequireNonNull"
     message="Use Objects.requireNonNull() instead of throwing a NullPointerException yourself."
-    language="java" class="net.sourceforge.pmd.lang.rule.XPathRule">
+    language="java" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
     <description>Use Objects.requireNonNull() instead of throwing a
       NullPointerException yourself.</description>
     <properties>

Excluding the other linting warnings which haven't been fixed, the main problem now is that PMD throws a bunch of exceptions with "bad intersection" when trying to process MutableMeasure.java:

org.apache.commons.lang3.exception.ContextedRuntimeException: java.lang.IllegalArgumentException: Bad intersection, unrelated class types edu.wpi.first.units.Dimensionless and edu.wpi.first.units.Unit in [edu.wpi.first.units.Unit, edu.wpi.first.units.Dimensionless]
Exception Context:
	[1:Resolving type of=!debug only! [VariableAccess:251:22]multiplier]
	[2:Rule applied on node=!debug only! [MethodCall:251:22]multiplier.baseUnitMagnitude()]
---------------------------------
	at net.sourceforge.pmd.util.AssertionUtil.contexted(AssertionUtil.java:236)
	at net.sourceforge.pmd.lang.java.ast.AbstractJavaTypeNode.getTypeMirror(AbstractJavaTypeNode.java:54)
	at net.sourceforge.pmd.lang.java.ast.ASTVariableAccess.getTypeMirror(ASTVariableAccess.java:27)
	at net.sourceforge.pmd.lang.java.ast.AbstractJavaTypeNode.getTypeMirror(AbstractJavaTypeNode.java:39)
	at net.sourceforge.pmd.lang.java.ast.ASTVariableAccess.getTypeMirror(ASTVariableAccess.java:27)
	at net.sourceforge.pmd.lang.java.types.TypeTestUtil.isA(TypeTestUtil.java:65)
	at net.sourceforge.pmd.lang.java.rule.bestpractices.UseCollectionIsEmptyRule.visit(UseCollectionIsEmptyRule.java:29)
	at net.sourceforge.pmd.lang.java.ast.ASTMethodCall.acceptVisitor(ASTMethodCall.java:75)
	at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.acceptVisitor(AbstractJavaNode.java:38)
	at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.apply(AbstractJavaRule.java:30)
	at net.sourceforge.pmd.lang.rule.RuleReference.apply(RuleReference.java:415)
	at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex(RuleApplicator.java:77)
	at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply(RuleApplicator.java:57)
	at net.sourceforge.pmd.lang.rule.internal.RuleSets.apply(RuleSets.java:155)
	at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource(PmdRunnable.java:140)
	at net.sourceforge.pmd.lang.impl.PmdRunnable.run(PmdRunnable.java:80)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.IllegalArgumentException: Bad intersection, unrelated class types edu.wpi.first.units.Dimensionless and edu.wpi.first.units.Unit in [edu.wpi.first.units.Unit, edu.wpi.first.units.Dimensionless]
	at net.sourceforge.pmd.lang.java.types.Lub.glb(Lub.java:344)
	at net.sourceforge.pmd.lang.java.types.TypeSystem.glb(TypeSystem.java:723)
	at net.sourceforge.pmd.lang.java.types.TypeConversion.capture(TypeConversion.java:227)
	at net.sourceforge.pmd.lang.java.types.TypeConversion.capture(TypeConversion.java:154)
	at net.sourceforge.pmd.lang.java.types.ast.internal.LazyTypeResolver.visit(LazyTypeResolver.java:541)
	at net.sourceforge.pmd.lang.java.types.ast.internal.LazyTypeResolver.visit(LazyTypeResolver.java:95)
	at net.sourceforge.pmd.lang.java.ast.ASTVariableAccess.acceptVisitor(ASTVariableAccess.java:76)
	at net.sourceforge.pmd.lang.java.ast.AbstractJavaTypeNode.getTypeMirror(AbstractJavaTypeNode.java:51)
	... 19 more

Not sure how to fix this.

from allwpilib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.