Skip to content

Commit

Permalink
Issue checkstyle#13693: migrate all naming modules to property macros
Browse files Browse the repository at this point in the history
  • Loading branch information
romani committed Jan 5, 2024
1 parent a379ad8 commit 81c4580
Show file tree
Hide file tree
Showing 65 changed files with 281 additions and 850 deletions.
29 changes: 0 additions & 29 deletions config/checkstyle-non-main-files-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,35 +265,6 @@
files="src[\\/]xdocs[\\/]checks[\\/]misc[\\/]uncommentedmain.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]misc[\\/]uniqueproperties.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]constantname.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]illegalidentifiername.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]interfacetypeparametername.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]lambdaparametername.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]localfinalvariablename.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]localvariablename.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]membername.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]methodname.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]methodtypeparametername.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]packagename.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]parametername.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]patternvariablename.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]recordcomponentname.xml.template"/>
<suppress id="propertiesMacroMustExist"
files="src[\\/]xdocs[\\/]checks[\\/]naming[\\/]recordtypeparametername.xml.template"/>


<!-- no properties by design -->
<suppress id="propertiesMacroMustExist"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private static boolean isPublic(DetailAST modifiers) {
}

/**
* Setter to control whether we should apply the check to public members.
* Setter to control if check should apply to public members.
*
* @param applyTo new value of the property.
*/
Expand All @@ -122,7 +122,7 @@ public void setApplyToPublic(boolean applyTo) {
}

/**
* Setter to control whether we should apply the check to protected members.
* Setter to control if check should apply to protected members.
*
* @param applyTo new value of the property.
*/
Expand All @@ -131,7 +131,7 @@ public void setApplyToProtected(boolean applyTo) {
}

/**
* Setter to control whether we should apply the check to package-private members.
* Setter to control if check should apply to package-private members.
*
* @param applyTo new value of the property.
*/
Expand All @@ -140,7 +140,7 @@ public void setApplyToPackage(boolean applyTo) {
}

/**
* Setter to control whether we should apply the check to private members.
* Setter to control if check should apply to private members.
*
* @param applyTo new value of the property.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@
* </p>
* <ul>
* <li>
* Property {@code applyToPackage} - Controls whether to apply the check to package-private member.
* Property {@code applyToPackage} - Control if check should apply to package-private members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToPrivate} - Controls whether to apply the check to private member.
* Property {@code applyToPrivate} - Control if check should apply to private members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToProtected} - Controls whether to apply the check to protected member.
* Property {@code applyToProtected} - Control if check should apply to protected members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToPublic} - Controls whether to apply the check to public member.
* Property {@code applyToPublic} - Control if check should apply to public members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Sets the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* </p>
* <ul>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Sets the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "(?i)^(?!(record|yield|var|permits|sealed|_)$).+$"}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* </p>
* <ul>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Sets the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[A-Z]$"}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* </p>
* <ul>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Sets the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* </p>
* <ul>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Sets the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* Default value is {@code false}.
* </li>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Sets the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@
* </p>
* <ul>
* <li>
* Property {@code applyToPackage} - Controls whether to apply the check to package-private member.
* Property {@code applyToPackage} - Control if check should apply to package-private members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToPrivate} - Controls whether to apply the check to private member.
* Property {@code applyToPrivate} - Control if check should apply to private members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToProtected} - Controls whether to apply the check to protected member.
* Property {@code applyToProtected} - Control if check should apply to protected members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToPublic} - Controls whether to apply the check to public member.
* Property {@code applyToPublic} - Control if check should apply to public members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Sets the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,34 @@
*
* <ul>
* <li>
* Property {@code allowClassName} - Controls whether to allow a method name to have the same name
* as the residing class name. This is not to be confused with a constructor. An easy mistake is
* to place a return type on a constructor declaration which turns it into a method. For example:
* <pre>
* class MyClass {
* public void MyClass() {} //this is a method
* public MyClass() {} //this is a constructor
* }
* </pre>
* Property {@code allowClassName} - Control whether to allow a method name to have the same name
* as the enclosing class name. Setting this property {@code false} helps to avoid
* confusion between constructors and methods.
* Type is {@code boolean}.
* Default value is {@code false}.
* </li>
* <li>
* Property {@code applyToPackage} - Controls whether to apply the check to package-private member.
* Property {@code applyToPackage} - Control if check should apply to package-private members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToPrivate} - Controls whether to apply the check to private member.
* Property {@code applyToPrivate} - Control if check should apply to private members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToProtected} - Controls whether to apply the check to protected member.
* Property {@code applyToProtected} - Control if check should apply to protected members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToPublic} - Controls whether to apply the check to public member.
* Property {@code applyToPublic} - Control if check should apply to public members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Sets the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
* </li>
Expand Down Expand Up @@ -103,15 +97,9 @@ public class MethodNameCheck
public static final String MSG_KEY = "method.name.equals.class.name";

/**
* Controls whether to allow a method name to have the same name as the residing class name.
* This is not to be confused with a constructor. An easy mistake is to place a return type on
* a constructor declaration which turns it into a method. For example:
* <pre>
* class MyClass {
* public void MyClass() {} //this is a method
* public MyClass() {} //this is a constructor
* }
* </pre>
* Control whether to allow a method name to have the same name as the enclosing class name.
* Setting this property {@code false} helps to avoid confusion
* between constructors and methods.
*/
private boolean allowClassName;

Expand Down Expand Up @@ -164,15 +152,9 @@ public void visitToken(DetailAST ast) {
}

/**
* Setter to controls whether to allow a method name to have the same name as the residing
* class name. This is not to be confused with a constructor. An easy mistake is to place
* a return type on a constructor declaration which turns it into a method. For example:
* <pre>
* class MyClass {
* public void MyClass() {} //this is a method
* public MyClass() {} //this is a constructor
* }
* </pre>
* Setter to control whether to allow a method name to have the same name
* as the enclosing class name. Setting this property {@code false}
* helps to avoid confusion between constructors and methods.
*
* @param allowClassName true to allow false to disallow
* @since 5.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* </p>
* <ul>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Sets the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[A-Z]$"}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* </p>
* <ul>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Control the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[a-z]+(\.[a-zA-Z_]\w*)*$"}.
* </li>
Expand Down Expand Up @@ -71,14 +71,14 @@ public class PackageNameCheck
*/
public static final String MSG_KEY = "name.invalidPattern";

/** Specifies valid identifiers. */
/** Control the pattern to match valid identifiers. */
// Uppercase letters seem rather uncommon, but they're allowed in
// https://docs.oracle.com/javase/specs/
// second_edition/html/packages.doc.html#40169
private Pattern format = Pattern.compile("^[a-z]+(\\.[a-zA-Z_]\\w*)*$");

/**
* Setter to specifies valid identifiers.
* Setter to control the pattern to match valid identifiers.
*
* @param pattern the new pattern
* @since 3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* Default value is {@code public, protected, package, private}.
* </li>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Sets the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* </p>
* <ul>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Sets the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* </p>
* <ul>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Sets the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* </p>
* <ul>
* <li>
* Property {@code format} - Specifies valid identifiers.
* Property {@code format} - Sets the pattern to match valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[A-Z]$"}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@
* </p>
* <ul>
* <li>
* Property {@code applyToPackage} - Control whether we should apply the check to package-private
* Property {@code applyToPackage} - Control if check should apply to package-private
* members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToPrivate} - Control whether we should apply the check to private members.
* Property {@code applyToPrivate} - Control if check should apply to private members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToProtected} - Control whether we should apply the check to protected
* Property {@code applyToProtected} - Control if check should apply to protected
* members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToPublic} - Control whether we should apply the check to public members.
* Property {@code applyToPublic} - Control if check should apply to public members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@
* </p>
* <ul>
* <li>
* Property {@code applyToPackage} - Control whether we should apply the check to package-private
* Property {@code applyToPackage} - Control if check should apply to package-private
* members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToPrivate} - Control whether we should apply the check to private members.
* Property {@code applyToPrivate} - Control if check should apply to private members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToProtected} - Control whether we should apply the check to protected
* Property {@code applyToProtected} - Control if check should apply to protected
* members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
* <li>
* Property {@code applyToPublic} - Control whether we should apply the check to public members.
* Property {@code applyToPublic} - Control if check should apply to public members.
* Type is {@code boolean}.
* Default value is {@code true}.
* </li>
Expand Down
Loading

0 comments on commit 81c4580

Please sign in to comment.