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

[doc] Multivalued properties do not accept | as a separator #4704

Closed
ben-manes opened this issue Oct 3, 2023 · 5 comments · Fixed by #4833
Closed

[doc] Multivalued properties do not accept | as a separator #4704

ben-manes opened this issue Oct 3, 2023 · 5 comments · Fixed by #4833
Labels
a:bug PMD crashes or fails to analyse a file. in:documentation Affects the documentation
Milestone

Comments

@ben-manes
Copy link

ben-manes commented Oct 3, 2023

Affects PMD Version:
7.0.0-rc4

Description:
After upgrading from 7.0.0-rc3, the analysis logs exceptions. This appears to only be noise as it does not fail the run.

Exception Stacktrace:

Exception applying rule LooseCoupling on file /home/runner/work/caffeine/caffeine/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/Feature.java, continuing with next rule
org.apache.commons.lang3.exception.ContextedRuntimeException: java.lang.IllegalArgumentException: Not a Java binary name 'java.util.Properties         |java.util.concurrent.ConcurrentHashMap         |com.google.common.collect.ImmutableMap         |com.google.common.collect.ImmutableSet         |com.google.common.collect.ImmutableList         |com.github.benmanes.caffeine.cache.BoundedLocalCache         |com.github.benmanes.caffeine.cache.UnboundedLocalCache'
Exception Context:
	[1:Rule applied on node=!debug only! [ClassOrInterfaceType:52:24]ImmutableSet<Feature>]
---------------------------------
	at net.sourceforge.pmd.util.AssertionUtil.contexted(AssertionUtil.java:232)
	at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex(RuleApplicator.java:77)
	at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply(RuleApplicator.java:55)
	at net.sourceforge.pmd.RuleSets.apply(RuleSets.java:158)
	at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource(PmdRunnable.java:140)
	at net.sourceforge.pmd.lang.impl.PmdRunnable.run(PmdRunnable.java:80)
	at java.base@20.0.2/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
	at java.base@20.0.2/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base@20.0.2/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base@20.0.2/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base@20.0.2/java.lang.Thread.run(Thread.java:1623)
Caused by: java.lang.IllegalArgumentException: Not a Java binary name 'java.util.Properties         |java.util.concurrent.ConcurrentHashMap         |com.google.common.collect.ImmutableMap         |com.google.common.collect.ImmutableSet         |com.google.common.collect.ImmutableList         |com.github.benmanes.caffeine.cache.BoundedLocalCache         |com.github.benmanes.caffeine.cache.UnboundedLocalCache'
	at net.sourceforge.pmd.util.AssertionUtil.assertValidJavaBinaryName(AssertionUtil.java:55)
	at net.sourceforge.pmd.lang.java.types.TypeTestUtil.isA(TypeTestUtil.java:116)
	at net.sourceforge.pmd.lang.java.rule.bestpractices.LooseCouplingRule.isAllowedType(LooseCouplingRule.java:72)
	at net.sourceforge.pmd.lang.java.rule.bestpractices.LooseCouplingRule.visit(LooseCouplingRule.java:49)
	at net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType.acceptVisitor(ASTClassOrInterfaceType.java:159)
	at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.acceptVisitor(AbstractJavaNode.java:38)
	at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.apply(AbstractJavaRule.java:24)
	at net.sourceforge.pmd.lang.rule.AbstractDelegateRule.apply(AbstractDelegateRule.java:232)
	at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex(RuleApplicator.java:75)
	... 9 more

https://github.com/ben-manes/caffeine/actions/runs/6389804412/job/17341828673?pr=1229#step:5:284

Code Sample demonstrating the issue:

Project's rulesSets.xml.

Steps to reproduce:
Check out the PR commit and run the script,

.github/scripts/analyze.sh

Running PMD through: Gradle

@ben-manes ben-manes added the a:bug PMD crashes or fails to analyse a file. label Oct 3, 2023
@ben-manes
Copy link
Author

Removing the whitespace did not help. The multi-valued configuration is documented, so perhaps that capability was removed for this rule?

@jsotuyod
Copy link
Member

jsotuyod commented Oct 3, 2023

@ben-manes it should be a comma-separated string. This doc section is clearly outdated 'though.

I'm unsure about the extra whitespace though… I don't remember if it was trimmed

@ben-manes
Copy link
Author

Perfect, that worked. Maybe the documentation needs to be updated since it suggests using a pipe?

Some properties take multiple values (a list), in which case you can provide them all by delimiting them with a delimiter character. It is usually a pipe (‘|’), or a comma (‘,’) for numeric properties, e.g.

@jsotuyod jsotuyod added the in:documentation Affects the documentation label Oct 3, 2023
@jsotuyod jsotuyod added this to the 7.0.0 milestone Oct 3, 2023
@jsotuyod
Copy link
Member

jsotuyod commented Oct 3, 2023

yeah, that needs updating as do the migration guide we recently put together. Thanks for raising this.

@jsotuyod jsotuyod changed the title IllegalArgumentException: Not a Java binary name [core] Multivalued properties do not accept | as a separator Oct 3, 2023
@adangel
Copy link
Member

adangel commented Oct 3, 2023

It's mentioned in this section: https://docs.pmd-code.org/latest/pmd_userdocs_migrating_to_pmd7.html#im-using-only-built-in-rules
It's also mentioned in the release notes of rc4: https://docs.pmd-code.org/latest/pmd_release_notes.html#rule-properties

And yes, https://docs.pmd-code.org/latest/pmd_userdocs_configuring_rules.html needs to be updated

@adangel adangel changed the title [core] Multivalued properties do not accept | as a separator [doc] Multivalued properties do not accept | as a separator Feb 23, 2024
adangel added a commit to adangel/pmd that referenced this issue Feb 23, 2024
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. in:documentation Affects the documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants