Let’s say you have a class that extends RuntimeException, ExtendedRuntimeException.
Then you have a class that extends that, ExtraExtendedRuntimeException.
Then you have a class that extends that, ExtraExtraExtendedRuntimeException.
In your application, this in practical purposes only really has an inheritance depth of 3.
However squid:MaximumInheritanceDepth of max depth = 6 will hit because this exceeds max inheritance depth. Because
Throwable -> Exception -> RuntimeException -> ExtendedRuntimeException -> ExtraExtendedRuntimeException -> ExtraExtraExtendedRuntimeException
We should remove the Throwable, Exception and RuntimeException java.lang classes from the counter.
Hello
@ndeepizza
, thanks for the feedback.
In fact, you can already reach this behavior with the current state of the rule, there is a rule parameter (
filteredClasses
), where you can list classes to be filtered out of the count of inheritance.
I don’t think adding it by default is a good idea, other user might be happy to consider the effective inheritance depth (count every classes, even the one not written by himself).
Hope this helps,
Quentin
[WEBINAR]
AI-Enhanced, Sonar Assured: Boost Developer Productivity and Improve Code Security in your SDLC - October 16
Register Now