Skip to content

Commit

Permalink
Issue checkstyle#13693: migrate regexp checks to property macro
Browse files Browse the repository at this point in the history
  • Loading branch information
romani authored and nrmancuso committed Dec 29, 2023
1 parent aa68921 commit d7f97f3
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 299 deletions.
12 changes: 0 additions & 12 deletions config/checkstyle-non-main-files-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -347,18 +347,6 @@
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]recordcomponentname.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]recordtypeparametername.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]regexp[\\/]regexp.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]regexp[\\/]regexpmultiline.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]regexp[\\/]regexponfilename.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]regexp[\\/]regexpsingleline.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]regexp[\\/]regexpsinglelinejava.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]sizes[\\/]anoninnerlength.xml.template"/>


<!-- no properties by design -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@
* </p>
* <ul>
* <li>
* Property {@code fileExtensions} - Specify the file type extension of files to process. If this is
* specified, then only files that match these types are examined with the other
* patterns.
* Property {@code fileExtensions} - Specify the file type extension of files to process.
* Type is {@code java.lang.String[]}.
* Default value is {@code ""}.</li>
* <li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ public final class SiteUtil {
Map.entry("TypeNameCheck.applyToPrivate", VERSION_5_0),
Map.entry("TypeNameCheck.applyToProtected", VERSION_5_0),
Map.entry("TypeNameCheck.applyToPublic", VERSION_5_0),
Map.entry("TypeNameCheck.format", VERSION_3_0)
Map.entry("TypeNameCheck.format", VERSION_3_0),
Map.entry("RegexpMultilineCheck.fileExtensions", VERSION_5_0),
Map.entry("RegexpOnFilenameCheck.fileExtensions", "6.15"),
Map.entry("RegexpSinglelineCheck.fileExtensions", VERSION_5_0)
);

/** Map of all superclasses properties and their javadocs. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@
&lt;/p&gt;</description>
<properties>
<property default-value="" name="fileExtensions" type="java.lang.String[]">
<description>Specify the file type extension of files to process. If this is
specified, then only files that match these types are examined with the other
patterns.</description>
<description>Specify the file type extension of files to process.</description>
</property>
<property name="fileNamePattern" type="java.util.regex.Pattern">
<description>Specify the regular expression to match the file name against.</description>
Expand Down
8 changes: 2 additions & 6 deletions src/xdocs/checks/regexp/regexp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@
</tr>
<tr>
<td>duplicateLimit</td>
<td>Control whether to check for duplicates of a required pattern,
any negative value means no checking for duplicates, any positive
value is used as the maximum number of allowed duplicates, if the
limit is exceeded violations will be logged.</td>
<td>Control whether to check for duplicates of a required pattern, any negative value means no checking for duplicates, any positive value is used as the maximum number of allowed duplicates, if the limit is exceeded violations will be logged.</td>
<td><a href="../../property_types.html#int">int</a></td>
<td><code>0</code></td>
<td>4.0</td>
Expand Down Expand Up @@ -106,8 +103,7 @@
</tr>
<tr>
<td>message</td>
<td>Specify message which is used to notify about violations,
if empty then the default (hard-coded) message is used.</td>
<td>Specify message which is used to notify about violations, if empty then the default (hard-coded) message is used.</td>
<td><a href="../../property_types.html#String">String</a></td>
<td><code>null</code></td>
<td>4.0</td>
Expand Down
59 changes: 4 additions & 55 deletions src/xdocs/checks/regexp/regexp.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -58,61 +58,10 @@

<subsection name="Properties" id="Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>duplicateLimit</td>
<td>Control whether to check for duplicates of a required pattern,
any negative value means no checking for duplicates, any positive
value is used as the maximum number of allowed duplicates, if the
limit is exceeded violations will be logged.</td>
<td><a href="../../property_types.html#int">int</a></td>
<td><code>0</code></td>
<td>4.0</td>
</tr>
<tr>
<td>errorLimit</td>
<td>Specify the maximum number of violations before the check will abort.</td>
<td><a href="../../property_types.html#int">int</a></td>
<td><code>100</code></td>
<td>4.0</td>
</tr>
<tr>
<td>format</td>
<td>Specify the pattern to match against.</td>
<td><a href="../../property_types.html#Pattern">Pattern</a></td>
<td><code>"^$"</code></td>
<td>4.0</td>
</tr>
<tr>
<td>ignoreComments</td>
<td>Control whether to ignore matches found within comments.</td>
<td><a href="../../property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>4.0</td>
</tr>
<tr>
<td>illegalPattern</td>
<td>Control whether the pattern is required or illegal.</td>
<td><a href="../../property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>4.0</td>
</tr>
<tr>
<td>message</td>
<td>Specify message which is used to notify about violations,
if empty then the default (hard-coded) message is used.</td>
<td><a href="../../property_types.html#String">String</a></td>
<td><code>null</code></td>
<td>4.0</td>
</tr>
</table>
<macro name="properties">
<param name="modulePath"
value="src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheck.java"/>
</macro>
</div>
</subsection>

Expand Down
3 changes: 1 addition & 2 deletions src/xdocs/checks/regexp/regexpmultiline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@
</tr>
<tr>
<td>message</td>
<td>Specify the message which is used to notify about violations,
if empty then default (hard-coded) message is used.</td>
<td>Specify the 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>null</code></td>
<td>5.0</td>
Expand Down
63 changes: 4 additions & 59 deletions src/xdocs/checks/regexp/regexpmultiline.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -22,65 +22,10 @@

<subsection name="Properties" id="Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>fileExtensions</td>
<td>Specify the file type extension of files to process.</td>
<td><a href="../../property_types.html#String.5B.5D">String[]</a></td>
<td><code>all files</code></td>
<td>5.0</td>
</tr>
<tr>
<td>format</td>
<td>Specify the format of the regular expression to match.</td>
<td><a href="../../property_types.html#Pattern">Pattern</a></td>
<td><code>"$."</code></td>
<td>5.0</td>
</tr>
<tr>
<td>ignoreCase</td>
<td>Control whether to ignore case when searching.</td>
<td><a href="../../property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>5.0</td>
</tr>
<tr>
<td>matchAcrossLines</td>
<td>Control whether to match expressions across multiple lines.</td>
<td><a href="../../property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>8.25</td>
</tr>
<tr>
<td>maximum</td>
<td>Specify the maximum number of matches required in each file.</td>
<td><a href="../../property_types.html#int">int</a></td>
<td><code>0</code></td>
<td>5.0</td>
</tr>
<tr>
<td>message</td>
<td>Specify the 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>null</code></td>
<td>5.0</td>
</tr>
<tr>
<td>minimum</td>
<td>Specify the minimum number of matches required in each file.</td>
<td><a href="../../property_types.html#int">int</a></td>
<td><code>0</code></td>
<td>5.0</td>
</tr>
</table>
<macro name="properties">
<param name="modulePath"
value="src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheck.java"/>
</macro>
</div>
</subsection>

Expand Down
6 changes: 2 additions & 4 deletions src/xdocs/checks/regexp/regexponfilename.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
</tr>
<tr>
<td>fileExtensions</td>
<td>Specify the file type extension of files to process. If this is specified, then
only files that match these types are examined with the other patterns.</td>
<td>Specify the file type extension of files to process.</td>
<td><a href="../../property_types.html#String.5B.5D">String[]</a></td>
<td><code>all files</code></td>
<td>6.15</td>
Expand Down Expand Up @@ -90,8 +89,7 @@
</tr>
<tr>
<td>match</td>
<td>Control whether to look for a match or mismatch on the file name, if the
fileNamePattern is supplied, otherwise it is applied on the folderPattern.</td>
<td>Control whether to look for a match or mismatch on the file name, if the fileNamePattern is supplied, otherwise it is applied on the folderPattern.</td>
<td><a href="../../property_types.html#boolean">boolean</a></td>
<td><code>true</code></td>
<td>6.15</td>
Expand Down
50 changes: 4 additions & 46 deletions src/xdocs/checks/regexp/regexponfilename.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -51,52 +51,10 @@

<subsection name="Properties" id="Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>fileExtensions</td>
<td>Specify the file type extension of files to process. If this is specified, then
only files that match these types are examined with the other patterns.</td>
<td><a href="../../property_types.html#String.5B.5D">String[]</a></td>
<td><code>all files</code></td>
<td>6.15</td>
</tr>
<tr>
<td>fileNamePattern</td>
<td>Specify the regular expression to match the file name against.</td>
<td><a href="../../property_types.html#Pattern">Pattern</a></td>
<td><code>null</code></td>
<td>6.15</td>
</tr>
<tr>
<td>folderPattern</td>
<td>Specify the regular expression to match the folder path against.</td>
<td><a href="../../property_types.html#Pattern">Pattern</a></td>
<td><code>null</code></td>
<td>6.15</td>
</tr>
<tr>
<td>ignoreFileNameExtensions</td>
<td>Control whether to ignore the file extension for the file name match.</td>
<td><a href="../../property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>6.15</td>
</tr>
<tr>
<td>match</td>
<td>Control whether to look for a match or mismatch on the file name, if the
fileNamePattern is supplied, otherwise it is applied on the folderPattern.</td>
<td><a href="../../property_types.html#boolean">boolean</a></td>
<td><code>true</code></td>
<td>6.15</td>
</tr>
</table>
<macro name="properties">
<param name="modulePath"
value="src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpOnFilenameCheck.java"/>
</macro>
</div>
</subsection>

Expand Down
3 changes: 1 addition & 2 deletions src/xdocs/checks/regexp/regexpsingleline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
</tr>
<tr>
<td>message</td>
<td>Specify the message which is used to notify about violations,
if empty then default (hard-coded) message is used.</td>
<td>Specify the 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>null</code></td>
<td>5.0</td>
Expand Down
56 changes: 4 additions & 52 deletions src/xdocs/checks/regexp/regexpsingleline.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -22,58 +22,10 @@

<subsection name="Properties" id="Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>fileExtensions</td>
<td>Specify the file type extension of files to process.</td>
<td><a href="../../property_types.html#String.5B.5D">String[]</a></td>
<td><code>all files</code></td>
<td>5.0</td>
</tr>
<tr>
<td>format</td>
<td>Specify the format of the regular expression to match.</td>
<td><a href="../../property_types.html#Pattern">Pattern</a></td>
<td><code>"$."</code></td>
<td>5.0</td>
</tr>
<tr>
<td>ignoreCase</td>
<td>Control whether to ignore case when searching.</td>
<td><a href="../../property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>5.0</td>
</tr>
<tr>
<td>maximum</td>
<td>Specify the maximum number of matches required in each file.</td>
<td><a href="../../property_types.html#int">int</a></td>
<td><code>0</code></td>
<td>5.0</td>
</tr>
<tr>
<td>message</td>
<td>Specify the 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>null</code></td>
<td>5.0</td>
</tr>
<tr>
<td>minimum</td>
<td>Specify the minimum number of matches required in each file.</td>
<td><a href="../../property_types.html#int">int</a></td>
<td><code>0</code></td>
<td>5.0</td>
</tr>
</table>
<macro name="properties">
<param name="modulePath"
value="src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineCheck.java"/>
</macro>
</div>
</subsection>

Expand Down
3 changes: 1 addition & 2 deletions src/xdocs/checks/regexp/regexpsinglelinejava.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
</tr>
<tr>
<td>message</td>
<td>Specify the message which is used to notify about violations,
if empty then default (hard-coded) message is used.</td>
<td>Specify the 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>null</code></td>
<td>6.0</td>
Expand Down
Loading

0 comments on commit d7f97f3

Please sign in to comment.