我是新来的PMD/CPD
.我PMD
在我的maven项目中配置如下:
org.parent
CustRestExampleOsgi
1.0
pom
CustRestExampleOsgii
CustImplProvider
CustInterface
RestCustConsumer
G:\apache-karaf-3.0.0.RC1\deploy
org.apache.maven.plugins
maven-pmd-plugin
3.0
org.apache.maven.plugins
maven-jxr-plugin
2.3
org.apache.maven.plugins
maven-javadoc-plugin
2.9.1
我的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
正常查找报告.我错过了一些配置或规则集吗?
请帮忙!
确保将最小令牌数设置得足够低.您的短片重复代码的标记少于默认值100.
根据文件,该财产被称为minimumTokens
.较旧版本的Maven PMD插件具有属性maven.pmd.cpd.minimumtokencount
.将其设置为5以进行测试.在现实生活中,默认值100是一个很好的价值.