Hi,
I have a problem with the following Code.
PMD5.3.3 think that the method "getImageUrlsListForVariant" is unused, but it is used as you can see.
Whats wrong with the rule?
public class blabla implements blabla2 { @Override public List<String> getProductImageUrls(final ApparelStyleVariantProductModel product, final String format) { return getImageUrlsListForVariant(product, format); } private List<String> getImageUrlsListForVariant(final VariantProductModel variant, final String format) { final SortedMap<Integer, String> imageUrls = getImageUrlsMapForVariant(variant, format); return new ArrayList<String>(imageUrls.values()); } }
Thanks
Mark
Similar to 1279.
Hi,
thanks for the report.
How do you execute PMD? For this situation, it is important to know about the "auxClasspath" option. It seems, that you run PMD with this option turned on.
The effect of this option is, that PMD will use the the runtime classpath of your application during analysis of your source code, so that less false negatives are produced. However, if you run PMD with this option provided, but the classpath doesn't contain the necessary classes, then, it will produce false positives, like in your case. I assume, that
ApparelStyleVariantProductModel
is a subclass ofVariantProductModel
- but PMD doesn't know about this.If you use PMD via the maven plugin, make sure, you run it after the compile phase, so that your own classes are on the classpath, too.
Thanks,
Andreas
Diff:
Hi Andreas ,
thanks for your reply.
I dont use auxclasspath as you can see below. I am using ANT and JAVA 8
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
<classpath>
<fileset dir="${build.common.bin.dir}/pmd/lib" includes="*.jar"/>
</classpath>
</taskdef>
I could reproduce it now - it is indeed a ant problem. The PMDTask always sets up the auxclasspath, regardless whether it has been configured or not.
This will be fixed with PMD 5.3.4.
Commit: https://github.com/pmd/pmd/commit/e1a41bdf984fdd8f79d6f3638e339d9a7bb57194