Skip to content

Commit

Permalink
Issue checkstyle#13693: migrate misc modules to property macros
Browse files Browse the repository at this point in the history
  • Loading branch information
romani authored and nrmancuso committed Jan 5, 2024
1 parent a5d0468 commit e449968
Show file tree
Hide file tree
Showing 19 changed files with 63 additions and 174 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 @@ -253,18 +253,6 @@
<!-- Properties macro suppressions until https://github.com/checkstyle/checkstyle/issues/13693 -->
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]imports[\\/]customimportorder.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]misc[\\/]orderedproperties.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]misc[\\/]todocomment.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]misc[\\/]trailingcomment.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]misc[\\/]translation.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]misc[\\/]uncommentedmain.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]misc[\\/]uniqueproperties.xml.template"/>

<!-- no properties by design -->
<suppress id="propertiesMacroMustExist"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
* <p>Known limitation: The key should not contain a newline.
* The string compare will work, but not the line number reporting.</p>
* <ul><li>
* Property {@code fileExtensions} - Specify file type extension of the files to check.
* Property {@code fileExtensions} - Specify the file extensions of the files to process.
* Type is {@code java.lang.String[]}.
* Default value is {@code .properties}.
* </li></ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@
* of default translation files in project.
* </p>
* <p>
* Note: If your project uses preprocessed translation files and the original files do not have the
* {@code properties} extension, you can specify additional file extensions
* via the {@code fileExtensions} property.
* </p>
* <p>
* Attention: the check will perform the validation of ISO codes if the option
* is used. So, if you specify, for example, "mm" for language code,
* TranslationCheck will rise violation that the language code is incorrect.
Expand All @@ -113,10 +118,7 @@
* Default value is {@code "^messages.*$"}.
* </li>
* <li>
* Property {@code fileExtensions} - Specify file type extension to identify
* translation files. Setting this property is typically only required if your
* translation files are preprocessed and the original files do not have
* the extension {@code .properties}
* Property {@code fileExtensions} - Specify the file extensions of the files to process.
* Type is {@code java.lang.String[]}.
* Default value is {@code .properties}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* </p>
* <ul>
* <li>
* Property {@code fileExtensions} - Specify file type extension of the files to check.
* Property {@code fileExtensions} - Specify the file extensions of the files to process.
* Type is {@code java.lang.String[]}.
* Default value is {@code .properties}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ public final class SiteUtil {
Map.entry("FileTabCharacterCheck.fileExtensions", VERSION_5_0),
Map.entry("NewlineAtEndOfFileCheck.fileExtensions", "3.1"),
Map.entry("JavadocPackageCheck.fileExtensions", VERSION_5_0),
Map.entry("OrderedPropertiesCheck.fileExtensions", "8.22"),
Map.entry("UniquePropertiesCheck.fileExtensions", VERSION_5_7),
Map.entry("TranslationCheck.fileExtensions", VERSION_3_0),
Map.entry("LineLengthCheck.fileExtensions", V824),
// until https://github.com/checkstyle/checkstyle/issues/14052
Map.entry("JavadocBlockTagLocationCheck.violateExecutionOnNonTightHtml", V824),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<property default-value=".properties"
name="fileExtensions"
type="java.lang.String[]">
<description>Specify file type extension of the files to check.</description>
<description>Specify the file extensions of the files to process.</description>
</property>
</properties>
<message-keys>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
of default translation files in project.
&lt;/p&gt;
&lt;p&gt;
Note: If your project uses preprocessed translation files and the original files do not have the
{@code properties} extension, you can specify additional file extensions
via the {@code fileExtensions} property.
&lt;/p&gt;
&lt;p&gt;
Attention: the check will perform the validation of ISO codes if the option
is used. So, if you specify, for example, "mm" for language code,
TranslationCheck will rise violation that the language code is incorrect.
Expand All @@ -66,10 +71,7 @@
<property default-value=".properties"
name="fileExtensions"
type="java.lang.String[]">
<description>Specify file type extension to identify
translation files. Setting this property is typically only required if your
translation files are preprocessed and the original files do not have
the extension {@code .properties}</description>
<description>Specify the file extensions of the files to process.</description>
</property>
<property default-value=""
name="requiredTranslations"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<property default-value=".properties"
name="fileExtensions"
type="java.lang.String[]">
<description>Specify file type extension of the files to check.</description>
<description>Specify the file extensions of the files to process.</description>
</property>
</properties>
<message-keys>
Expand Down
2 changes: 1 addition & 1 deletion src/xdocs/checks/misc/orderedproperties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</tr>
<tr>
<td>fileExtensions</td>
<td>Specify file type extension of the files to check.</td>
<td>Specify the file extensions of the files to process.</td>
<td><a href="../../property_types.html#String.5B.5D">String[]</a></td>
<td><code>.properties</code></td>
<td>8.22</td>
Expand Down
20 changes: 4 additions & 16 deletions src/xdocs/checks/misc/orderedproperties.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,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 file type extension of the files to check.</td>
<td><a href="../../property_types.html#String.5B.5D">String[]</a></td>
<td><code>.properties</code></td>
<td>8.22</td>
</tr>
</table>
<macro name="properties">
<param name="modulePath"
value="src/main/java/com/puppycrawl/tools/checkstyle/checks/OrderedPropertiesCheck.java"/>
</macro>
</div>
</subsection>

Expand Down
20 changes: 4 additions & 16 deletions src/xdocs/checks/misc/todocomment.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,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>format</td>
<td>Specify pattern to match comments against.</td>
<td><a href="../../property_types.html#Pattern">Pattern</a></td>
<td><code>"TODO:"</code></td>
<td>3.0</td>
</tr>
</table>
<macro name="properties">
<param name="modulePath"
value="src/main/java/com/puppycrawl/tools/checkstyle/checks/TodoCommentCheck.java"/>
</macro>
</div>
</subsection>

Expand Down
3 changes: 1 addition & 2 deletions src/xdocs/checks/misc/trailingcomment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ d = e / f; // Another comment for this line
</tr>
<tr>
<td>legalComment</td>
<td>Define pattern for text allowed in trailing comments. This
pattern will not be applied to multiline comments.</td>
<td>Define pattern for text allowed in trailing comments. This pattern will not be applied to multiline comments.</td>
<td><a href="../../property_types.html#Pattern">Pattern</a></td>
<td><code>null</code></td>
<td>4.2</td>
Expand Down
28 changes: 4 additions & 24 deletions src/xdocs/checks/misc/trailingcomment.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,10 @@ d = e / f; // Another comment for this line

<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>format</td>
<td>Specify pattern for strings allowed before the comment.</td>
<td><a href="../../property_types.html#Pattern">Pattern</a></td>
<td><code>"^[\s});]*$"</code></td>
<td>3.4</td>
</tr>
<tr>
<td>legalComment</td>
<td>Define pattern for text allowed in trailing comments. This
pattern will not be applied to multiline comments.</td>
<td><a href="../../property_types.html#Pattern">Pattern</a></td>
<td><code>null</code></td>
<td>4.2</td>
</tr>
</table>
<macro name="properties">
<param name="modulePath"
value="src/main/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheck.java"/>
</macro>
</div>
</subsection>

Expand Down
24 changes: 10 additions & 14 deletions src/xdocs/checks/misc/translation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ messages.properties: Key 'ok' missing.
one language code) of required translations the check will also check for
existence of default translation files in project.
</p>
<p>
Note: If your project uses preprocessed translation files and the original files
do not have the <code>properties</code> extension,
you can specify additional file extensions
via the <code>fileExtensions</code> property.
</p>
<p>
Attention: the check will perform the validation of ISO codes if the option
is used. So, if you specify, for example, &quot;mm&quot; for language code, TranslationCheck
Expand All @@ -79,32 +85,22 @@ messages.properties: Key 'ok' missing.
</tr>
<tr>
<td>baseName</td>
<td>Specify
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/ResourceBundle.html">
Base name</a> of resource bundles which contain message resources. It helps
the check to distinguish config and localization resources.
</td>
<td>Specify <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/ResourceBundle.html">
Base name</a> of resource bundles which contain message resources. It helps the check to distinguish config and localization resources.</td>
<td><a href="../../property_types.html#Pattern">Pattern</a></td>
<td><code>&quot;^messages.*$&quot;</code></td>
<td>6.17</td>
</tr>
<tr>
<td>fileExtensions</td>
<td>
Specify file type extension to identify translation files. Setting
this property is typically only required if your
translation files are preprocessed and the original files
do not have the extension <code>.properties</code>
</td>
<td>Specify the file extensions of the files to process.</td>
<td><a href="../../property_types.html#String.5B.5D">String[]</a></td>
<td><code>.properties</code></td>
<td>3.0</td>
</tr>
<tr>
<td>requiredTranslations</td>
<td>
Specify language codes of required translations which must exist in project.
</td>
<td>Specify language codes of required translations which must exist in project.</td>
<td><a href="../../property_types.html#String.5B.5D">String[]</a></td>
<td><code>{}</code></td>
<td>6.11</td>
Expand Down
51 changes: 10 additions & 41 deletions src/xdocs/checks/misc/translation.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ messages.properties: Key 'ok' missing.
one language code) of required translations the check will also check for
existence of default translation files in project.
</p>
<p>
Note: If your project uses preprocessed translation files and the original files
do not have the <code>properties</code> extension,
you can specify additional file extensions
via the <code>fileExtensions</code> property.
</p>
<p>
Attention: the check will perform the validation of ISO codes if the option
is used. So, if you specify, for example, "mm" for language code, TranslationCheck
Expand All @@ -69,47 +75,10 @@ messages.properties: Key 'ok' missing.

<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>baseName</td>
<td>Specify
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/ResourceBundle.html">
Base name</a> of resource bundles which contain message resources. It helps
the check to distinguish config and localization resources.
</td>
<td><a href="../../property_types.html#Pattern">Pattern</a></td>
<td><code>"^messages.*$"</code></td>
<td>6.17</td>
</tr>
<tr>
<td>fileExtensions</td>
<td>
Specify file type extension to identify translation files. Setting
this property is typically only required if your
translation files are preprocessed and the original files
do not have the extension <code>.properties</code>
</td>
<td><a href="../../property_types.html#String.5B.5D">String[]</a></td>
<td><code>.properties</code></td>
<td>3.0</td>
</tr>
<tr>
<td>requiredTranslations</td>
<td>
Specify language codes of required translations which must exist in project.
</td>
<td><a href="../../property_types.html#String.5B.5D">String[]</a></td>
<td><code>{}</code></td>
<td>6.11</td>
</tr>
</table>
<macro name="properties">
<param name="modulePath"
value="src/main/java/com/puppycrawl/tools/checkstyle/checks/TranslationCheck.java"/>
</macro>
</div>
</subsection>

Expand Down
3 changes: 1 addition & 2 deletions src/xdocs/checks/misc/uncommentedmain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
</tr>
<tr>
<td>excludedClasses</td>
<td>Specify pattern for qualified names of classes which are allowed
to have a <code>main</code> method.</td>
<td>Specify pattern for qualified names of classes which are allowed to have a <code>main</code> method.</td>
<td><a href="../../property_types.html#Pattern">Pattern</a></td>
<td><code>&quot;^$&quot;</code></td>
<td>3.2</td>
Expand Down
21 changes: 4 additions & 17 deletions src/xdocs/checks/misc/uncommentedmain.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,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>excludedClasses</td>
<td>Specify pattern for qualified names of classes which are allowed
to have a <code>main</code> method.</td>
<td><a href="../../property_types.html#Pattern">Pattern</a></td>
<td><code>"^$"</code></td>
<td>3.2</td>
</tr>
</table>
<macro name="properties">
<param name="modulePath"
value="src/main/java/com/puppycrawl/tools/checkstyle/checks/UncommentedMainCheck.java"/>
</macro>
</div>
</subsection>

Expand Down
2 changes: 1 addition & 1 deletion src/xdocs/checks/misc/uniqueproperties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</tr>
<tr>
<td>fileExtensions</td>
<td>Specify file type extension of the files to check.</td>
<td>Specify the file extensions of the files to process.</td>
<td><a href="../../property_types.html#String.5B.5D">String[]</a></td>
<td><code>.properties</code></td>
<td>5.7</td>
Expand Down
Loading

0 comments on commit e449968

Please sign in to comment.