3
我是PMD/CPD
的新手。我在Maven項目配置PMD
如下:PMD/CPD無法檢測到重複的代碼
<groupId>org.parent</groupId>
<artifactId>CustRestExampleOsgi</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>CustRestExampleOsgii</name>
<modules>
<module>CustImplProvider</module>
<module>CustInterface</module>
<module>RestCustConsumer</module>
</modules>
<properties>
<karaf.deploy.build.folder>
G:\apache-karaf-3.0.0.RC1\deploy
</karaf.deploy.build.folder>
</properties>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
</plugin>
</plugins>
</reporting>
我的Maven項目通常是編譯和mvn jxr:jxr site
生成的所有報告。 但我無法找到任何顯示重複代碼的結果。爲了測試這個我已經在我的代碼有意引入重複的代碼,如:
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Address)) {
return false;
}
Address other = (Address) object;
if ((this.id == null && other.id != null)
|| (this.id != null && !this.id.equals(other.id))) {
return false;
}
if (!(object instanceof Address)) { //Duplicate is here
return false;
}
return true;
}
但始終CPD
沒有顯示出在源代碼中檢測到的問題。但是,我可以正常發現PMD
報告。我是否缺少一些配置或規則集?
請幫忙!
哦哇!它按預期完美工作。非常感謝!!! :-) – Amrit