checkstyle/docs/config_sizes.html

291 lines
8.5 KiB
HTML

<?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>Checks for Size Violations</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>Checks for Size Violations</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="#FileLength">FileLength</a>
</li>
<li>
<a href="#LineLength">LineLength</a>
</li>
<li>
<a href="#MethodLength">MethodLength</a>
</li>
<li>
<a href="#ParameterNumber">ParameterNumber</a>
</li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<a name="FileLength"></a> <h2>FileLength</h2> <h4>Description</h4>
<p class="body">
Checks for long source files.
</p>
<p class="body">
Rationale: If a source file becomes very long it is hard to understand.
Therefore long classes should usually be refactored into several individual
classes that focus on a specific task.
</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>max</td>
<td>maximum allowable number of lines</td>
<td><a href="property_types.html#integer">integer</a></td>
<td>2000</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check to accept files with up to 1500 lines:
</p>
<pre class="body">
&lt;module name="FileLength"&gt;
&lt;property name="max" value="1500"/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="LineLength"></a> <h2>LineLength</h2> <h4>Description</h4>
<p class="body">
Checks for long lines.
</p>
<p class="body">
Rationale: Long lines are hard to read in printouts or if developers have
limited screen space for the source code, e.g. if the IDE displays additional
information like project tree, class hierarchy, etc.
</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>ignorePattern</td>
<td>pattern for lines to ignore</td>
<td><a href="property_types.html#regexp">regular expression</a></td>
<td>^$</td>
</tr>
<tr>
<td>max</td>
<td>maximum allowable line length</td>
<td><a href="property_types.html#integer">integer</a></td>
<td>80</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check to accept lines up to 120 characters long:
</p>
<pre class="body">
&lt;module name="LineLength"&gt;
&lt;property name="max" value="120"/&gt;
&lt;/module&gt;
</pre>
<p class="body">
To configure the check to ignore lines that begin with &quot; * &quot;, followed
by just one word, such as within a Javadoc comment:
</p>
<pre class="body">
&lt;module name="LineLength"&gt;
&lt;property name="ignorePattern" value="^ *\* *[^ ]+$"/&gt;
&lt;/module&gt;
</pre>
<h4>Notes</h4>
<ul class="body">
<li>
The calculation of the length of a line takes into account the number of expanded spaces
for a tab character (<span class="code">'\t'</span>). The default number of spaces is
<span class="code">8</span>.
To specify a different number of spaces, the user can
set <a href="config.html#treewalker"><span class="code">TreeWalker</span></a> property
<span class="code">tabWidth</span> which applies to all Checks, including
<span class="code">LineLength</span>; or can set property
<span class="code">tabWidth</span> for <span class="code">LineLength</span> alone.
</li>
<li>Support for the special handling of imports in CheckStyle Version 2 has been
dropped as it is a special case of regexp: The user can set property
<span class="code">ignorePattern</span> to
<span class="code">^import</span> and achieve the same effect.
</li>
</ul>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="MethodLength"></a> <h2>MethodLength</h2> <h4>Description</h4>
<p class="body">
Checks for long methods and constructors.
</p>
<p class="body">
Rationale: If a method becomes very long it is hard to understand. Therefore
long methods should usually be refactored into several individual methods that
focus on a specific task.
</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>max</td>
<td>maximum allowable number of lines</td>
<td><a href="property_types.html#integer">integer</a></td>
<td>150</td>
</tr>
<tr>
<td>tokens</td>
<td>blocks to check</td>
<td>subset of tokens METHOD_DEF, CTOR_DEF</td>
<td>METHOD_DEF, CTOR_DEF</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name="MethodLength"/&gt;
</pre>
<p class="body">
To configure the check so that it accepts methods with at most 60 lines:
</p>
<pre class="body">
&lt;module name="MethodLength"&gt;
&lt;property name="tokens" value="METHOD_DEF"/&gt;
&lt;property name="max" value="60"/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<a name="ParameterNumber"></a> <h2>ParameterNumber</h2> <h4>Description</h4>
<p class="body">
Checks the number of parameters of a method or constructor.
</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>max</td>
<td>maximum allowable number of parameters</td>
<td><a href="property_types.html#integer">integer</a></td>
<td>7</td>
</tr>
<tr>
<td>tokens</td>
<td>declarations to check</td>
<td>subset of tokens METHOD_DEF, CTOR_DEF</td>
<td>METHOD_DEF, CTOR_DEF</td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name="ParameterNumber"/&gt;
</pre>
<p class="body">
To configure the check to allow 10 parameters for a method:
</p>
<pre class="body">
&lt;module name="ParameterNumber"&gt;
&lt;property name="max" value="10"/&gt;
&lt;property name="tokens" value="METHOD_DEF"/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
</td>
</tr>
</table>
<hr />
<p>
Copyright &copy; 2002 Oliver Burn. All rights Reserved.
</p>
</body>
</html>