admin管理员组文章数量:1642496
· NPathComplexity: The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
翻译 n条路径复杂度:NPath复杂度是一个方法中各种可能的执行路径总和,一般把200作为考虑降低复杂度的临界点
· ExcessiveMethodLength: Violations of this rule usually indicate that the method is doing too much. Try to reduce the method size by creating helper methods and removing any copy/pasted code.
翻译 方法太长:这种违例就是方法中做了太多事,通过创建辅助方法或移除拷贝/粘贴的代码试着减小方法的规模
· ExcessiveParameterList: Long parameter lists can indicate that a new object should be created to wrap the numerous parameters. Basically, try to group the parameters together.
翻译 太多的参数:过长的参数列表表明应该创建一个新的对象包装众多的参数值,就是把参数组织到一起
· ExcessiveClassLength: Long Class files are indications that the class may be trying to do too much. Try to break it down, and reduce the size to something manageable.
翻译 太长的类:太长的类文件表明类试图做太多的事,试着分解它,减少到易于管理的规模
· CyclomaticComplexity: Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
翻译 秩复杂性:由if,while,for,case labels等决策点确定的复杂度,1-4是低复杂度,5-7为中,8到10是高复杂度,11以上是非常高
· ExcessivePublicCount: A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
翻译 过多的公共成员:一个类中如果声明了大量的公共方法和属性表明类需要分解,因为想完全测试这个类需要大量的努力。
· TooManyFields: Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
翻译 太多的域:类包含太多域可以被重新设计为包含更少的域,可以通过将一些信息组织为嵌套类。比如:一个类包含了city/state/zip域,可以用一个Address域组织这三个域
· NcssMethodCount: This rule uses the NCSS (Non Commenting Source Statements) algorithm to determine the number of lines of code for a given method. NCSS ignores comments, and counts actual statements. Using this algorithm, lines of code that are split are counted as one.
翻译 NCSS方法代码计算:这个规则采用NCSS(非注释代码块)算法计算给定的方法(不含构造方法)的代码行数。NCSS忽略代码中的注释并且计算实际代码行数。用这种算法,一行单独的代码被计算为1. (也同时忽略空行)
· NcssTypeCount: This rule uses the NCSS (Non Commenting Source Statements) algorithm to determine the number of lines of code for a given type. NCSS ignores comments, and counts actual statements. Using this algorithm, lines of code that are split are counted as one.
翻译 NCSS类代码计算:这个规则采用NCSS(非注释代码块)算法计算给定类型的代码行数。NCSS忽略代码中的注释并且计算实际代码行数。用这种算法,一行单独的代码被计算为1.(也同时忽略空行)
· NcssConstructorCount: This rule uses the NCSS (Non Commenting Source Statements) algorithm to determine the number of lines of code for a given constructor. NCSS ignores comments, and counts actual statements. Using this algorithm, lines of code that are split are counted as one.
翻译 NCSS构造器代码计算:这个规则适用NCSS(非注释代码块)算法计算给定的构造方法的代码行数。NCSS忽略代码中的注释并且计算实际代码行数。用这种算法,一行单独的代码被计算为1.(也同时忽略空行)
· TooManyMethods: A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
翻译 太多的方法:类中包含太多方法可能需要重构,以减低复杂度和获取更加细粒度的对象
版权声明:本文标题:PMD规则之Code Size Rules 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1729340811a1197510.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论