Ignore two files that are duplicated by cpdCheck
mjovanc opened this issue · 3 comments
I'm trying to read through the documentation here and as well as on PMD but I don't seem to have the option to ignore two files that cpdCheck says are duplicates. They have some duplicated code, but the code is necessary and can't be avoided any other way.
How can I do make my two classes ignored with the error "Found a 30 line (103 tokens) duplication in the following files: "? is there a setting in Gradle I can do?
Best solution to this might be using annotation or comments, see https://pmd.github.io/pmd-6.13.0/pmd_userdocs_cpd.html#suppression.
If you need to exclude more code or e.g. all tests, you can exclude files either overriding the source
property directly or providing an include
or exclude
as Cpd
is actually a SourceTask and therefore supports its properties, e.g. see JavaDoc of Cpd
:
task cpd(type: Cpd, description: 'Copy/Paste detection for all Ruby scripts') {
// change language of cpd to Ruby
language = 'ruby'
// set minimum token count causing a duplication warning
minimumTokenCount = 10
// enable CSV reports and customize outputLocation, disable xml report
reports {
csv {
required = true
outputLocation = file("${buildDir}/cpd.csv")
}
xml.required = false
}
// explicitly include all Ruby files and exclude tests
include '**.rb'
exclude '**Test*'
// set source for running duplication check on
source = files('src/ruby')
}