added docs for duplicate code detection
This commit is contained in:
parent
d974a457e1
commit
e9cc31b2ec
|
|
@ -431,6 +431,9 @@
|
|||
<li>
|
||||
<a href="config_design.html">Checks For Design Problems</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="config_duplicates.html">Checks For Finding Duplicate Code</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="config_misc.html">Miscellaneous Checks</a>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,152 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>Duplicate Code Checks</title>
|
||||
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- The header -->
|
||||
<table border="0" width="100%" summary="header layout">
|
||||
<tr>
|
||||
<td><h1>Class Design Checks</h1></td>
|
||||
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- content -->
|
||||
<table border="0" width="100%" cellpadding="5" summary="body layout">
|
||||
<tr>
|
||||
<!--Left menu-->
|
||||
<td class="menu" valign="top">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#StrictDuplicateCode">StrictDuplicateCode</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
<!--Content-->
|
||||
<td class="content" valign="top" align="left">
|
||||
|
||||
There are many trade-offs when writing a duplicate code detection tool.
|
||||
Some of the conflicting goals are:
|
||||
<ul>
|
||||
<li>Fast</li>
|
||||
<li>Low memory usage</li>
|
||||
<li>Avoid false alarms</li>
|
||||
<li>Support multiple/arbitrary languages</li>
|
||||
<li>Support Fuzzy matches (comments, whitespace, linebreaks, variable renaming, etc.)</li>
|
||||
</ul>
|
||||
</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.
|
||||
</p>
|
||||
<p>
|
||||
Simian is reasonably priced (free for noncommercial projects)
|
||||
and includes a Checkstyle plugin.
|
||||
We encourage all users of Checkstyle to evaluate Simian as an
|
||||
alternative to the Checks we offer in our distribution.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The following table summarizes the characteristics of the available
|
||||
Checkstyle plugins for duplicate code detection:
|
||||
<table width="100%" border="1" cellpadding="5" class="body">
|
||||
<tr class="header">
|
||||
<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>Medium</td>
|
||||
<td>Very Low</td>
|
||||
<td>Possible but very unlikely</td>
|
||||
<td>any language</td>
|
||||
<td>No</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Simian</td>
|
||||
<td>Very high</td>
|
||||
<td>Low</td>
|
||||
<td>unknown</td>
|
||||
<td>many languages, including Java and C/C++/C#</td>
|
||||
<td>Limited support</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<a name="StrictDuplicateCode"></a><h2>StrictDuplicateCode</h2>
|
||||
<p class="body">
|
||||
</p>
|
||||
|
||||
|
||||
<h4>Properties</h4>
|
||||
<table width="100%" border="1" cellpadding="5" class="body">
|
||||
<tr class="header">
|
||||
<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>
|
||||
</table>
|
||||
<h4>Examples</h4>
|
||||
<p class="body">
|
||||
To configure the check:
|
||||
</p>
|
||||
<pre class="body">
|
||||
<module name="StrictDuplicateCode"/>
|
||||
</pre>
|
||||
<p class="body">
|
||||
To configure the check so that it allows larger equivalent blocks:
|
||||
</p>
|
||||
<pre class="body">
|
||||
<module name="VisibilityModifier">
|
||||
<property name="min" value="15"/>
|
||||
</module>
|
||||
</pre>
|
||||
<p class="body">
|
||||
To configure the check so that it allows no public members:
|
||||
</p>
|
||||
<pre class="body">
|
||||
<module name="VisibilityModifier">
|
||||
<property name="publicMemberPattern" value="^$"/>
|
||||
</module>
|
||||
</pre>
|
||||
<h4>Package</h4>
|
||||
<p class="body">
|
||||
com.puppycrawl.tools.checkstyle.checks.duplicates
|
||||
</p>
|
||||
<h4>Parent Module</h4>
|
||||
<p class="body">
|
||||
<a href="config.html#checker">Checker</a>
|
||||
</p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr />
|
||||
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
|
||||
<p class="copyright">
|
||||
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -132,6 +132,7 @@
|
|||
<li class="body"><a href="config_design.html">Class Design</a></li>
|
||||
<li class="body"><a href="config_usage.html">Usage</a></li>
|
||||
<li class="body"><a href="config_j2ee.html">J2EE Requirements</a></li>
|
||||
<li class="body"><a href="config_duplicates.html">Duplicate Code</a></li>
|
||||
<li class="body"><a href="config_misc.html">Miscellaneous Checks</a></li>
|
||||
</ul>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue