PMD CPD excludes methods like equals and hashcode?

I cannot find an option on how to tell PMD-CPD to skip certain methods. We use the generated methods equals()and hashCode(), therefore, the methods often look very similar, and the CPD reports that many of them duplicate the code.

I can use some comments //NOPMDin the code, but what in my eyes is not a way to manage my code. Since I am including the tool in the code, that has nothing to do with the code. CPD helps to avoid coding errors / styles and should not force me to change the code.

So it would be very useful if someone had ideas on how to solve it.

best wishes

+4
source share
1

PMD CPD , , , .

, CPD:

//enable suppression
@SuppressWarnings("CPD-START")
public Object someMethod(int x) throws Exception {
    // any code here will be ignored for the duplication detection
}
//disable suppression
@SuppressWarnings("CPD-END")
public void nextMethod() {
}

, . nextMethod() someMethod(), CPD-END. , //NOPMD. CPD, PMD, //NOPMD .

. , , - , . , SonarQube - .

+1

Source: https://habr.com/ru/post/1548584/


All Articles