This is my setup:
Code:
public class BaseActivity extends android.app.Activity {}
public class FooActivity extends BaseActivity {}
SonarQube thinks that FooActivity
violates squid:MaximumInheritanceDepth
:
This class has 6 parents which is greater than 5 authorized.
android.app.Activity
is Android Native API.
Shouldn't any super classes of Activity
be ignored when calculating violations for this rule?
Is this a bug?
This is not a bug, but rather a configuration issue. Rule squid:S110
can be configured to filter out classes from the inheritance tree. By default, no class is ignored and the rule simply count the number of inheritance levels till reaching Object
class. In order to configure filtered classes, you have to set up the filteredClasses
rule property.
Note that it is plan to update to rule to not simply exclude filtered classes from the total inheritance depth, but stop incrementing inheritance levels as soon as reaching a filtered class. The fix will be done when handling Jira ticket SONARJAVA-2252.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With