checkstyle/docs/config_modifiers.html

185 lines
5.4 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>Modifier 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>Modifier 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="#ModifierOrder">ModifierOrder</a>
</li>
<li>
<a href="#RedundantModifier">RedundantModifier</a>
</li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<!-- --><a name="ModifierOrder"></a> <h2>ModifierOrder</h2>
<h4>Description</h4>
<p class="body">
Checks that the order of modifiers conforms to the suggestions in the <a href="http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html">Java
Language specification, sections 8.1.1, 8.3.1 and 8.4.3</a>. The correct order
is:
</p>
<ol class="body">
<li>
<span class="code">public</span>
</li>
<li>
<span class="code">protected</span>
</li>
<li>
<span class="code">private</span>
</li>
<li>
<span class="code">abstract</span>
</li>
<li>
<span class="code">static</span>
</li>
<li>
<span class="code">final</span>
</li>
<li>
<span class="code">transient</span>
</li>
<li>
<span class="code">volatile</span>
</li>
<li>
<span class="code">synchronized</span>
</li>
<li>
<span class="code">native</span>
</li>
<li>
<span class="code">strictfp</span>
</li>
</ol>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;ModifierOrder&quot;/&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="RedundantModifier"></a><h2>RedundantModifier</h2>
<p class="body">
Checks that
<ul class="body">
<li>method declarations in interfaces include neither the <span class="code">
public</span> modifier nor the <span class="code">abstract</span> modifier (see
the <a
href="http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html">Java
Language specification, section 9.4</a>).
</li>
<li>all <span class="code">private</span> method declarations and all method declarations in a
<span class="code">final</span> class do not include modifier
<span class="code">final</span> (see the <a
href="http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#11246">Java
Language specification, section 8.4.3.3</a>).</li>
<li>
variable declarations in interfaces include none of the following
modifiers: <span class="code">public</span>, <span class="code">static</span>,
<span class="code">final</span> (variables in interface definitions are constants
and have these modifiers implicitly, see the <a
href="http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html">Java
Language specification, section 9.3</a>).
</li>
</ul>
<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>tokens</td>
<td>tokens to check</td>
<td>subset of tokens <a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">VARIABLE_DEF</a></td>
<td><a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
<a
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">VARIABLE_DEF</a></td>
</tr>
</table>
<h4>Example</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;RedundantModifier&quot;/&gt;
</pre>
<p class="body">
To configure the check to check only methods and not variables:
</p>
<pre class="body">
&lt;module name=&quot;RedundantModifier&quot;&gt;
&lt;property name=&quot;tokens&quot; value=&quot;METHOD_DEF&quot;/&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 />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>