![JAR search and dependency download from the Maven repository](/logo.png)
hudson.plugins.checkstyle.rules.config_duplicates.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checkstyle Show documentation
Show all versions of checkstyle Show documentation
This plug-in generates the trend report for
Checkstyle, an open source static code analysis program.
<?xml version="1.0" encoding="ISO-8859-1"?> <document> <properties> <title>Duplicate code</title> <author>Checkstyle Development Team</author> </properties> <body> <p> <span class="xdocspagetitle">Duplicate code</span> detection allows you to find code that has been generated by Copy/Paste programming. Duplicate code typically leads to higher maintainance cost because bugs will need to be fixed twice, more code needs to be tested, etc. </p> <p> There are many trade-offs when writing a duplicate code detection tool. Some of the conflicting goals are: </p> <ul> <li>Fast</li> <li>Low memory usage</li> <li>Avoid false alarms</li> <li>Support multiple/arbitrary languages (Java, JSP, C++, ...)</li> <li>Support Fuzzy matches (comments, whitespace, linebreaks, variable renaming, etc.)</li> </ul> <p> The check provided here, StrictDuplicateCode, is fast enough to facilitate checking very large code bases in acceptable time (minutes). It consumes very little memory, false alarms are impossible. While it supports multiple languages it does not support fuzzy matches (that's why it's called Strict). </p> <p> Note that there are brilliant commercial implementations of duplicate code detection tools. One that is particularly noteworthy is <a href="http://www.redhillconsulting.com.au/products/simian/">Simian</a> from RedHill Consulting, Inc. Simian has managed to find a very good balance of the above tradeoffs. It is superior to the checks in this package in many repects. Simian is reasonably priced (free for noncommercial projects) and includes a Checkstyle plugin. </p> <p> The following table summarizes the characteristics of the available Checkstyle plugins for duplicate code detection: </p> <table> <tr> <th>Name</th> <th>Speed</th> <th>Memory Usage</th> <th>False Alarms</th> <th>Supported languages</th> <th>Fuzzy matches</th> </tr> <tr> <td>StrictDuplicateCode</td> <td>High</td> <td>Very Low</td> <td>Impossible</td> <td>any language</td> <td>No</td> </tr> <tr> <td>Simian</td> <td>Very high</td> <td>Low</td> <td>Possible but very unlikely</td> <td>many languages, including Java and C/C++/C#</td> <td>Limited support</td> </tr> </table> <p> <strong> We encourage all users of Checkstyle to evaluate Simian as an alternative to the Checks we offer in our distribution. </strong> </p><section name="StrictDuplicateCode"> <p> Performs a line-by-line comparison of all code lines and reports duplicate code if a sequence of lines differs only in indentation. All import statements in Java code are ignored, any other line - including javadoc, whitespace lines between methods, etc. - is considered (which is why the check is called <em>strict</em>). </p> <subsection name="Properties"> <table> <tr> <th>name</th> <th>description</th> <th>type</th> <th>default value</th> </tr> <tr> <td>min</td> <td>how many lines must be equal to be considered a duplicate</td> <td><a href="property_types.html#int">int</a></td> <td><span class="default">12</span></td> </tr> <tr> <td>charset</td> <td>name of the file charset</td> <td><a href="property_types.html#string">String</a></td> <td>System property "file.encoding"</td> </tr> </table> </subsection> <subsection name="Examples"> <p> To configure the check: </p> <source> <module name="StrictDuplicateCode"/> </source> <p> To configure the check so that it allows larger equivalent blocks: </p> <source> <module name="StrictDuplicateCode"> <property name="min" value="15"/> </module> </source> <p> To configure the check so that it handles files with the <span class="code">UTF-8</span> charset: </p> <source> <module name="StrictDuplicateCode"> <property name="charset" value="UTF-8"/> </module> </source> </subsection> <subsection name="Package"> <p>com.puppycrawl.tools.checkstyle.checks.duplicates</p> </subsection> <subsection name="Parent Module"> <p> <a href="config.html#Checker">Checker</a> </p> </subsection> </section> </body> </document>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy