319 lines
11 KiB
XML
319 lines
11 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<document xmlns="http://maven.apache.org/XDOC/2.0"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
|
|
|
|
<properties>
|
|
<title>Regexp</title>
|
|
<author>Checkstyle Development Team</author>
|
|
</properties>
|
|
|
|
<head>
|
|
<title>Regexp</title>
|
|
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
|
<script type="text/javascript" src="js/anchors.js"></script>
|
|
<script type="text/javascript" src="js/google-analytics.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<section name="RegexpSingleline">
|
|
<subsection name="Description">
|
|
<p>
|
|
A check for detecting single lines that match a supplied
|
|
regular expression. Works with any file type.
|
|
</p>
|
|
|
|
<p>
|
|
Rationale: This check can be used to prototype checks and to
|
|
find common bad practice such as calling <code>ex.printStacktrace()</code>, <code>
|
|
System.out.println()</code>, <code>System.exit()</code>, etc.
|
|
</p>
|
|
</subsection>
|
|
|
|
<subsection name="Properties">
|
|
<table>
|
|
<tr>
|
|
<th>name</th>
|
|
<th>description</th>
|
|
<th>type</th>
|
|
<th>default value</th>
|
|
</tr>
|
|
<tr>
|
|
<td>format</td>
|
|
<td>illegal pattern</td>
|
|
<td><a href="property_types.html#regexp">regular expression</a></td>
|
|
<td><code>^$</code> (empty)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>message</td>
|
|
<td>message which is used to notify about violations,
|
|
if empty then default(hard-coded) message is used.</td>
|
|
<td><a href="property_types.html#string">String</a></td>
|
|
<td><code>""</code>(empty)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>ignoreCase</td>
|
|
<td>Controls whether to ignore case when searching.</td>
|
|
<td><a href="property_types.html#boolean">Boolean</a></td>
|
|
<td><code>false</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>minimum</td>
|
|
<td>The minimum number of matches required in each file.</td>
|
|
<td><a href="property_types.html#integer">Integer</a></td>
|
|
<td><code>0</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>maximum</td>
|
|
<td>The maximum number of matches required in each file.</td>
|
|
<td><a href="property_types.html#integer">Integer</a></td>
|
|
<td><code>0</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>fileExtensions</td>
|
|
<td>file type extension of files to process</td>
|
|
<td><a href="property_types.html#stringSet">String Set</a></td>
|
|
<td><code>{}</code></td>
|
|
</tr>
|
|
</table>
|
|
</subsection>
|
|
|
|
<subsection name="Examples">
|
|
<p>
|
|
To configure the check to find trailing whitespace at the end
|
|
of a line:
|
|
</p>
|
|
<source>
|
|
<module name="RegexpSingleline">
|
|
<!-- \s matches whitespace character, $ matches end of line. -->
|
|
<property name="format" value="\s+$"/>
|
|
</module>
|
|
</source>
|
|
|
|
<p>
|
|
To configure the check to find trailing whitespace at the end
|
|
of a line, with some <i>slack</i> of allowing two occurrences
|
|
per file:
|
|
</p>
|
|
<source>
|
|
<module name="RegexpSingleline">
|
|
<property name="format" value="\s+$"/>
|
|
<!-- next line not required as 0 is the default -->
|
|
<property name="minimum" value="0"/>
|
|
<property name="maximum" value="2"/>
|
|
</module>
|
|
</source>
|
|
|
|
<p>
|
|
An example of how to configure the check to make sure a copyright
|
|
statement is included in the file:
|
|
</p>
|
|
<source>
|
|
<module name="RegexpSingleline">
|
|
<property name="format" value="This file is copyrighted"/>
|
|
<property name="minimum" value="1"/>
|
|
<!-- Need to specify a maximum, so 10 times is more than enough. -->
|
|
<property name="maximum" value="10"/>
|
|
</module>
|
|
</source>
|
|
</subsection>
|
|
|
|
<subsection name="Package">
|
|
<p>
|
|
com.puppycrawl.tools.checkstyle.checks.regexp
|
|
</p>
|
|
</subsection>
|
|
|
|
<subsection name="Parent Module">
|
|
<p>
|
|
<a href="config.html#Checker">Checker</a>
|
|
</p>
|
|
</subsection>
|
|
</section>
|
|
|
|
|
|
<section name="RegexpMultiline">
|
|
<subsection name="Description">
|
|
<p>
|
|
A check for detecting that matches across multiple lines.
|
|
Works with any file type.
|
|
</p>
|
|
|
|
<p>
|
|
Rationale: This check can be used to when the regular
|
|
expression can be span multiple lines.
|
|
</p>
|
|
</subsection>
|
|
|
|
<subsection name="Properties">
|
|
<table>
|
|
<tr>
|
|
<th>name</th>
|
|
<th>description</th>
|
|
<th>type</th>
|
|
<th>default value</th>
|
|
</tr>
|
|
<tr>
|
|
<td>format</td>
|
|
<td>illegal pattern</td>
|
|
<td><a href="property_types.html#regexp">regular expression</a></td>
|
|
<td><code>^$</code> (empty)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>message</td>
|
|
<td>message which is used to notify about violations,
|
|
if empty then default(hard-coded) message is used.</td>
|
|
<td><a href="property_types.html#string">String</a></td>
|
|
<td><code>""</code>(empty)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>ignoreCase</td>
|
|
<td>Controls whether to ignore case when searching.</td>
|
|
<td><a href="property_types.html#boolean">Boolean</a></td>
|
|
<td><code>false</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>minimum</td>
|
|
<td>The minimum number of matches required in each file.</td>
|
|
<td><a href="property_types.html#integer">Integer</a></td>
|
|
<td><code>0</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>maximum</td>
|
|
<td>The maximum number of matches required in each file.</td>
|
|
<td><a href="property_types.html#integer">Integer</a></td>
|
|
<td><code>0</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>fileExtensions</td>
|
|
<td>file type extension of files to process</td>
|
|
<td><a href="property_types.html#stringSet">String Set</a></td>
|
|
<td><code>{}</code></td>
|
|
</tr>
|
|
</table>
|
|
</subsection>
|
|
|
|
<subsection name="Examples">
|
|
<p>
|
|
To configure the check to find calls to print to the console:
|
|
</p>
|
|
<source>
|
|
<module name="RegexpMultiline">
|
|
<property name="format"
|
|
value="System\.(out)|(err)\.print(ln)?\("/>
|
|
</module>
|
|
</source>
|
|
</subsection>
|
|
|
|
<subsection name="Package">
|
|
<p>
|
|
com.puppycrawl.tools.checkstyle.checks.regexp
|
|
</p>
|
|
</subsection>
|
|
|
|
<subsection name="Parent Module">
|
|
<p>
|
|
<a href="config.html#Checker">Checker</a>
|
|
</p>
|
|
</subsection>
|
|
</section>
|
|
|
|
|
|
<section name="RegexpSinglelineJava">
|
|
<subsection name="Description">
|
|
<p>
|
|
This class is variation on <a
|
|
href="#RegexpSingleline">RegexpSingleline</a> for detecting
|
|
single lines that match a supplied regular expression in Java files. It supports suppressing matches in Java comments.
|
|
</p>
|
|
</subsection>
|
|
|
|
<subsection name="Properties">
|
|
<table>
|
|
<tr>
|
|
<th>name</th>
|
|
<th>description</th>
|
|
<th>type</th>
|
|
<th>default value</th>
|
|
</tr>
|
|
<tr>
|
|
<td>format</td>
|
|
<td>illegal pattern</td>
|
|
<td><a href="property_types.html#regexp">regular expression</a></td>
|
|
<td><code>^$</code> (empty)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>message</td>
|
|
<td>message which is used to notify about violations,
|
|
if empty then default(hard-coded) message is used.</td>
|
|
<td><a href="property_types.html#string">String</a></td>
|
|
<td><code>""</code>(empty)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>ignoreCase</td>
|
|
<td>Controls whether to ignore case when searching.</td>
|
|
<td><a href="property_types.html#boolean">Boolean</a></td>
|
|
<td><code>false</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>minimum</td>
|
|
<td>The minimum number of matches required in each file.</td>
|
|
<td><a href="property_types.html#integer">Integer</a></td>
|
|
<td><code>0</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>maximum</td>
|
|
<td>The maximum number of matches required in each file.</td>
|
|
<td><a href="property_types.html#integer">Integer</a></td>
|
|
<td><code>0</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>ignoreComments</td>
|
|
<td>Controls whether to ignore text in comments when searching.</td>
|
|
<td><a href="property_types.html#boolean">Boolean</a></td>
|
|
<td><code>false</code></td>
|
|
</tr>
|
|
</table>
|
|
</subsection>
|
|
|
|
<subsection name="Examples">
|
|
<p>
|
|
To configure the check for calls to <code>System.out.println</code>, except in comments:
|
|
</p>
|
|
<source>
|
|
<module name="RegexpSinglelineJava">
|
|
<!-- . matches any character, so we need to
|
|
escape it and use \. to match dots. -->
|
|
<property name="format" value="System\.out\.println"/>
|
|
<property name="ignoreComments" value="true"/>
|
|
</module>
|
|
</source>
|
|
|
|
<p>
|
|
To configure the check to find case-insensitive occurrences of
|
|
"debug":
|
|
</p>
|
|
<source>
|
|
<module name="RegexpSinglelineJava">
|
|
<property name="format" value="debug"/>
|
|
<property name="ignoreCase" value="true"/>
|
|
</module>
|
|
</source>
|
|
</subsection>
|
|
|
|
<subsection name="Package">
|
|
<p>
|
|
com.puppycrawl.tools.checkstyle.checks.regexp
|
|
</p>
|
|
</subsection>
|
|
|
|
<subsection name="Parent Module">
|
|
<p>
|
|
<a href="config.html#TreeWalker">TreeWalker</a>
|
|
</p>
|
|
</subsection>
|
|
</section>
|
|
</body>
|
|
</document>
|