Discussion:
[pmd-devel] NullPointerException in CommentDefaultAccessModifier Java rule
Tim Webster
2016-05-30 14:39:35 UTC
Permalink
Hi,

Pretty minor issue, and not sure where the responsibility lies, but I'm
seeing this and just thought I'd raise it. This is is from the SonarQube
plugin - we're setting an empty default value on the 'regex' parameter for
this rule (via XML - so hence the null). It seems to be the only rule that
doesn't like this.

It's doing a trim() on the parameter value (which is is null). if you
think a change is required on my side please let me know - but this seems
to be the only rule that objects to empty default parameter values.


java.lang.NullPointerException
at
net.sourceforge.pmd.lang.java.rule.comments.CommentDefaultAccessModifierRule.visit(CommentDefaultAccessModifierRule.java:53)
at
net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visitAll(AbstractJavaRule.java:31)
at
net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.apply(AbstractJavaRule.java:25)
at
net.sourceforge.pmd.lang.rule.AbstractDelegateRule.apply(AbstractDelegateRule.java:215)
at net.sourceforge.pmd.RuleSet.apply(RuleSet.java:307)
at net.sourceforge.pmd.RuleSets.apply(RuleSets.java:125)
at
net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:146)
at
net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:76)
at
net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:43)

Cheers,

Tim
Matt_Jack59
2016-08-16 15:26:47 UTC
Permalink
Hi Tim,

You can provide the regex for your Quality Profile in SonarQube GUI.

Search the PMD Rule "pmd:CommentDefaultAccessModifier", and on your Quality
Profile, you have a "change" button that let you provide the regex.

By default, the regex should be "/* default */" but it look like to not work
as well as it should... So force the value.

Personally, i've migrated my Quality Profile from older version of PMD, i
think the parameter was not existing before and during the migration, it has
been set to null instead of the default value.

Best Regards.
Matthieu.



--
View this message in context: http://java-pmd.30631.n5.nabble.com/NullPointerException-in-CommentDefaultAccessModifier-Java-rule-tp5710768p5710819.html
Sent from the Java PMD - Dev mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Loading...