[英]How to discover repeating code lines with PMD
A popular attempt to bypass Salesforce Apex code coverage rules are code busters where one statement is used in thousands of repeating lines.绕过 Salesforce Apex 代码覆盖规则的一种流行尝试是代码破坏者,其中一个语句在数千个重复行中使用。
We have found variations like i=1;
我们发现了像
i=1;
这样的变化i=1;
or a++;
或
a++;
or a=b;
或
a=b;
with endless variations for the variable name.变量名的变化无穷无尽。 All have in common that two (or more) consecutive lines (excluding empty or comments) are identical.
所有的共同点是两个(或更多)连续行(不包括空行或注释)是相同的。
How can I discover those in PMD?我怎样才能在 PMD 中发现那些?
This sound more like a use case for the copy paste detector.这听起来更像是复制粘贴检测器的用例。 This is a separate tool also available from PMD: https://pmd.github.io/pmd-6.12.0/pmd_userdocs_cpd.html
这是一个单独的工具,也可以从 PMD 获得: https : //pmd.github.io/pmd-6.12.0/pmd_userdocs_cpd.html
However, CPD is focused on finding duplicated code between different files, whereas you seem to be looking for duplicated code within one file.但是,CPD 专注于查找不同文件之间的重复代码,而您似乎正在寻找一个文件中的重复代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.