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

Plugin not load ruleset and verify all rules at eclipse startup #180

Open
Tenebrosful opened this issue May 30, 2023 · 6 comments
Open

Plugin not load ruleset and verify all rules at eclipse startup #180

Tenebrosful opened this issue May 30, 2023 · 6 comments

Comments

@Tenebrosful
Copy link

Hi,

I don't know why but sometimes the PMD don't want to read the ruleset file and try to verify all rules.

The only way that i found to fix that is switching git branch to a branch with different .pmd and .ruleset.xml then come back to branch and it correcly read it again.

My ruleset.xml

<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	name="pmd-eclipse"
	xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
	
	<description>PMD Plugin preferences rule set</description>
	
	<!-- Included files -->
	<include-pattern>./WEB-INF/src/*</include-pattern>
	<include-pattern>./WebContent/*</include-pattern>
	
	<exclude-pattern>*.min.js</exclude-pattern>
	<exclude-pattern>./node_modules/*</exclude-pattern>
	<exclude-pattern>./WebContent/Plugin/*</exclude-pattern>
	
	<!--  HTML rules  -->
	<rule ref="category/html/bestpractices.xml/AvoidInlineStyles"/>
	<rule ref="category/html/bestpractices.xml/UnnecessaryTypeAttribute"/>
	<rule ref="category/html/bestpractices.xml/UseAltAttributeForImages"/>
	<!--  Java Best Practices rules  -->
	<rule ref="category/java/bestpractices.xml/AbstractClassWithoutAbstractMethod"/>
	<rule ref="category/java/bestpractices.xml/ArrayIsStoredDirectly"/>
	<rule ref="category/java/bestpractices.xml/AvoidMessageDigestField"/>
	<rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace"/>
	<rule ref="category/java/bestpractices.xml/AvoidReassigningCatchVariables"/>
	<rule ref="category/java/bestpractices.xml/AvoidReassigningLoopVariables"/>
	<rule ref="category/java/bestpractices.xml/AvoidReassigningParameters"/>
	<rule ref="category/java/bestpractices.xml/AvoidStringBufferField"/>
	<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>
	<rule ref="category/java/bestpractices.xml/CheckResultSet"/>
	<rule ref="category/java/bestpractices.xml/ConstantsInInterface"/>
	<rule ref="category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt"/>
	<rule ref="category/java/bestpractices.xml/DoubleBraceInitialization"/>
	<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach"/>
	<rule ref="category/java/bestpractices.xml/JUnit4SuitesShouldUseSuiteAnnotation"/>
	<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseAfterAnnotation"/>
	<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseBeforeAnnotation"/>
	<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseTestAnnotation"/>
	<rule ref="category/java/bestpractices.xml/JUnit5TestShouldBePackagePrivate"/>
	<rule ref="category/java/bestpractices.xml/JUnitAssertionsShouldIncludeMessage"/>
	<rule ref="category/java/bestpractices.xml/JUnitTestsShouldIncludeAssert"/>
	<rule ref="category/java/bestpractices.xml/JUnitUseExpected"/>
	<rule ref="category/java/bestpractices.xml/LiteralsFirstInComparisons"/>
	<rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray"/>
	<rule ref="category/java/bestpractices.xml/MissingOverride"/>
	<rule ref="category/java/bestpractices.xml/OneDeclarationPerLine">
		<properties>
			<property name="strictMode" value="true"/>
		</properties>
	</rule>
	<rule ref="category/java/bestpractices.xml/PreserveStackTrace"/>
	<rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation"/>
	<rule ref="category/java/bestpractices.xml/ReplaceEnumerationWithIterator"/>
	<rule ref="category/java/bestpractices.xml/ReplaceHashtableWithMap"/>
	<rule ref="category/java/bestpractices.xml/ReplaceVectorWithList" />
	<rule ref="category/java/bestpractices.xml/SimplifiableTestAssertion"/>
	<rule ref="category/java/bestpractices.xml/SwitchStmtsShouldHaveDefault"/>
	<!-- <rule ref="category/java/bestpractices.xml/SystemPrintln"/> -->
	<rule ref="category/java/bestpractices.xml/UnusedAssignment"/>
	<rule ref="category/java/bestpractices.xml/UnusedFormalParameter"/>
	<rule ref="category/java/bestpractices.xml/UnusedLocalVariable"/>
	<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
	<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod"/>
	<rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty"/>
	<rule ref="category/java/bestpractices.xml/UseStandardCharsets"/>
	<rule ref="category/java/bestpractices.xml/UseTryWithResources"/>
	<rule ref="category/java/bestpractices.xml/UseVarargs"/>
	<rule ref="category/java/bestpractices.xml/WhileLoopWithLiteralBoolean"/>
	<!--  Java Code Style  -->
	<rule ref="category/java/codestyle.xml/AvoidDollarSigns"/>
	<rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass"/>
	<rule ref="category/java/codestyle.xml/AvoidProtectedMethodInFinalClassNotExtending"/>
	<rule ref="category/java/codestyle.xml/BooleanGetMethodName"/>
	<rule ref="category/java/codestyle.xml/CallSuperInConstructor"/>
	<rule ref="category/java/codestyle.xml/ClassNamingConventions"/>
	<rule ref="category/java/codestyle.xml/ConfusingTernary"/>
	<rule ref="category/java/codestyle.xml/ControlStatementBraces"/>
	<rule ref="category/java/codestyle.xml/EmptyControlStatement"/>
	<rule ref="category/java/codestyle.xml/EmptyMethodInAbstractClassShouldBeAbstract"/>
	<rule ref="category/java/codestyle.xml/ExtendsObject"/>
	<rule ref="category/java/codestyle.xml/FieldDeclarationsShouldBeAtStartOfClass"/>
	<rule ref="category/java/codestyle.xml/FieldNamingConventions">
		<properties>
			<property name="finalPattern" value="[A-Z][A-Z0-9_]*" />
		</properties>
	</rule>
	<rule ref="category/java/codestyle.xml/FinalParameterInAbstractMethod"/>
	<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/>
	<rule ref="category/java/codestyle.xml/FormalParameterNamingConventions"/>
	<rule ref="category/java/codestyle.xml/GenericsNaming"/>
	<rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/>
	<rule ref="category/java/codestyle.xml/LinguisticNaming"/>
	<rule ref="category/java/codestyle.xml/LocalVariableNamingConventions"/>
	<rule ref="category/java/codestyle.xml/MethodNamingConventions"/>
	<rule ref="category/java/codestyle.xml/NoPackage"/>
	<rule ref="category/java/codestyle.xml/PackageCase"/>
	<rule ref="category/java/codestyle.xml/PrematureDeclaration"/>
	<rule ref="category/java/codestyle.xml/ShortClassName">
		<properties>
			<property name="minimum" value="3"/>
		</properties>
	</rule>
	<rule ref="category/java/codestyle.xml/ShortMethodName"/>
	<rule ref="category/java/codestyle.xml/ShortVariable"/>
	<rule ref="category/java/codestyle.xml/UnnecessaryAnnotationValueElement"/>
	<rule ref="category/java/codestyle.xml/UnnecessaryBoxing"/>
	<rule ref="category/java/codestyle.xml/UnnecessaryCast"/>
	<rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/>
	<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName"/>
	<rule ref="category/java/codestyle.xml/UnnecessaryImport"/>
	<rule ref="category/java/codestyle.xml/UnnecessaryLocalBeforeReturn"/>
	<rule ref="category/java/codestyle.xml/UnnecessaryModifier"/>
	<rule ref="category/java/codestyle.xml/UnnecessaryReturn" />
	<rule ref="category/java/codestyle.xml/UnnecessarySemicolon"/>
	<rule ref="category/java/codestyle.xml/UseDiamondOperator"/>
	<rule ref="category/java/codestyle.xml/UselessParentheses"/>
	<rule ref="category/java/codestyle.xml/UselessQualifiedThis"/>
	<rule ref="category/java/codestyle.xml/UseShortArrayInitializer"/>
	<!--  Java Design  -->
	<rule ref="category/java/design.xml/AbstractClassWithoutAnyMethod" />
	<rule ref="category/java/design.xml/AvoidDeeplyNestedIfStmts"/>
	<rule ref="category/java/design.xml/AvoidRethrowingException"/>
	<rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException"/>
	<rule ref="category/java/design.xml/AvoidThrowingNullPointerException"/>
	<rule ref="category/java/design.xml/AvoidThrowingRawExceptionTypes"/>
	<rule ref="category/java/design.xml/AvoidUncheckedExceptionsInSignatures"/>
	<!-- <rule ref="category/java/design.xml/CognitiveComplexity"/> -->
	<rule ref="category/java/design.xml/CollapsibleIfStatements"/>
	<!-- <rule ref="category/java/design.xml/CyclomaticComplexity"/> -->
	<rule ref="category/java/design.xml/DoNotExtendJavaLangError"/>
	<rule ref="category/java/design.xml/ExceptionAsFlowControl"/>
	<rule ref="category/java/design.xml/ExcessiveParameterList"/>
	<rule ref="category/java/design.xml/FinalFieldCouldBeStatic"/>
	<rule ref="category/java/design.xml/ImmutableField"/>
	<rule ref="category/java/design.xml/LogicInversion"/>
	<rule ref="category/java/design.xml/MutableStaticState"/>
	<rule ref="category/java/design.xml/SignatureDeclareThrowsException"/>
	<rule ref="category/java/design.xml/SimplifiedTernary"/>
	<rule ref="category/java/design.xml/SimplifyBooleanExpressions"/>
	<rule ref="category/java/design.xml/SimplifyBooleanReturns"/>
	<rule ref="category/java/design.xml/SimplifyConditional"/>
	<rule ref="category/java/design.xml/SingularField"/>
	<rule ref="category/java/design.xml/SwitchDensity"/>
	<rule ref="category/java/design.xml/UselessOverridingMethod"/>
	<rule ref="category/java/design.xml/UseUtilityClass"/>
	<!--  Java Documentation  -->
	<rule ref="category/java/documentation.xml/CommentRequired"/>
	<rule ref="category/java/documentation.xml/UncommentedEmptyConstructor"/>
	<rule ref="category/java/documentation.xml/UncommentedEmptyMethodBody"/>
	<!--  Java Error Prone  -->
	<rule ref="category/java/errorprone.xml/AssignmentInOperand"/>
	<rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic"/>
	<rule ref="category/java/errorprone.xml/AvoidAssertAsIdentifier"/>
	<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop"/>
	<rule ref="category/java/errorprone.xml/AvoidCatchingNPE"/>
	<rule ref="category/java/errorprone.xml/AvoidCatchingThrowable"/>
	<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor"/>
	<!-- <rule ref="category/java/errorprone.xml/AvoidDuplicateLiterals">
		<properties>
			<property name="exceptionList" value="&lt;div&gt;,&lt;/div&gt;"/>
		</properties>
	</rule> -->
	<rule ref="category/java/errorprone.xml/AvoidEnumAsIdentifier"/>
	<rule ref="category/java/errorprone.xml/AvoidFieldNameMatchingMethodName"/>
	<rule ref="category/java/errorprone.xml/AvoidInstanceofChecksInCatchClause"/>
	<rule ref="category/java/errorprone.xml/AvoidLiteralsInIfCondition">
		<properties>
			<property name="ignoreMagicNumbers" value="-1,0,1"/>
		</properties>
	</rule>
	<rule ref="category/java/errorprone.xml/AvoidLosingExceptionInformation"/>
	<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators"/>
	<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/>
	<rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
	<rule ref="category/java/errorprone.xml/CheckSkipResult"/>
	<rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray" />
	<rule ref="category/java/errorprone.xml/CloneMethodMustBePublic"/>
	<rule ref="category/java/errorprone.xml/CloneMethodMustImplementCloneable"/>
	<rule ref="category/java/errorprone.xml/CloneMethodReturnTypeMustMatchClassName"/>
	<rule ref="category/java/errorprone.xml/CloseResource"/>
	<rule ref="category/java/errorprone.xml/CompareObjectsWithEquals"/>
	<rule ref="category/java/errorprone.xml/ComparisonWithNaN"/>
	<rule ref="category/java/errorprone.xml/ConstructorCallsOverridableMethod"/>
	<rule ref="category/java/errorprone.xml/DetachedTestCase"/>
	<rule ref="category/java/errorprone.xml/DoNotCallGarbageCollectionExplicitly"/>
	<rule ref="category/java/errorprone.xml/DoNotExtendJavaLangThrowable"/>
	<rule ref="category/java/errorprone.xml/DoNotHardCodeSDCard"/>
	<rule ref="category/java/errorprone.xml/DoNotTerminateVM"/>
	<rule ref="category/java/errorprone.xml/DoNotThrowExceptionInFinally"/>
	<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices"/>
	<rule ref="category/java/errorprone.xml/EmptyCatchBlock"/>
	<rule ref="category/java/errorprone.xml/EqualsNull"/>
	<rule ref="category/java/errorprone.xml/IdempotentOperations"/>
	<rule ref="category/java/errorprone.xml/ImplicitSwitchFallThrough"/>
	<rule ref="category/java/errorprone.xml/InstantiationToGetClass"/>
	<rule ref="category/java/errorprone.xml/InvalidLogMessageFormat"/>
	<rule ref="category/java/errorprone.xml/JumbledIncrementer"/>
	<rule ref="category/java/errorprone.xml/JUnitSpelling"/>
	<rule ref="category/java/errorprone.xml/JUnitStaticSuite"/>
	<rule ref="category/java/errorprone.xml/MethodWithSameNameAsEnclosingClass"/>
	<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
	<rule ref="category/java/errorprone.xml/MissingStaticMethodInNonInstantiatableClass"/>
	<rule ref="category/java/errorprone.xml/MoreThanOneLogger"/>
	<rule ref="category/java/errorprone.xml/NonCaseLabelInSwitchStatement"/>
	<rule ref="category/java/errorprone.xml/NonSerializableClass"/>
	<rule ref="category/java/errorprone.xml/NonStaticInitializer"/>
	<rule ref="category/java/errorprone.xml/NullAssignment"/>
	<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/>
	<rule ref="category/java/errorprone.xml/ProperCloneImplementation"/>
	<rule ref="category/java/errorprone.xml/ProperLogger"/>
	<rule ref="category/java/errorprone.xml/ReturnEmptyCollectionRatherThanNull"/>
	<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock"/>
	<rule ref="category/java/errorprone.xml/SimpleDateFormatNeedsLocale"/>
	<rule ref="category/java/errorprone.xml/SingleMethodSingleton"/>
	<rule ref="category/java/errorprone.xml/SingletonClassReturningNewInstance"/>
	<rule ref="category/java/errorprone.xml/StringBufferInstantiationWithChar"/>
	<rule ref="category/java/errorprone.xml/SuspiciousEqualsMethodName"/>
	<rule ref="category/java/errorprone.xml/SuspiciousHashcodeMethodName"/>
	<rule ref="category/java/errorprone.xml/SuspiciousOctalEscape"/>
	<rule ref="category/java/errorprone.xml/TestClassWithoutTestCases"/>
	<rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/>
	<rule ref="category/java/errorprone.xml/UnnecessaryBooleanAssertion"/>
	<rule ref="category/java/errorprone.xml/UnnecessaryCaseChange"/>
	<rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary"/>
	<rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals"/>
	<rule ref="category/java/errorprone.xml/UseCorrectExceptionLogging"/>
	<rule ref="category/java/errorprone.xml/UseEqualsToCompareStrings"/>
	<rule ref="category/java/errorprone.xml/UselessOperationOnImmutable"/>
	<rule ref="category/java/errorprone.xml/UseLocaleWithCaseConversions"/>
	<rule ref="category/java/errorprone.xml/UseProperClassLoader"/>
	<!--  Java Multithreading  -->
	<rule ref="category/java/multithreading.xml/AvoidSynchronizedAtMethodLevel"/>
	<rule ref="category/java/multithreading.xml/AvoidThreadGroup"/>
	<rule ref="category/java/multithreading.xml/AvoidUsingVolatile"/>
	<rule ref="category/java/multithreading.xml/DoNotUseThreads"/>
	<rule ref="category/java/multithreading.xml/DontCallThreadRun"/>
	<rule ref="category/java/multithreading.xml/DoubleCheckedLocking"/>
	<rule ref="category/java/multithreading.xml/NonThreadSafeSingleton"/>
	<rule ref="category/java/multithreading.xml/UnsynchronizedStaticFormatter"/>
	<rule ref="category/java/multithreading.xml/UseConcurrentHashMap"/>
	<rule ref="category/java/multithreading.xml/UseNotifyAllInsteadOfNotify"/>
	<!--  Java Performance  -->
	<rule ref="category/java/performance.xml/AddEmptyString"/>
	<rule ref="category/java/performance.xml/AppendCharacterWithChar"/>
	<rule ref="category/java/performance.xml/AvoidArrayLoops"/>
	<rule ref="category/java/performance.xml/AvoidCalendarDateCreation"/>
	<rule ref="category/java/performance.xml/AvoidFileStream"/>
	<rule ref="category/java/performance.xml/AvoidInstantiatingObjectsInLoops"/>
	<rule ref="category/java/performance.xml/BigIntegerInstantiation"/>
	<rule ref="category/java/performance.xml/ConsecutiveAppendsShouldReuse"/>
	<rule ref="category/java/performance.xml/ConsecutiveLiteralAppends"/>
	<rule ref="category/java/performance.xml/InefficientEmptyStringCheck"/>
	<rule ref="category/java/performance.xml/InefficientStringBuffering"/>
	<rule ref="category/java/performance.xml/InsufficientStringBufferDeclaration"/>
	<rule ref="category/java/performance.xml/OptimizableToArrayCall"/>
	<rule ref="category/java/performance.xml/RedundantFieldInitializer"/>
	<rule ref="category/java/performance.xml/StringInstantiation"/>
	<rule ref="category/java/performance.xml/StringToString"/>
	<rule ref="category/java/performance.xml/TooFewBranchesForASwitchStatement"/>
	<rule ref="category/java/performance.xml/UseArrayListInsteadOfVector"/>
	<rule ref="category/java/performance.xml/UseArraysAsList"/>
	<rule ref="category/java/performance.xml/UseIndexOfChar"/>
	<rule ref="category/java/performance.xml/UseIOStreamsWithApacheCommonsFileItem"/>
	<rule ref="category/java/performance.xml/UselessStringValueOf"/>
	<rule ref="category/java/performance.xml/UseStringBufferForStringAppends"/>
	<rule ref="category/java/performance.xml/UseStringBufferLength"/>
	<!--  Java Security  -->
	<rule ref="category/java/security.xml/HardCodedCryptoKey"/>
	<rule ref="category/java/security.xml/InsecureCryptoIv"/>
	<!-- JavaScript Best Practice -->
	<rule ref="category/ecmascript/bestpractices.xml/AvoidWithStatement" />
	<rule ref="category/ecmascript/bestpractices.xml/ConsistentReturn" />
	<rule ref="category/ecmascript/bestpractices.xml/GlobalVariable" />
	<rule ref="category/ecmascript/bestpractices.xml/ScopeForInVariable" />
	<rule ref="category/ecmascript/bestpractices.xml/UseBaseWithParseInt" />
	<!-- JavaScript Style -->
	<rule ref="category/ecmascript/codestyle.xml/AssignmentInOperand" />
	<rule ref="category/ecmascript/codestyle.xml/ForLoopsMustUseBraces" />
	<rule ref="category/ecmascript/codestyle.xml/IfElseStmtsMustUseBraces" />
	<rule ref="category/ecmascript/codestyle.xml/IfStmtsMustUseBraces" />
	<rule ref="category/ecmascript/codestyle.xml/NoElseReturn" />
	<rule ref="category/ecmascript/codestyle.xml/UnnecessaryBlock" />
	<rule ref="category/ecmascript/codestyle.xml/UnnecessaryParentheses" />
	<rule ref="category/ecmascript/codestyle.xml/UnreachableCode" />
	<rule ref="category/ecmascript/codestyle.xml/WhileLoopsMustUseBraces" />
	<!--  JavaScript Error Prone -->
	<rule ref="category/ecmascript/errorprone.xml/AvoidTrailingComma" />
</ruleset>

My .pmd

<?xml version="1.0" encoding="UTF-8"?>
<pmd>
    <workingSet>Aggregate:Java Main Sources:Java Test</workingSet>
    <useProjectRuleSet>true</useProjectRuleSet>
    <ruleSetFile>.ruleset.xml</ruleSetFile>
    <includeDerivedFiles>false</includeDerivedFiles>
    <violationsAsErrors>false</violationsAsErrors>
    <fullBuildEnabled>true</fullBuildEnabled>
</pmd>

Eclipse version: Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components) 4.27.0
PMD Version: 7.0.0.v20230502-1028-rc2

@adangel
Copy link
Member

adangel commented May 30, 2023

Thanks for the report. Would you mind to share your workspace log file (eclipse error log) the next time this happens?. The plugin has also a logging setting, you could also configure this in the preferences and share the log file of the plugin only.

@Tenebrosful
Copy link
Author

Hummm, according to logs it looks like the problem is from the .ruleset.xml

2023/05/31 08:47:22.185 [Worker-22: ReviewCode] ERROR n.s.pmd.eclipse.plugin.PMDPlugin - Project RuleSet cannot be loaded for project x using RuleSet file name .ruleset.xml. Using the rules from properties.
net.sourceforge.pmd.RuleSetLoadException: Cannot load ruleset C:\x\x\x\x\.ruleset.xml: 2 XML validation errors occurred
	at net.sourceforge.pmd.RuleSetFactory.readDocument(RuleSetFactory.java:198)
	at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:121)
	at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:116)
	at net.sourceforge.pmd.RuleSetLoader.loadFromResource(RuleSetLoader.java:266)
	at net.sourceforge.pmd.RuleSetLoader.loadFromResource(RuleSetLoader.java:169)
	at net.sourceforge.pmd.eclipse.runtime.properties.impl.ProjectPropertiesManagerImpl.loadRuleSetFromProject(ProjectPropertiesManagerImpl.java:159)
	at net.sourceforge.pmd.eclipse.runtime.properties.impl.ProjectPropertiesManagerImpl.loadProjectProperties(ProjectPropertiesManagerImpl.java:109)
	at net.sourceforge.pmd.eclipse.plugin.PMDPlugin.loadProjectProperties(PMDPlugin.java:516)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.getProjectProperties(ReviewCodeCmd.java:504)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.rulesetsFrom(ReviewCodeCmd.java:511)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.determineFileExtensions(ReviewCodeCmd.java:304)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.determineTotalWork(ReviewCodeCmd.java:274)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.execute(ReviewCodeCmd.java:180)
	at net.sourceforge.pmd.eclipse.runtime.cmd.JobCommandProcessor$1.run(JobCommandProcessor.java:60)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

After some tests, removing exclude-pattern remove 1 error, (what is strange because there are in the official documentation, i will looks for the others

@Tenebrosful
Copy link
Author

Ok found it.

<rule ref="category/java/codestyle.xml/FieldNamingConventions">
  <properties>
	  <property name="finalPattern" value="[A-Z][A-Z0-9_]*" />
  </properties>
</rule>

was the probleme because property finalPattern is misspelled and so thats make all the file crashing. But i still have no idea about the <exclude-pattern>, if you can help me about that

@chovyy
Copy link

chovyy commented Jun 21, 2023

I have a similar error. Would be nice to receive a proper error message or warning in such cases.

@adangel
Copy link
Member

adangel commented Jun 24, 2023

was the probleme because property finalPattern is misspelled and so thats make all the file crashing

Yes, the property name is "finalFieldPattern" (https://docs.pmd-code.org/latest/pmd_rules_java_codestyle.html#fieldnamingconventions)

The exclude pattern in the ruleset xml file is supposed to be a valid java regular expression. I don't think, we are explicit about the syntax of these patterns in the doc (https://docs.pmd-code.org/latest/pmd_userdocs_making_rulesets.html#filtering-the-processed-files). I know, that the eclipse plugin internally used to use ant-like pattern - so converting between the two might also contain some bugs.

Looking at your pattern, I think, the following produces a syntax error:

<exclude-pattern>*.min.js</exclude-pattern>

It should be

<exclude-pattern>.*\.min\.js</exclude-pattern>

warning: I'm not sure about the escapes for ".". Remember, that a dot "." matches any character and not only a dot.

Your include pattern also don't look correct, so you probably don't pick up all files you want:

<include-pattern>./WEB-INF/src/*</include-pattern>

instead use

<include-pattern>/WEB-INF/src/.*</include-pattern>

@Tenebrosful
Copy link
Author

About the exclude pattern, there are detected like not allowed
image

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

No branches or pull requests

3 participants