简体   繁体   English

SonarQube规则squid:S1200限制java。*类为20吗?

[英]SonarQube rule squid:S1200 counts java.* classes in its limit of 20?

How does the SonarQube rule SonarQube规则如何

squid:S1200: Classes should not be coupled to too many other classes (Single Responsibility Principle) squid:S1200:班级不应与太多其他班级联系在一起(单一责任原则)

count the coupling number towards its limit of 20? 计算耦合数到其极限20?

It seems like it counts classes from the standard Java packages like java.lang.* , java.text.* and java.util.* in this rule's limit of 20. So If I use the Java Integer class, I've used up 1/20 of this rule's limit. 似乎它从标准Ja​​va包(例如java.lang.*java.text.*java.util.*中计数了20条规则的限制。因此,如果我使用Java Integer类,就用光了此规则限制的1/20。

Additional Info: SonarQube Version: 4.5.1 附加信息:SonarQube版本:4.5.1

The best way to answer your question is to look directly at the source code of this rule : https://github.com/SonarSource/sonar-java/blob/c1f15b81bcd9d643ab403aeea6e1606040f84eac/java-checks/src/main/java/org/sonar/java/checks/ClassCouplingCheck.java 回答问题的最佳方法是直接查看此规则的源代码: https : //github.com/SonarSource/sonar-java/blob/c1f15b81bcd9d643ab403aeea6e1606040f84eac/java-checks/src/main/java/org/sonar /java/checks/ClassCouplingCheck.java

So it counts every declared type. 因此,它计算每个声明的类型。 And so indeed if you use java.lang.Integer it will count as one type so 1/20 of the this rule's limit. 因此,的确,如果您使用java.lang.Integer,它将被视为一种类型,因此是此规则限制的1/20。

The good news is that you can configure this '20' magical number in your quality profile. 好消息是,您可以在质量配置文件中配置此“ 20”幻数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM