Closed mjovanc closed 2 years ago
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')
}
@mjovanc has that helped or is it solved for you?
@aaschmid it was solved by your answer. Sorry I forgot to answer you. Thanks a lot!
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?