squid:MaximumInheritanceDepth on Android(鱿鱼: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.
这篇关于鱿鱼:Android 上的最大继承深度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:鱿鱼:Android 上的最大继承深度
基础教程推荐
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 存储 20 位数字的数据类型 2022-01-01
