179 lines
6.2 KiB
HTML
179 lines
6.2 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 Headers</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 Headers</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="#Header">Header</a>
|
|
</li>
|
|
<li>
|
|
<a href="#RegexpHeader">RegexpHeader</a>
|
|
</li>
|
|
</ul>
|
|
</td>
|
|
<!--Content-->
|
|
<td class="content" valign="top" align="left">
|
|
|
|
<a name="Header"></a> <h2>Header</h2> <h4>Description</h4>
|
|
<p class="body">
|
|
Checks that a source file begins with a specified header. Property <span class="code">
|
|
headerFile</span> specifies a file that contains the required header.
|
|
</p>
|
|
<p class="body">
|
|
Property <span class="code">ignoreLines</span> specifies the line numbers to
|
|
ignore when matching lines in a header file. This property is very useful for
|
|
supporting headers that contain copyright dates. For example, consider the
|
|
following header:
|
|
</p>
|
|
<pre class="body">
|
|
line 1: ////////////////////////////////////////////////////////////////////
|
|
line 2: // checkstyle:
|
|
line 3: // Checks Java source code for adherence to a set of rules.
|
|
line 4: // Copyright (C) 2002 Oliver Burn
|
|
line 5: ////////////////////////////////////////////////////////////////////
|
|
</pre>
|
|
<p class="body">
|
|
Since the year information will change over time, you can tell Checkstyle to
|
|
ignore line 4 by setting property <span class="code">ignoreLines</span> to <span class="code">
|
|
4</span>.
|
|
</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>headerFile</td>
|
|
<td>name of the file containing the required header</td>
|
|
<td><a href="property_types.html#string">string</a></td>
|
|
<td><span class="default">null</span></td>
|
|
</tr>
|
|
<tr>
|
|
<td>ignoreLines</td>
|
|
<td>line numbers to ignore</td>
|
|
<td><a href="property_types.html#intSet">list of integers</a></td>
|
|
<td><span class="default">{}</span></td>
|
|
</tr>
|
|
</table>
|
|
|
|
<h4>Example</h4>
|
|
<p class="body">
|
|
To configure the check to use header file <span class="code">"java.header"</span>
|
|
and ignore lines <span class="code">2</span>, <span class="code">3</span>, and <span class="code">
|
|
4</span>:
|
|
</p>
|
|
<pre class="body">
|
|
<module name="Header">
|
|
<property name="headerFile" value="java.header"/>
|
|
<property name="ignoreLines" value="2, 3, 4"/>
|
|
</module>
|
|
</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="RegexpHeader"></a> <h2>RegexpHeader</h2> <h4>Description</h4>
|
|
<p class="body">
|
|
Checks the header of a source file against a header file that contains a <a href="http://jakarta.apache.org/regexp/apidocs/org/apache/regexp/RE.html">regular
|
|
expression</a> for each line of the source header.
|
|
</p>
|
|
<p class="body">
|
|
Rationale: In some projects <a href="#Header">checking against a fixed header</a>
|
|
is not sufficient, e.g. the header might require a copyright line where the year
|
|
information is not static.
|
|
</p>
|
|
<p class="body">
|
|
For example, consider the following header file:
|
|
</p>
|
|
<pre class="body">
|
|
line 1: /{71}
|
|
line 2: // checkstyle:
|
|
line 3: // Checks Java source code for adherence to a set of rules\.
|
|
line 4: // Copyright \(C\) \d\d\d\d Oliver Burn
|
|
line 5: // Last modification by \$Author.*\$
|
|
line 6: /{71}
|
|
</pre>
|
|
|
|
<p class="body">
|
|
Lines 1 and 6 demonstrate a more compact notation for 71 '/' characters. Line 4
|
|
enforces that the copyright notice includes a four digit year. Line 5 is an
|
|
example how to enforce revision control keywords in a file header.
|
|
</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>headerFile</td>
|
|
<td>name of the file containing the required header</td>
|
|
<td><a href="property_types.html#string">string</a></td>
|
|
<td><span class="default">null</span></td>
|
|
</tr>
|
|
<tr>
|
|
<td>ignoreLines</td>
|
|
<td>line numbers to ignore</td>
|
|
<td><a href="property_types.html#intSet">list of integers</a></td>
|
|
<td><span class="default">{}</span></td>
|
|
</tr>
|
|
</table>
|
|
|
|
<h4>Example</h4>
|
|
<p class="body">
|
|
To configure the check to use header file <span class="code">"java.header"</span>
|
|
and ignore lines <span class="code">2</span>, <span class="code">3</span>, and <span class="code">
|
|
4</span>:
|
|
</p>
|
|
<pre class="body">
|
|
<module name="RegexpHeader">
|
|
<property name="headerFile" value="java.header"/>
|
|
<property name="ignoreLines" value="2, 3, 4"/>
|
|
</module>
|
|
</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 class="copyright">
|
|
Copyright © 2002-2003 Oliver Burn. All rights Reserved.
|
|
</p>
|
|
|
|
</body>
|
|
</html> |