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

Cannot load ruleset for JUnit-rules #498

Closed
meisenla opened this issue Feb 27, 2025 · 1 comment · Fixed by #502
Closed

Cannot load ruleset for JUnit-rules #498

meisenla opened this issue Feb 27, 2025 · 1 comment · Fixed by #502

Comments

@meisenla
Copy link

The following JUnit- rules fail on sonar-pmd 4.0.0:

Caused by: net.sourceforge.pmd.lang.rule.RuleSetLoadException: Cannot load ruleset rulesets/java/migrating.xml/JUnit4TestShouldUseBeforeAnnotation: Cannot resolve rule/ruleset reference 'rulesets/java/migrating.xml/JUnit4TestShouldUseBeforeAnnotation'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath.

Caused by: java.lang.IllegalStateException: net.sourceforge.pmd.lang.rule.RuleSetLoadException: Cannot load ruleset rulesets/java/migrating.xml/JUnit4TestShouldUseAfterAnnotation: Cannot resolve rule/ruleset reference 'rulesets/java/migrating.xml/JUnit4TestShouldUseAfterAnnotation'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath.

Caused by: java.lang.IllegalStateException: net.sourceforge.pmd.lang.rule.RuleSetLoadException: Cannot load ruleset rulesets/java/migrating.xml/JUnit4TestShouldUseTestAnnotation: Cannot resolve rule/ruleset reference 'rulesets/java/migrating.xml/JUnit4TestShouldUseTestAnnotation'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath.

Caused by: net.sourceforge.pmd.lang.rule.RuleSetLoadException: Cannot load ruleset rulesets/java/junit.xml/UnnecessaryBooleanAssertion: Cannot resolve rule/ruleset reference 'rulesets/java/junit.xml/UnnecessaryBooleanAssertion'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath.

Caused by: java.lang.IllegalStateException: net.sourceforge.pmd.lang.rule.RuleSetLoadException: Cannot load ruleset rulesets/java/migrating.xml/JUnit4SuitesShouldUseSuiteAnnotation: Cannot resolve rule/ruleset reference 'rulesets/java/migrating.xml/JUnit4SuitesShouldUseSuiteAnnotation'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath.

Caused by: net.sourceforge.pmd.lang.rule.RuleSetLoadException: Cannot load ruleset rulesets/java/migrating.xml/JUnitUseExpected: Cannot resolve rule/ruleset reference 'rulesets/java/migrating.xml/JUnitUseExpected'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath.

@stokpop
Copy link
Collaborator

stokpop commented Feb 28, 2025

@meisenla thanks for reporting, the junit rules have all been moved in pmd7 or removed from pmd7. We will remove these references for now and recheck the rule mappings in a future release.

For example: JUnitAssertionsShouldIncludeMessage has been moved to bestpractices with new name UnitTestAssertionsShouldIncludeMessageRule.

Plus that rule is also available in Sonar java already as: https://rules.sonarsource.com/java/RSPEC-2698/ so we can exclude it from sonar-pmd.

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

Successfully merging a pull request may close this issue.

2 participants