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

[core] Can not set ruleset property value to empty #4279

Closed
hgschmie opened this issue Jan 4, 2023 · 0 comments · Fixed by #4300
Closed

[core] Can not set ruleset property value to empty #4279

hgschmie opened this issue Jan 4, 2023 · 0 comments · Fixed by #4300
Assignees
Labels
a:bug PMD crashes or fails to analyse a file.
Milestone

Comments

@hgschmie
Copy link
Contributor

hgschmie commented Jan 4, 2023

Affects PMD Version:

6.53.0

Description:

Docs claim "Test class name pattern to identify test classes by their fully qualified name. An empty pattern disables test class detection by name. Since PMD 6.51.0."

However, adding this to my custom pmd config:

<rule ref="category/java/errorprone.xml/TestClassWithoutTestCases">
        <properties>
            <property name="testClassPattern" value="" />
        </properties>
    </rule>

leads to

Exception Stacktrace:

Caused by: java.lang.NullPointerException: Cannot invoke "String.isEmpty()" because "this.pattern" is null
    at java.util.regex.Pattern.<init> (Pattern.java:1428)
    at java.util.regex.Pattern.compile (Pattern.java:1069)
    at net.sourceforge.pmd.properties.ValueParserConstants$10.valueOf (ValueParserConstants.java:211)
    at net.sourceforge.pmd.properties.ValueParserConstants$10.valueOf (ValueParserConstants.java:208)
    at net.sourceforge.pmd.properties.GenericPropertyDescriptor.createFrom (GenericPropertyDescriptor.java:68)
    at net.sourceforge.pmd.properties.AbstractSingleValueProperty.valueFrom (AbstractSingleValueProperty.java:129)
    at net.sourceforge.pmd.rules.RuleFactory.setRulePropertyCapture (RuleFactory.java:307)
    at net.sourceforge.pmd.rules.RuleFactory.setPropertyValues (RuleFactory.java:302)
    at net.sourceforge.pmd.rules.RuleFactory.decorateRule (RuleFactory.java:126)
    at net.sourceforge.pmd.RuleSetFactory.parseRuleReferenceNode (RuleSetFactory.java:726)
    at net.sourceforge.pmd.RuleSetFactory.parseRuleNode (RuleSetFactory.java:505)
    at net.sourceforge.pmd.RuleSetFactory.parseRuleSetNode (RuleSetFactory.java:409)
    at net.sourceforge.pmd.RuleSetFactory.createRuleSet (RuleSetFactory.java:234)
    at net.sourceforge.pmd.RuleSetFactory.createRuleSet (RuleSetFactory.java:229)
    at net.sourceforge.pmd.RuleSetLoader.loadFromResource (RuleSetLoader.java:253)
    at net.sourceforge.pmd.RuleSetLoader.loadFromResource (RuleSetLoader.java:153)
    at net.sourceforge.pmd.RuleSetLoader.loadFromResources (RuleSetLoader.java:185)
    at org.apache.maven.plugins.pmd.exec.PmdExecutor.processFilesWithPMD (PmdExecutor.java:351)
    at org.apache.maven.plugins.pmd.exec.PmdExecutor.run (PmdExecutor.java:248)
    at org.apache.maven.plugins.pmd.exec.PmdExecutor.execute (PmdExecutor.java:83)
    at org.apache.maven.plugins.pmd.PmdReport.executePmd (PmdReport.java:390)
    at org.apache.maven.plugins.pmd.PmdReport.canGenerateReport (PmdReport.java:315)

Code Sample demonstrating the issue:

not needed.

Steps to reproduce:

Please provide detailed steps for how we can reproduce the bug.

  1. add example above to custom ruleset.
  2. run pmd with the ruleset
  3. profit

Running PMD through: [Maven]

@hgschmie hgschmie added the a:bug PMD crashes or fails to analyse a file. label Jan 4, 2023
@adangel adangel self-assigned this Jan 11, 2023
@adangel adangel added this to the 6.54.0 milestone Jan 11, 2023
@jsotuyod jsotuyod changed the title [java] TestClassWithoutTestCases - can not set test pattern to empty [core] Can not set ruleset property value to empty Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug PMD crashes or fails to analyse a file.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants