aaschmid / gradle-cpd-plugin

Gradle plugin to find duplicate code using PMDs copy/paste detection (= CPD).
Apache License 2.0
95 stars 12 forks source link

Changing cpdCheck source seems to have no affect #34

Closed LethiferousMoose closed 5 years ago

LethiferousMoose commented 5 years ago

I've tried following your readme and I still cannot seem to make cpdCheck stop running on tests and scala. This does not work:

   cpd {
        language = 'java'
        skipLexicalErrors = true
        toolVersion = '6.12.0'
    }

   cpdCheck {
      source = sourceSets.main.java
   }

This also does not work

    cpd {
        language = 'java'
        skipLexicalErrors = true
        toolVersion = '6.12.0'
    }

    tasks.cpdCheck {
        source = sourceSets.main.java
    }

If I turn on debug logging, I still see it "Tokenizing" tests and scala code. I'm also very confused why it is trying to read a changelog,md file located in my src directory.

aaschmid commented 5 years ago

Hi @LethiferousMoose,

I am not sure by heart but I think this has something to do with how scala and java plugin integrates with another. I will dive deeper into it and give you feedback.

Meanwhile you can try

tasks.withType(Cpd) {
    exclude "*.scala"
}

There is also an include method, see https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/SourceTask.html.

Does that help you for now?

aaschmid commented 5 years ago

@LethiferousMoose any news on this?

LethiferousMoose commented 5 years ago

I haven't done any more with it. CPD was finding too many false positives on our code base and I decided against using it because it wasn't adding enough value to justify it.

aaschmid commented 5 years ago

OK, thanks for the answer. I will close the issue but don't hesitate to reopen if it is still a problem :-)