Migrated more documentation.
This commit is contained in:
parent
91994467f4
commit
7344a99c88
|
|
@ -1,164 +0,0 @@
|
|||
<?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>Duplicate Code 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>Possible but very unlikely</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">
|
||||
Performs a line-by-line comparison of all code lines and reports
|
||||
duplicate code, i.e. a sequence of lines that differ 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>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
<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="StrictDuplicateCode">
|
||||
<property name="min" value="15"/>
|
||||
</module>
|
||||
</pre>
|
||||
<p class="body">
|
||||
To configure the check so that it handles files with the <span class="code">UTF-8</span>
|
||||
charset:
|
||||
</p>
|
||||
<pre class="body">
|
||||
<module name="StrictDuplicateCode">
|
||||
<property name="charset" value="UTF-8"/>
|
||||
</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-2004 Oliver Burn. All rights Reserved.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue