问题描述
这是我的设置:
- 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.
这篇关于鱿鱼:Android 上的最大继承深度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)