Rylander
Rylander

Reputation: 20179

Does Sonar's complexity metric include equals() and hashCode() methods

When Sonar calculates cyclomatic complexity are the equals() and hashCode() methods included?

If so is there some way to exclude them?

Upvotes: 1

Views: 1553

Answers (1)

Yes, every method is used to compute the overall complexity of the enclosing class.

I guess I understand why you're asking such a question: modern IDEs generate the #equals() and #hashCode() methods for you, and those generated method tend to be quite complex. However, they are completely part of your code, and they truly add complexity: they should be tested - like any other method, to prevent any regression.

Upvotes: 2

Related Questions