Open Tenebrosful opened 1 year ago
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.
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
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
I have a similar error. Would be nice to receive a proper error message or warning in such cases.
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>
About the exclude pattern, there are detected like not allowed
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
My
.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