gpt4 book ai didi

java - PMD - 违规 :SuspiciousEqualsMethodName

转载 作者:行者123 更新时间:2023-11-30 08:05:23 26 4
gpt4 key购买 nike

我有以下代码,我得到了 PMD 违规 SuspiciousEqualsMethodName。

我想知道为什么这会被视为违规?

private boolean areEquals(final Object thisObj, final Object thatObj) {
return thisObj == null && thatObj == null || thisObj != null && thisObj.equals(thatObj);
}

@Override
public boolean equals(final Object obj) {
return obj instanceof AttributeKey && areEquals(this.getEndPoint(), ((AttributeKey) obj).getEndPoint())
&& areEquals(this.getCluster(), ((AttributeKey) obj).getCluster());
}

最佳答案

我怀疑是 obj 上的 final 修饰符触发了这个;即 PMD 规则不正确。

(不知道您正在使用的 PMD 版本,就不可能知道规则是如何定义的。如果您能告诉我版本,我可以检查规则的 XML 实际说的是什么。)

关于java - PMD - 违规 :SuspiciousEqualsMethodName,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35082641/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com