That's about PMD static analyzer's feature: Copy-Paste Detector.
Yes, I read http://pmd.sourceforge.net/cpd.html thoroughly.
But if I run CPD from ant-task, I can fine-tune its work by specifying ignoreLiterals
and ignoreIdentifiers
. How can I specify these keys using command-line?
I think it's currently not possible (with pmd 4.2.6 and pmd 4.1.1).
A simple Properties
object contains the ignoreLiterals
and ignoreIdentifiers
settings, but the command line CPD.main()
method does not pass any Properties object to the LanguageFactory
as the ant task (CPDTask
) does. Furthermore, if I'm correct, the CPDTask
pass these properties to the LanguageFactory.createLanguage(String language, Properties properties)
method, but this method does not use the properties argument. So, IMO the ignoreLiterals
and ignoreIdentifiers
settings are ignored by the ant task.
Here is an old issue about this, which is still open. The patch looks correct, maybe it still works. Unfortunately it does not contain any fixes for the command line CPD
class. Perhaps it fixes the ant task. Anyway, if you really need this functionality it does not look too hard to fix these issues.