From d7f97f34021bab6e5027a947eabbcd40300d4567 Mon Sep 17 00:00:00 2001 From: Roman Ivanov Date: Wed, 27 Dec 2023 06:41:56 -0800 Subject: [PATCH] Issue #13693: migrate regexp checks to property macro --- ...checkstyle-non-main-files-suppressions.xml | 12 ---- .../checks/regexp/RegexpOnFilenameCheck.java | 4 +- .../tools/checkstyle/site/SiteUtil.java | 5 +- .../checks/regexp/RegexpOnFilenameCheck.xml | 4 +- src/xdocs/checks/regexp/regexp.xml | 8 +-- src/xdocs/checks/regexp/regexp.xml.template | 59 ++--------------- src/xdocs/checks/regexp/regexpmultiline.xml | 3 +- .../regexp/regexpmultiline.xml.template | 63 ++----------------- src/xdocs/checks/regexp/regexponfilename.xml | 6 +- .../regexp/regexponfilename.xml.template | 50 ++------------- src/xdocs/checks/regexp/regexpsingleline.xml | 3 +- .../regexp/regexpsingleline.xml.template | 56 ++--------------- .../checks/regexp/regexpsinglelinejava.xml | 3 +- .../regexp/regexpsinglelinejava.xml.template | 56 ++--------------- 14 files changed, 33 insertions(+), 299 deletions(-) diff --git a/config/checkstyle-non-main-files-suppressions.xml b/config/checkstyle-non-main-files-suppressions.xml index cd4a1ef5b42..ca320a30aea 100644 --- a/config/checkstyle-non-main-files-suppressions.xml +++ b/config/checkstyle-non-main-files-suppressions.xml @@ -347,18 +347,6 @@ files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]recordcomponentname.xml.template"/> - - - - - - diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpOnFilenameCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpOnFilenameCheck.java index 5a84cb10618..7ed16f72240 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpOnFilenameCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpOnFilenameCheck.java @@ -72,9 +72,7 @@ *

*
    *
  • - * 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 ""}.
  • *
  • diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java b/src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java index 66640f2eaea..4c01b39acd3 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java @@ -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. */ diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpOnFilenameCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpOnFilenameCheck.xml index 3920a70dd56..89ea36b2359 100644 --- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpOnFilenameCheck.xml +++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpOnFilenameCheck.xml @@ -46,9 +46,7 @@ </p> - 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. + Specify the file type extension of files to process. Specify the regular expression to match the file name against. diff --git a/src/xdocs/checks/regexp/regexp.xml b/src/xdocs/checks/regexp/regexp.xml index 45c571ffa4b..2b3849a8b2e 100644 --- a/src/xdocs/checks/regexp/regexp.xml +++ b/src/xdocs/checks/regexp/regexp.xml @@ -68,10 +68,7 @@ duplicateLimit - 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. + 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. int 0 4.0 @@ -106,8 +103,7 @@ message - Specify message which is used to notify about violations, - if empty then the default (hard-coded) message is used. + Specify message which is used to notify about violations, if empty then the default (hard-coded) message is used. String null 4.0 diff --git a/src/xdocs/checks/regexp/regexp.xml.template b/src/xdocs/checks/regexp/regexp.xml.template index c360c8bbb12..ec41d7f2b09 100644 --- a/src/xdocs/checks/regexp/regexp.xml.template +++ b/src/xdocs/checks/regexp/regexp.xml.template @@ -58,61 +58,10 @@
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    namedescriptiontypedefault valuesince
    duplicateLimitControl 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.int04.0
    errorLimitSpecify the maximum number of violations before the check will abort.int1004.0
    formatSpecify the pattern to match against.Pattern"^$"4.0
    ignoreCommentsControl whether to ignore matches found within comments.booleanfalse4.0
    illegalPatternControl whether the pattern is required or illegal.booleanfalse4.0
    messageSpecify message which is used to notify about violations, - if empty then the default (hard-coded) message is used.Stringnull4.0
    + + +
    diff --git a/src/xdocs/checks/regexp/regexpmultiline.xml b/src/xdocs/checks/regexp/regexpmultiline.xml index 86eeeeec6f3..49f59bb8fe5 100644 --- a/src/xdocs/checks/regexp/regexpmultiline.xml +++ b/src/xdocs/checks/regexp/regexpmultiline.xml @@ -67,8 +67,7 @@ message - Specify the message which is used to notify about violations, - if empty then default (hard-coded) message is used. + Specify the message which is used to notify about violations, if empty then default (hard-coded) message is used. String null 5.0 diff --git a/src/xdocs/checks/regexp/regexpmultiline.xml.template b/src/xdocs/checks/regexp/regexpmultiline.xml.template index e2a317ffb3f..d232334b3e7 100644 --- a/src/xdocs/checks/regexp/regexpmultiline.xml.template +++ b/src/xdocs/checks/regexp/regexpmultiline.xml.template @@ -22,65 +22,10 @@
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    namedescriptiontypedefault valuesince
    fileExtensionsSpecify the file type extension of files to process.String[]all files5.0
    formatSpecify the format of the regular expression to match.Pattern"$."5.0
    ignoreCaseControl whether to ignore case when searching.booleanfalse5.0
    matchAcrossLinesControl whether to match expressions across multiple lines.booleanfalse8.25
    maximumSpecify the maximum number of matches required in each file.int05.0
    messageSpecify the message which is used to notify about violations, - if empty then default (hard-coded) message is used.Stringnull5.0
    minimumSpecify the minimum number of matches required in each file.int05.0
    + + +
    diff --git a/src/xdocs/checks/regexp/regexponfilename.xml b/src/xdocs/checks/regexp/regexponfilename.xml index b6c7f1e79dd..c254546f7f6 100644 --- a/src/xdocs/checks/regexp/regexponfilename.xml +++ b/src/xdocs/checks/regexp/regexponfilename.xml @@ -61,8 +61,7 @@ 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. + Specify the file type extension of files to process. String[] all files 6.15 @@ -90,8 +89,7 @@ match - 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. + 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. boolean true 6.15 diff --git a/src/xdocs/checks/regexp/regexponfilename.xml.template b/src/xdocs/checks/regexp/regexponfilename.xml.template index cc3370cf87a..a75da1bea2b 100644 --- a/src/xdocs/checks/regexp/regexponfilename.xml.template +++ b/src/xdocs/checks/regexp/regexponfilename.xml.template @@ -51,52 +51,10 @@
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    namedescriptiontypedefault valuesince
    fileExtensionsSpecify 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.String[]all files6.15
    fileNamePatternSpecify the regular expression to match the file name against.Patternnull6.15
    folderPatternSpecify the regular expression to match the folder path against.Patternnull6.15
    ignoreFileNameExtensionsControl whether to ignore the file extension for the file name match.booleanfalse6.15
    matchControl whether to look for a match or mismatch on the file name, if the - fileNamePattern is supplied, otherwise it is applied on the folderPattern.booleantrue6.15
    + + +
    diff --git a/src/xdocs/checks/regexp/regexpsingleline.xml b/src/xdocs/checks/regexp/regexpsingleline.xml index 3eafdd45d8c..52a3d7074b5 100644 --- a/src/xdocs/checks/regexp/regexpsingleline.xml +++ b/src/xdocs/checks/regexp/regexpsingleline.xml @@ -60,8 +60,7 @@ message - Specify the message which is used to notify about violations, - if empty then default (hard-coded) message is used. + Specify the message which is used to notify about violations, if empty then default (hard-coded) message is used. String null 5.0 diff --git a/src/xdocs/checks/regexp/regexpsingleline.xml.template b/src/xdocs/checks/regexp/regexpsingleline.xml.template index 0bc321ed406..0f3632d0d29 100644 --- a/src/xdocs/checks/regexp/regexpsingleline.xml.template +++ b/src/xdocs/checks/regexp/regexpsingleline.xml.template @@ -22,58 +22,10 @@
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    namedescriptiontypedefault valuesince
    fileExtensionsSpecify the file type extension of files to process.String[]all files5.0
    formatSpecify the format of the regular expression to match.Pattern"$."5.0
    ignoreCaseControl whether to ignore case when searching.booleanfalse5.0
    maximumSpecify the maximum number of matches required in each file.int05.0
    messageSpecify the message which is used to notify about violations, - if empty then default (hard-coded) message is used.Stringnull5.0
    minimumSpecify the minimum number of matches required in each file.int05.0
    + + +
    diff --git a/src/xdocs/checks/regexp/regexpsinglelinejava.xml b/src/xdocs/checks/regexp/regexpsinglelinejava.xml index b373dedf2f0..01163838fae 100644 --- a/src/xdocs/checks/regexp/regexpsinglelinejava.xml +++ b/src/xdocs/checks/regexp/regexpsinglelinejava.xml @@ -60,8 +60,7 @@ message - Specify the message which is used to notify about violations, - if empty then default (hard-coded) message is used. + Specify the message which is used to notify about violations, if empty then default (hard-coded) message is used. String null 6.0 diff --git a/src/xdocs/checks/regexp/regexpsinglelinejava.xml.template b/src/xdocs/checks/regexp/regexpsinglelinejava.xml.template index 6aff205b64d..8de117a292a 100644 --- a/src/xdocs/checks/regexp/regexpsinglelinejava.xml.template +++ b/src/xdocs/checks/regexp/regexpsinglelinejava.xml.template @@ -22,58 +22,10 @@
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    namedescriptiontypedefault valuesince
    formatSpecify the format of the regular expression to match.Pattern"$."5.0
    ignoreCaseControl whether to ignore case when searching.booleanfalse5.0
    ignoreCommentsControl whether to ignore text in comments when searching.booleanfalse5.0
    maximumSpecify the maximum number of matches required in each file.int05.0
    messageSpecify the message which is used to notify about violations, - if empty then default (hard-coded) message is used.Stringnull6.0
    minimumSpecify the minimum number of matches required in each file.int05.0
    + + +