Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
When Sonar calculates cyclomatic complexity are the equals() and hashCode() methods included?
equals()
hashCode()
If so is there some way to exclude them?
是的,每种方法都用于计算封闭类的整体复杂性。
我想我明白你为什么要问这样一个问题:现代 IDE 会为你生成#equals()和#hashCode()方法,而那些生成的方法往往相当复杂。但是,它们完全是您代码的一部分,并且确实增加了复杂性:它们应该像任何其他方法一样进行测试,以防止任何回归。
#equals()
#hashCode()