Checkstyle 5.5

##### About

- Checkstyle
- Release Notes

##### Documentation

- Configuration
  - Property Types
- Running
  - Ant Task
  - Command Line
- Available Checks
- Standard Checks
  - Annotations
  - Block Checks
  - Class Design
  - Coding
  - Duplicate Code
  - Headers
  - Imports
  - Javadoc Comments
  - Metrics
  - Miscellaneous
  - Modifiers
  - Naming Conventions
  - Regexp
  - Size Violations
  - Whitespace
- Extending Checkstyle
  - Writing checks
  - Writing filters
  - Writing listeners

##### Developers

- Javadoc
- Project Page
- Contributing

##### Project Documentation

- Project Information
- Project Reports

## RegexpSingleline

### Description

A check for detecting single lines that match a supplied regular expression. Works with any file type.

Rationale: This check can be used to prototype checks and to find common bad practice such as calling `ex.printStacktrace()`, `System.out.println()`, `System.exit()`, etc.

### Properties

name | description | type | default value
--- | --- | --- | ---
format | illegal pattern | regular expression | `^$` (empty)
message | message which is used to notify about violations, if empty then default(hard-coded) message is used. | String | `""`(empty)
ignoreCase | Controls whether to ignore case when searching. | Boolean | `false`
minimum | The minimum number of matches required in each file. | Integer | `0`
maximum | The maximum number of matches required in each file. | Integer | `0`
fileExtensions | file type extension of files to process | String Set | `{}`

### Examples

To configure the check to find trailing whitespace at the end of a line:

    <module name="RegexpSingleline">
      <!-- \s matches whitespace character, $ matches end of line. -->
      <property name="format" value="\s+$"/>
    </module>

To configure the check to find trailing whitespace at the end of a line, with some slack of allowing two occurances per file:

    <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>

An example of how to configure the check to make sure a copyright statement is included in the file:

    <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>

### Package

com.puppycrawl.tools.checkstyle.checks

### Parent Module

Checker

## RegexpMultiline

### Description

A check for detecting that matches across multiple lines. Works with any file type.

Rationale: This check can be used to when the regular expression can be span multiple lines.

### Properties

name | description | type | default value
--- | --- | --- | ---
format | illegal pattern | regular expression | `^$` (empty)
message | message which is used to notify about violations, if empty then default(hard-coded) message is used. | String | `""`(empty)
ignoreCase | Controls whether to ignore case when searching. | Boolean | `false`
minimum | The minimum number of matches required in each file. | Integer | `0`
maximum | The maximum number of matches required in each file. | Integer | `0`
fileExtensions | file type extension of files to process | String Set | `{}`

### Examples

To configure the check to find calls to print to the console:

    <module name="RegexpMultiline">
      <property name="format"
       value="System\.(out)|(err)\.print(ln)?\("/>
    </module>

### Package

com.puppycrawl.tools.checkstyle.checks

### Parent Module

Checker

## RegexpSinglelineJava

### Description

This class is variation on RegexpSingleline for detecting single lines that match a supplied regular expression in Java files. It supports suppressing matches in Java comments.

### Properties

name | description | type | default value
--- | --- | --- | ---
format | illegal pattern | regular expression | `^$` (empty)
message | message which is used to notify about violations, if empty then default(hard-coded) message is used. | String | `""`(empty)
ignoreCase | Controls whether to ignore case when searching. | Boolean | `false`
minimum | The minimum number of matches required in each file. | Integer | `0`
maximum | The maximum number of matches required in each file. | Integer | `0`
ignoreComments | Controls whether to ignore text in comments when searching. | Boolean | `false`

### Examples

To configure the check for calls to `System.out.println`, except in comments:

    <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>

To configure the check to find case-insensitive occurrences of "debug":

    <module name="RegexpSinglelineJava">
        <property name="format" value="debug"/>
        <property name="ignoreCase" value="true"/>
    </module>

### Package

com.puppycrawl.tools.checkstyle.checks

### Parent Module

TreeWalker