squid:MaximumInheritanceDepth在Android上 [英] squid:MaximumInheritanceDepth on Android

查看:67
本文介绍了squid:MaximumInheritanceDepth在Android上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的设置:

  • SonarQube 5.6.6
  • SonarJava插件4.8.0.9441

代码:

public class BaseActivity extends android.app.Activity {}

public class FooActivity extends BaseActivity {}

SonarQube认为 FooActivity 违反了 squid:MaximumInheritanceDepth :

SonarQube thinks that FooActivity violates squid:MaximumInheritanceDepth:

本课程有6位家长,超过5位获得授权.

This class has 6 parents which is greater than 5 authorized.

android.app.Activity 是Android本机API.在计算违反此规则的行为时,是否不应该忽略 Activity 的任何超类?

android.app.Activity is Android Native API. Shouldn't any super classes of Activity be ignored when calculating violations for this rule?

这是一个错误吗?

推荐答案

这不是bug,而是配置问题.可以配置规则 squid:S110 来过滤类从继承树.默认情况下,不会忽略任何类,并且该规则仅计算继承级别的数量,直到达到 Object 类.为了配置过滤的类,您必须设置 filteredClasses 规则属性.

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.

请注意,计划将规则更新为不只是从总继承深度中排除已过滤的类,而是在达到已过滤的类后立即停止增加继承级别.将在处理Jira票证 SONARJAVA-2252 时完成.

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.

这篇关于squid:MaximumInheritanceDepth在Android上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆