Comments (8)
You can set the auxclasspath on the designer to test this out from the View -> Analysis Classpath menu.
from pmd.
You should probably write
//MethodCall/TypeExpression[pmd-java:typeIs('org.apache.commons.collections.CollectionUtils')]
This should also work in eg just CollectionUtils.isEmpty(...)
without qualification. AmbiguousName nodes are rewritten to TypeExpression if your analysis classpath is complete (ie includes this apache library). This is probably what happens to make your expression with AmbiguousName not match.
from pmd.
You should probably write
//MethodCall/TypeExpression[pmd-java:typeIs('org.apache.commons.collections.CollectionUtils')]
How about a prefix match against a package name?
Below works in PMD v6.x:
//ImportDeclaration[starts-with(@ImportedName,'org.apache.commons.collections.')]
| //PrimaryPrefix/Name[starts-with(@Image, 'org.apache.commons.collections.')]
Is there a way to do it in PMD v7? Thank you very much!
from pmd.
Currently you can do that in XPath for the import but not for the method call. You can do it with a java rule though. methodCall.getOverloadSelectionInfo().getMethodType().getSymbol().getPackageName()
from pmd.
Related Issues (20)
- [java] AvoidRethrowingException should allow rethrowing exception subclasses
- [java] Unable to parse some Java9+ resource references HOT 2
- [cli] cpd-gui closes immediately HOT 4
- [java] UnnecessaryConstructor vs. AtLeastOneConstructor
- [java] UseExplicitTypes: cases where 'var' should be unobjectionable
- [apex] TYPEOF in sub-query throws error
- [java] UnnecessaryBoxing false positive in PMD 7.0.0 in lambda
- [java] EmptyCatchBlock false negative when allowCommentedBlocks=true
- [java] EmptyControlStatement should not allow empty try with concise resources
- [java] Merge rules MethodArgumentCouldBeFinal and LocalVariableCouldBeFinal
- [java] [cpd] Unable to parse interface with method declaration HOT 1
- [core] CPD: `--skip-duplicate-files` has no effect (7.0.0 regression) HOT 1
- PMD "broke" when use 'as user' HOT 3
- [java] Broken TextBlock parser
- [java] ImplicitSwitchFallThrough: False-positive with nested switch statements
- [doc] Improve doc around PMDConfiguration#prependAuxclasspath #setClassloader
- [core] Deprecate PMDConfiguration#setClassloader and #getClassloader
- [java] LocalVariableNamingConventions should allow unnamed variables by default
- [java] ClassNamingConventions uses wrong pattern for interfaces HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pmd.