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 上的最大继承深度
基础教程推荐
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- JPA惰性列表上的流 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
