PMD规则之Code Size Rules

18 篇文章 1 订阅

·  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.

翻译   秩复杂性:由ifwhileforcase labels等决策点确定的复杂度,1-4是低复杂度,5-7为中,810是高复杂度,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.

翻译  太多的方法:类中包含太多方法可能需要重构,以减低复杂度和获取更加细粒度的对象

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值