- * To configure filter to suppress audit events for annotations add:
- *
- *
- * <module name="SuppressWarningsFilter" />
- *
- *
- * @SuppressWarnings({"memberName"})
- * private int J; // should NOT fail MemberNameCheck
- *
- * @SuppressWarnings({"MemberName"})
- * @SuppressWarnings({"NoWhitespaceAfter"})
- * private int [] ARRAY; // should NOT fail MemberNameCheck and NoWhitespaceAfterCheck
- *
- *
- * It is possible to specify an ID of checks, so that it can be leveraged by
- * the SuppressWarningsFilter to skip validations. The following examples show how to
- * skip validations near code that has {@code @SuppressWarnings("checkstyle:<ID>")}
- * or just {@code @SuppressWarnings("<ID>")} annotation, where ID is the ID
- * of checks you want to suppress.
- *
- *
- * Example of Checkstyle check configuration:
- *
- * public static final int lowerCaseConstant; // CHECKSTYLE IGNORE THIS LINE
- *
- *
- * To configure a filter so that {@code // OK to catch (Throwable|Exception|RuntimeException) here}
- * permits the current and previous line to avoid generating an IllegalCatch audit event:
- *
- * To configure a filter so that {@code CHECKSTYLE IGNORE check FOR NEXT
- * var LINES} avoids triggering any audits for the given check for
- * the current line and the next var lines (for a total of var+1 lines):
- *
- * static final int lowerCaseConstant; // CHECKSTYLE IGNORE ConstantNameCheck FOR NEXT 3 LINES
- * static final int lowerCaseConstant1;
- * static final int lowerCaseConstant2;
- * static final int lowerCaseConstant3;
- * static final int lowerCaseConstant4; // will warn here
- *
- *
- * To configure a filter to avoid any audits on code like:
- *
- * public static final int [] array; // @cs.suppress [ConstantName|NoWhitespaceAfter] A comment here
- *
- *
- * It is possible to specify an ID of checks, so that it can be leveraged by
- * the SuppressWithNearbyCommentFilter to skip validations. The following examples show how to skip
- * validations near code that has comment like {@code // @cs-: <ID/> (reason)},
- * where ID is the ID of checks you want to suppress.
- *
- *
- * Examples of Checkstyle checks configuration:
- *
- * Example of SuppressWithNearbyCommentFilter configuration (idFormat which is set to
- * '$1' points that ID of the checks is in the first group of commentFormat regular expressions):
- *
- * // @cs-: ClassDataAbstractionCoupling influence 2
- * // @cs-: MagicNumber influence 4
- * @Service // no violations from ClassDataAbstractionCoupling here
- * @Transactional
- * public class UserService {
- * private int value = 10022; // no violations from MagicNumber here
- * }
- *
- *
* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker}
*
- * int a = 42; // DO NOT CHECK THIS LINE
- * int b = 43; // violation
- *
- *
- * To configure the filter to suppress audit events whose check message contains
- * the word {@code Line}. In this case, {@code LineLengthCheck}'s violation message
- * contains it:
- *
- * int a = 42; // SUPPRESS CHECKSTYLE because i want to
- * static final int LONG_VAR_NAME_TO_TAKE_MORE_THAN_55_CHARS = 22; // LineLength violation
- *
- *
- * To configure the filter to suppress audit events for the current and next 2 lines:
- *
- * To configure a filter to suppress audit events between a comment containing
- * {@code CHECKSTYLE:OFF} and a comment containing {@code CHECKSTYLE:ON}:
- *
- * To configure a filter to suppress audit events between a comment containing
- * line {@code BEGIN GENERATED CONTENT} and a comment containing line
- * {@code END GENERATED CONTENT}(Checker is configured to check only properties files):
- *
- * //BEGIN GENERATED CONTENT
- * my.property=value1 // No violation events will be reported
- * my.property=value2 // No violation events will be reported
- * //END GENERATED CONTENT
- * . . .
- *
- *
- * To configure a filter so that {@code -- stop tab check} and {@code -- resume tab check}
- * marks allowed tab positions (Checker is configured to check only sql files):
- *
- * -- stop tab check
- * SELECT * FROM users // won't warn here if there is a tab character on line
- * -- resume tab check
- * SELECT 1 // will warn here if there is a tab character on line
- *
- *
- * To configure a filter so that name of suppressed check mentioned in comment
- * {@code CSOFF: regexp} and {@code CSON: regexp} mark a matching
- * check (Checker is configured to check only xml files):
- *
- * // CSOFF: RegexpSinglelineCheck
- * // RegexpSingleline check won't warn any lines below here if the line matches regexp
- * <condition property="checkstyle.ant.skip">
- * <isset property="checkstyle.ant.skip"/>
- * </condition>
- * // CSON: RegexpSinglelineCheck
- * // RegexpSingleline check will warn below here if the line matches regexp
- * <property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/>
- *
- *
- * To configure a filter to suppress all audit events between a comment containing
- * {@code CHECKSTYLE_OFF: ALMOST_ALL} and a comment containing {@code CHECKSTYLE_OFF: ALMOST_ALL}
- * except for the EqualsHashCode check (Checker is configured to check only java files):
- *
- * // CHECKSTYLE_OFF: ALMOST_ALL
- * public static final int array [];
- * private String [] strArray;
- * // CHECKSTYLE_ON: ALMOST_ALL
- * private int array1 [];
- *
- *
- * To configure a filter to suppress Check's violation message which matches
- * specified message in messageFormat(so suppression will not be only by
- * Check's name, but also by message text, as the same Check can report violations
- * with different message format) between a comment containing {@code stop} and
- * comment containing {@code resume}:
- *
- * It is possible to specify an ID of checks, so that it can be leveraged by the
- * SuppressWithPlainTextCommentFilter to skip validations. The following examples
- * show how to skip validations near code that is surrounded with
- * {@code -- CSOFF <ID> (reason)} and {@code -- CSON <ID>},
- * where ID is the ID of checks you want to suppress.
- *
- *
- * Examples of Checkstyle checks configuration:
- *
- * Example of SuppressWithPlainTextCommentFilter configuration (checkFormat which
- * is set to '$1' points that ID of the checks is in the first group of offCommentFormat
- * and onCommentFormat regular expressions):
- *
- * To configure a filter to suppress audit events (MemberNameCheck,
- * ConstantNameCheck and IllegalCatchCheck have been taken here for reference)
- * between a comment containing {@code CHECKSTYLE:OFF} and a comment
- * containing {@code CHECKSTYLE:ON}:
- *
- * class InputSuppressionCommentFilter
- * {
- * int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *
- * //stop constant check
- * int VAR2; // violation , Name 'VAR2' must match pattern '^[a-z][a-zA-Z0-9]*$'
- * //resume constant check
- *
- * public static final int var3;
- * // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *
- * //stop constant check
- * public static final int var4; // suppressed violation
- * //resume constant check
- *
- * public void method1()
- * {
- * try {}
- * catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- *
- * //stop constant check
- *
- * try {}
- * catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- * catch(Error err) {} // violation , Catching 'Error' is not allowed
- *
- * //resume constant check
- * }
- * }
- *
- *
- * To configure a filter so that {@code UNUSED OFF: var} and
- * {@code UNUSED ON: var} marks a variable or parameter known not to be
- * used by the code by matching the variable name in the message through a
- * specified message in messageFormat:
- *
- * class InputSuppressionCommentFilter
- * {
- * int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *
- * //ILLEGAL OFF: Exception
- * int VAR2; // violation , Name 'VAR2' must match pattern '^[a-z][a-zA-Z0-9]*$'
- * //ILLEGAL ON: Exception
- *
- * public static final int var3;
- * // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *
- * //ILLEGAL OFF: Exception
- * public static final int var4;
- * // violation above , Name 'var4' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- * //ILLEGAL ON: Exception
- *
- * public void method1()
- * {
- * try {}
- * catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- *
- * //ILLEGAL OFF: Exception
- *
- * try {}
- * catch(Exception ex) {} // suppressed violation
- * catch(Error err) {} // violation , Catching 'Error' is not allowed
- *
- * //ILLEGAL ON: Exception
- * }
- * }
- *
- *
- * To configure a filter so that name of suppressed check mentioned in comment
- * {@code CSOFF: regexp} and {@code CSON: regexp} mark a matching check:
- *
- * class InputSuppressionCommentFilter
- * {
- * int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *
- * //CSOFF: MemberName
- * int VAR2; // suppressed violation
- * //CSON: MemberName
- *
- * public static final int var3;
- * // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *
- * //CSOFF: ConstantName
- * public static final int var4; // suppressed violation
- * //CSON: ConstantName
- *
- * public void method1()
- * {
- * try {}
- * catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- *
- * //CSOFF: IllegalCatch
- *
- * try {}
- * catch(Exception ex) {} // suppressed violation
- * catch(Error err) {} // suppressed violation
- *
- * //CSON: IllegalCatch
- * }
- * }
- *
- *
- * To configure a filter to suppress all audit events between a comment containing
- * {@code CHECKSTYLE_OFF: ALMOST_ALL} and a comment containing
- * {@code CHECKSTYLE_OFF: ALMOST_ALL} except for the ConstantName check:
- *
- * class InputSuppressionCommentFilter
- * {
- * int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *
- * //CHECKSTYLE_OFF: ALMOST_ALL
- * int VAR2; // suppressed violation
- * //CHECKSTYLE_ON: ALMOST_ALL
- *
- * public static final int var3;
- * // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *
- * //CHECKSTYLE_OFF: ALMOST_ALL
- * public static final int var4;
- * // violation above , Name 'var4' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- * //CHECKSTYLE_ON: ALMOST_ALL
- *
- * public void method1()
- * {
- * try {}
- * catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- *
- * //CHECKSTYLE_OFF: ALMOST_ALL
- *
- * try {}
- * catch(Exception ex) {} // suppressed violation
- * catch(Error err) {} // suppressed violation
- *
- * //CHECKSTYLE_ON: ALMOST_ALL
- * }
- * }
- *
- *
- * It is possible to specify an ID of checks, so that it can be leveraged by the
- * SuppressionCommentFilter to skip validations. The following examples show how
- * to skip validations near code that is surrounded with {@code // CSOFF <ID>}
- * and {@code // CSON <ID>}, where ID is the ID of checks you want to suppress.
- * In the config of SuppressionCommentFilter, checkFormat is set to '$1' which points
- * to the ID written in the offCommentFormat and onCommentFormat. Config for such a
- * case is written below:
- *
- * For example, the following configuration fragment directs the Checker to use
- * a {@code SuppressionFilter} with suppressions file {@code config/suppressions.xml}:
- *
- * The following suppressions XML document directs a {@code SuppressionFilter} to
- * reject {@code JavadocStyleCheck} violations for lines 82 and 108 to 122 of file
- * {@code AbstractComplexityCheck.java}, and {@code MagicNumberCheck} violations for
- * line 221 of file {@code JavadocStyleCheck.java}, and
- * {@code 'Missing a Javadoc comment'} violations for all lines and files:
- *
- * The following suppressions directs a {@code SuppressionSingleFilter} to reject
- * {@code JavadocStyleCheck} violations for lines 82 and 108 to 122 of file
- * {@code AbstractComplexityCheck.java}, and
- * {@code MagicNumberCheck} violations for line 221 of file
- * {@code JavadocStyleCheck.java}, and {@code 'Missing a Javadoc comment'} violations for all lines
- * and files:
- *
- * For example, the following configuration fragment directs the Checker to use a
- * {@code SuppressionXpathFilter} with suppressions file {@code config/suppressions.xml}:
- *
- * A
- * suppressions XML document
- * contains a set of {@code suppress} and {@code suppress-xpath} elements,
- * where each {@code suppress-xpath} element can have the following attributes:
- *
- *
- *
- * {@code files} - a Pattern
- * matched against the file name associated with an audit event. It is optional.
- *
- *
- * {@code checks} - a Pattern
- * matched against the name of the check associated with an audit event.
- * Optional as long as {@code id} or {@code message} is specified.
- *
- *
- * {@code message} - a Pattern
- * matched against the message of the check associated with an audit event.
- * Optional as long as {@code checks} or {@code id} is specified.
- *
- *
- * {@code id} - a String matched against
- * the ID of the check associated with an audit event.
- * Optional as long as {@code checks} or {@code message} is specified.
- *
- *
- * {@code query} - a String xpath query. It is optional.
- *
- *
- *
- * Each audit event is checked against each {@code suppress} and {@code suppress-xpath} element.
- * It is suppressed if all specified attributes match against the audit event.
- *
- *
- * ATTENTION: filtering by message is dependent on runtime locale.
- * If project is running in different languages it is better to avoid filtering by message.
- *
- *
- * The following suppressions XML document directs a {@code SuppressionXpathFilter} to reject
- * {@code CyclomaticComplexity} violations for all methods with name sayHelloWorld inside
- * FileOne and FileTwo files:
- *
- *
- * Currently, xpath queries support one type of attribute {@code @text}. {@code @text} -
- * addresses to the text value of the node. For example: variable name, annotation name,
- * text content, etc. Only the following token types support {@code @text} attribute:
- * {@code TokenTypes.IDENT}, {@code TokenTypes.STRING_LITERAL}, {@code TokenTypes.CHAR_LITERAL},
- * {@code TokenTypes.NUM_LONG}, {@code TokenTypes.NUM_INT}, {@code TokenTypes.NUM_DOUBLE},
- * {@code TokenTypes.NUM_FLOAT}.
- * These token types were selected because only their text values are different
- * in content from token type and represent text value from file and can be used
- * in xpath queries for more accurate results. Other token types always have constant values.
- *
- * In the following sample, violations for {@code LeftCurly} check will be suppressed
- * for classes with name Main or for methods with name calculate.
- *
- * public class InputTest {
- * private int age = 23;
- *
- * public void changeAge() {
- * age = 24; //violation will be suppressed
- * }
- * }
- *
- *
- * Suppress {@code IllegalThrows} violations only for methods with name throwsMethod
- * and only for {@code RuntimeException} exceptions. Double colon is used for axis iterations.
- * In the following example {@code ancestor} axis is used to iterate all ancestor nodes
- * of the current node with type {@code METHOD_DEF} and name throwsMethod.
- * Please read more about xpath axes at
- * W3Schools Xpath Axes.
- *
- * public class InputTest {
- * public void throwsMethod() throws RuntimeException { // violation will be suppressed
- * }
- *
- * public void sampleMethod() throws RuntimeException { // will throw violation here
- * }
- * }
- *
- *
- * The following sample demonstrates how to suppress all violations for method
- * itself and all descendants. {@code descendant-or-self} axis iterates through
- * current node and all children nodes at any level. Keyword {@code node()}
- * selects node elements. Please read more about xpath syntax at
- * W3Schools Xpath Syntax.
- *
- * The easiest way is to suppress by variable name. As you can see {@code VARIABLE_DEF}
- * node refers to variable declaration statement and has child node with token type
- * {@code IDENT} which is used for storing class, method, variable names.
- *
- *
- * The following example demonstrates how variable can be queried by its name:
- *
- * Another way is to suppress by variable value. Again, if you look at the printed
- * AST tree above, you will notice that one of the grandchildren of {@code VARIABLE_DEF}
- * node is responsible for storing variable value -{@code NUM_INT} with value 11.
- *
- *
- * The following example demonstrates how variable can be queried by its value,
- * same approach applies to {@code String, char, float, double, int, long} data types:
- *
- * The problem with query above that it will suppress violations for all methods
- * with annotation {@code @Generated}. In order to suppress methods with
- * {@code @Generated("second")} annotations only, you need to look at AST tree again.
- * Value of the {@code ANNOTATION} node is stored inside sub-node with token type
- * {@code STRING_LITERAL}. Use the following query to suppress methods with
- * {@code @Generated("second")} annotation:
- *
- * public class FileOne {
- * public void MyMethod() {} // OK
- * }
- *
- * public class FileTwo {
- * public void MyMethod() {} // OK
- * }
- *
- * public class FileThree {
- * public void MyMethod() {} // violation, name 'MyMethod'
- * // must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- * }
- *
- *
- * To suppress MethodName check for method names matched pattern 'MyMethod[0-9]':
- *
- * public class FileOne {
- * public void MyMethod1() {} // OK
- * public void MyMethod2() {} // OK
- * public void MyMethodA() {} // violation, name 'MyMethodA' must
- * // match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- * }
- *
- *
- * To suppress checks being specified by id property:
- *
- * public class FileOne {
- * public void MyMethod() {} // OK
- * }
- * public class FileTwo {
- * public void MyMethod() {} // violation, name 'MyMethod' must
- * //match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- * }
- *
- *
- * To suppress checks for all package definitions:
- *
- * public class FileOne {
- * public void MyMethod() {} // OK
- * }
- *
- * public class FileTwo {
- * public void MyMethod() {} // violation, name 'MyMethod'
- * // must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- * }
- *
- *
- * Suppress checks for elements which are either class definitions, either method definitions:
- *
- * abstract class FileOne { // OK
- * public void MyMethod() {} // OK
- * }
- *
- * abstract class FileTwo { // violation of the AbstractClassName check,
- * // it should match the pattern "^Abstract.+$"
- * public void MyMethod() {} // violation, name 'MyMethod'
- * // must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- * }
- *
- *
- * Suppress checks for MyMethod1 or MyMethod2 methods:
- *
- * public class FileOne {
- * public void MyMethod1() {} // OK
- * public void MyMethod2() {} // OK
- * public void MyMethod3() {} // violation, name 'MyMethod3' must
- * // match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- * }
- *
- * public class TestClass {
- * public void testMethod() {
- * final int testVariable1 = 10; // OK
- * final int testVariable2 = 10; // violation of the LocalFinalVariableName check,
- * // name 'testVariable2' must match pattern '^[A-Z][A-Z0-9]*$'
- * }
- * }
- *
- *
- * In the following sample, violations for LeftCurly check will be suppressed
- * for classes with name Main or for methods with name calculate.
- *
- * public class TestClass {
- * public void testMethod1()
- * { // OK
- * }
- *
- * public void testMethod2()
- * { // violation, '{' should be on the previous line
- * }
- * }
- *
- *
- * The following example demonstrates how to suppress RequireThis violations for
- * variable age inside changeAge method.
- *
- * public class InputTest {
- * private int age = 23;
- *
- * public void changeAge() {
- * age = 24; // violation will be suppressed
- * }
- * }
- *
- *
- * Suppress {@code IllegalThrows} violations only for methods with name
- * throwsMethod and only for {@code RuntimeException} exceptions.
- * Double colon is used for axis iterations. In the following example
- * {@code ancestor} axis is used to iterate all ancestor nodes of the current
- * node with type {@code METHOD_DEF} and name throwsMethod.
- * Please read more about xpath axes at
- * W3Schools Xpath Axes.
- *
- * public class InputTest {
- * public void throwsMethod() throws RuntimeException { // violation will be suppressed
- * }
- *
- * public void sampleMethod() throws RuntimeException { // will throw violation here
- * }
- * }
- *
- *
- * The following sample demonstrates how to suppress all violations for method
- * itself and all descendants. {@code descendant-or-self} axis iterates through
- * current node and all children nodes at any level. Keyword {@code node()}
- * selects node elements. Please read more about xpath syntax at
- * W3Schools Xpath Syntax.
- *
- * public class TestClass {
- * public void TestMethod1() { // OK
- * final int num = 10; // OK
- * }
- *
- * public void TestMethod2() { // violation of the MethodName check,
- * // name 'TestMethod2' must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- * final int num = 10; // violation of the LocalFinalVariableName check,
- * // name 'num' must match pattern '^[A-Z][A-Z0-9]*$'
- * }
- * }
- *
- *
- * The following example is an example of what checks would be suppressed while
- * building Spring projects with checkstyle plugin. Please find more information at:
- * spring-javaformat
- *
Suppress naming violations on variable named 'log' in all files:
-<module name="SuppressionSingleFilter">
- <property name="message" value="Name 'log' must match pattern"/>
+<module name="Checker">
+ <module name="SuppressionSingleFilter">
+ <property name="message" value="Name 'log' must match pattern"/>
+ </module>
</module>
diff --git a/src/xdocs/filters/suppressionsinglefilter.xml.template b/src/xdocs/filters/suppressionsinglefilter.xml.template
index 217e35c5f9b..91c3d9528b7 100644
--- a/src/xdocs/filters/suppressionsinglefilter.xml.template
+++ b/src/xdocs/filters/suppressionsinglefilter.xml.template
@@ -98,7 +98,7 @@
-
+
The following suppressions directs
a SuppressionSingleFilter to
reject JavadocStyleCheck violations for
@@ -109,103 +109,84 @@
and 'Missing a Javadoc comment' violations
for all lines and files:
+
public class FileOne {
public void MyMethod() {} // OK
}
@@ -119,48 +120,48 @@ public class FileThree {
public void MyMethod() {} // violation, name 'MyMethod'
// must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
}
-
-
-
+
+
To suppress MethodName check for method names matched pattern 'MyMethod[0-9]':
+
public class FileOne {
public void MyMethod1() {} // OK
public void MyMethod2() {} // OK
public void MyMethodA() {} // violation, name 'MyMethodA' must
// match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
}
-
-
-
+
+
To suppress checks being specified by id property:
+
public class FileOne {
public void MyMethod() {} // OK
}
@@ -168,60 +169,60 @@ public class FileTwo {
public void MyMethod() {} // violation, name 'MyMethod' must
//match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
}
-
+
public class FileOne {
public void MyMethod() {} // OK
}
@@ -230,25 +231,25 @@ public class FileTwo {
public void MyMethod() {} // violation, name 'MyMethod'
// must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
}
-
-
-
+
+
Suppress checks for elements which are either class definitions,
either method definitions:
+
abstract class FileOne { // OK
public void MyMethod() {} // OK
}
@@ -258,48 +259,48 @@ abstract class FileTwo { // violation of the AbstractClassName check,
public void MyMethod() {} // violation, name 'MyMethod'
// must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
}
-
-
-
+
+
Suppress checks for MyMethod1 or MyMethod2 methods:
+
public class FileOne {
public void MyMethod1() {} // OK
public void MyMethod2() {} // OK
public void MyMethod3() {} // violation, name 'MyMethod3' must
// match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
}
-
+
public class TestClass {
public void testMethod() {
final int testVariable1 = 10; // OK
@@ -307,25 +308,25 @@ public class TestClass {
// name 'testVariable2' must match pattern '^[A-Z][A-Z0-9]*$'
}
}
-
-
-
+
+
In the following sample, violations for LeftCurly check
will be suppressed for classes with name Main or for methods
with name calculate.
+
public class TestClass {
public void testMethod1()
{ // OK
@@ -335,24 +336,24 @@ public class TestClass {
{ // violation, '{' should be on the previous line
}
}
-
-
-
+
+
The following example demonstrates how to suppress
RequireThis violations for variable age inside changeAge method.
+
public class InputTest {
private int age = 23;
@@ -360,9 +361,8 @@ public class InputTest {
age = 24; // violation will be suppressed
}
}
-
-
-
+
+
Suppress IllegalThrows violations only for methods with name
throwsMethod and only for RuntimeException exceptions.
Double colon is used for axis iterations. In the following example ancestor
@@ -370,18 +370,19 @@ public class InputTest {
METHOD_DEF and name throwsMethod. Please read more about xpath axes at
W3Schools Xpath Axes.
+
public class InputTest {
public void throwsMethod() throws RuntimeException { // violation will be suppressed
}
@@ -389,27 +390,27 @@ public class InputTest {
public void sampleMethod() throws RuntimeException { // will throw violation here
}
}
-
-
-
+
+
The following sample demonstrates how to suppress all violations for method itself and
all descendants. descendant-or-self axis iterates through current node and
all children nodes at any level. Keyword node() selects node elements.
Please read more about xpath syntax at
W3Schools Xpath Syntax.
+
public class TestClass {
public void TestMethod1() { // OK
final int num = 10; // OK
@@ -421,30 +422,31 @@ public class TestClass {
// name 'num' must match pattern '^[A-Z][A-Z0-9]*$'
}
}
-
-
-
+
+
The following example is an example of what checks would be suppressed
while building Spring projects with checkstyle plugin.
Please find more information at:
spring-javaformat
-public class FileOne {
- public void MyMethod() {} // OK
-}
-
-public class FileTwo {
- public void MyMethod() {} // OK
-}
-
-public class FileThree {
- public void MyMethod() {} // violation, name 'MyMethod'
- // must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
-}
-
-
-
+
+
+
+
+
Code example:
+
+
+
+
+
To suppress MethodName check for method names matched pattern 'MyMethod[0-9]':
-public class FileOne {
- public void MyMethod1() {} // OK
- public void MyMethod2() {} // OK
- public void MyMethodA() {} // violation, name 'MyMethodA' must
- // match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
-}
-
-
-
+
+
+
+
+
Code Example:
+
+
+
+
+
To suppress checks being specified by id property:
-public class FileOne {
- public void MyMethod() {} // OK
-}
-public class FileTwo {
- public void MyMethod() {} // violation, name 'MyMethod' must
- //match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
-}
-
-public class FileOne {
- public void MyMethod() {} // OK
-}
-
-public class FileTwo {
- public void MyMethod() {} // violation, name 'MyMethod'
- // must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
-}
-
-
-
+
+
+
+
+
Code example:
+
+
+
+
+
Suppress checks for elements which are either class definitions,
either method definitions:
-abstract class FileOne { // OK
- public void MyMethod() {} // OK
-}
-
-abstract class FileTwo { // violation of the AbstractClassName check,
- // it should match the pattern "^Abstract.+$"
- public void MyMethod() {} // violation, name 'MyMethod'
- // must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
-}
-
-
-
+
+
+
+
+
Code example:
+
+
+
+
+
Suppress checks for MyMethod1 or MyMethod2 methods:
-public class FileOne {
- public void MyMethod1() {} // OK
- public void MyMethod2() {} // OK
- public void MyMethod3() {} // violation, name 'MyMethod3' must
- // match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
-}
-
-public class TestClass {
- public void testMethod() {
- final int testVariable1 = 10; // OK
- final int testVariable2 = 10; // violation of the LocalFinalVariableName check,
- // name 'testVariable2' must match pattern '^[A-Z][A-Z0-9]*$'
- }
-}
-
-
-
+
+
+
+
+
Code Example:
+
+
+
+
+
In the following sample, violations for LeftCurly check
will be suppressed for classes with name Main or for methods
with name calculate.
-public class TestClass {
- public void testMethod1()
- { // OK
- }
-
- public void testMethod2()
- { // violation, '{' should be on the previous line
- }
-}
-
-
-
+
+
+
+
+
Code Example:
+
+
+
+
+
The following example demonstrates how to suppress
RequireThis violations for variable age inside changeAge method.
-public class InputTest {
- private int age = 23;
-
- public void changeAge() {
- age = 24; // violation will be suppressed
- }
-}
-
-
-
+
+
+
+
+
Code Example:
+
+
+
+
+
Suppress IllegalThrows violations only for methods with name
throwsMethod and only for RuntimeException exceptions.
Double colon is used for axis iterations. In the following example ancestor
@@ -370,81 +257,46 @@ public class InputTest {
METHOD_DEF and name throwsMethod. Please read more about xpath axes at
W3Schools Xpath Axes.
-public class InputTest {
- public void throwsMethod() throws RuntimeException { // violation will be suppressed
- }
-
- public void sampleMethod() throws RuntimeException { // will throw violation here
- }
-}
-
-
-
+
+
+
+
+
Code Example:
+
+
+
+
+
The following sample demonstrates how to suppress all violations for method itself and
all descendants. descendant-or-self axis iterates through current node and
all children nodes at any level. Keyword node() selects node elements.
Please read more about xpath syntax at
W3Schools Xpath Syntax.
-public class TestClass {
- public void TestMethod1() { // OK
- final int num = 10; // OK
- }
-
- public void TestMethod2() { // violation of the MethodName check,
- // name 'TestMethod2' must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- final int num = 10; // violation of the LocalFinalVariableName check,
- // name 'num' must match pattern '^[A-Z][A-Z0-9]*$'
- }
-}
-
-
-
+
+
+
+
+
Code Example:
+
+
+
+
+
The following example is an example of what checks would be suppressed
while building Spring projects with checkstyle plugin.
Please find more information at:
spring-javaformat
@SuppressWarnings({"memberName"})
private int J; // should NOT fail MemberNameCheck
@@ -98,6 +108,22 @@ private int [] ARRAY; // should NOT fail MemberNameCheck and NoWhitespaceAfterCh
<module name="SuppressWarningsFilter" />
+
@SuppressWarnings({"memberName"})
private int J; // should NOT fail MemberNameCheck
@@ -98,12 +105,18 @@ private int [] ARRAY; // should NOT fail MemberNameCheck and NoWhitespaceAfterCh
<module name="SuppressWarningsFilter" />
-
-@SuppressWarnings("checkstyle:systemout")
-public static void foo() {
- System.out.println("Debug info."); // should NOT fail RegexpSinglelineJava
-}
-
+
public static final int lowerCaseConstant; // CHECKSTYLE IGNORE THIS LINE
-
+
To configure a filter so that
// OK to catch (Throwable|Exception|RuntimeException) here
permits the current and previous line to avoid generating an IllegalCatch
audit event:
To configure a filter so that
CHECKSTYLE IGNORE check FOR NEXTvar LINES
avoids triggering any audits for the given check for
the current line and the next var lines (for a total of var+1 lines):
static final int lowerCaseConstant; // CHECKSTYLE IGNORE ConstantNameCheck FOR NEXT 3 LINES
static final int lowerCaseConstant1;
@@ -167,35 +187,45 @@ static final int lowerCaseConstant2;
static final int lowerCaseConstant3;
static final int lowerCaseConstant4; // will warn here
-
+
To configure a filter to avoid any audits on code like:
public static final int [] array; // @cs.suppress [ConstantName|NoWhitespaceAfter] A comment here
@@ -206,34 +236,36 @@ public static final int [] array; // @cs.suppress [ConstantName|NoWhitespaceAfte
// @cs-: <ID/> (reason), where ID is the ID of checks you want to
suppress.
-
- Examples of Checkstyle checks configuration:
-
-
-<module name="RegexpSinglelineJava">
- <property name="id" value="ignore"/>
- <property name="format" value="^.*@Ignore\s*$"/>
- <property name="message" value="@Ignore should have a reason."/>
-</module>
-
-<module name="RegexpSinglelineJava">
- <property name="id" value="systemout"/>
- <property name="format" value="^.*System\.(out|err).*$"/>
- <property name="message" value="Don't use System.out/err, use SLF4J instead."/>
-</module>
-
-
- Example of SuppressWithNearbyCommentFilter configuration (idFormat which
+
+ Example of Checkstyle checks and
+ SuppressWithNearbyCommentFilter configuration (idFormat which
is set to '$1' points that ID of the checks is in the first group of
commentFormat regular expressions):
To configure a filter to suppress all audit events on any line
containing the comment CHECKSTYLE IGNORE THIS LINE:
-
-<module name="SuppressWithNearbyCommentFilter">
- <property name="commentFormat" value="CHECKSTYLE IGNORE THIS LINE"/>
- <property name="checkFormat" value=".*"/>
- <property name="influenceFormat" value="0"/>
-</module>
-
-
-public static final int lowerCaseConstant; // CHECKSTYLE IGNORE THIS LINE
-
-
+
+
+
+
+
Example:
+
+
+
+
+
To configure a filter so that
// OK to catch (Throwable|Exception|RuntimeException) here
permits the current and previous line to avoid generating an IllegalCatch
audit event:
To configure a filter so that
CHECKSTYLE IGNORE check FOR NEXTvar LINES
avoids triggering any audits for the given check for
the current line and the next var lines (for a total of var+1 lines):
-
-<module name="SuppressWithNearbyCommentFilter">
- <property name="commentFormat"
- value="CHECKSTYLE IGNORE (\w+) FOR NEXT (\d+) LINES"/>
- <property name="checkFormat" value="$1"/>
- <property name="influenceFormat" value="$2"/>
-</module>
-
-
-static final int lowerCaseConstant; // CHECKSTYLE IGNORE ConstantNameCheck FOR NEXT 3 LINES
-static final int lowerCaseConstant1;
-static final int lowerCaseConstant2;
-static final int lowerCaseConstant3;
-static final int lowerCaseConstant4; // will warn here
-
-
+
+
+
+
+
Example:
+
+
+
+
+
To configure a filter to avoid any audits on code like:
To configure a filter to allow suppress one or more Checks
(separated by "|") and demand comment no less than 14 symbols:
-
-<module name="SuppressWithNearbyCommentFilter">
- <property name="commentFormat"
- value="@cs\.suppress \[(\w+(\|\w+)*)\] \w[-\.'`,:;\w ]{14,}"/>
- <property name="checkFormat" value="$1"/>
- <property name="influenceFormat" value="1"/>
-</module>
-
-
-public static final int [] array; // @cs.suppress [ConstantName|NoWhitespaceAfter] A comment here
-
+
+
+
+
+
Example:
+
+
+
+
It is possible to specify an ID of checks, so that it can be leveraged by the
SuppressWithNearbyCommentFilter to skip validations. The following examples
@@ -206,63 +201,38 @@ public static final int [] array; // @cs.suppress [ConstantName|NoWhitespaceAfte
// @cs-: <ID/> (reason), where ID is the ID of checks you want to
suppress.
-
- Examples of Checkstyle checks configuration:
-
-
-<module name="RegexpSinglelineJava">
- <property name="id" value="ignore"/>
- <property name="format" value="^.*@Ignore\s*$"/>
- <property name="message" value="@Ignore should have a reason."/>
-</module>
-
-<module name="RegexpSinglelineJava">
- <property name="id" value="systemout"/>
- <property name="format" value="^.*System\.(out|err).*$"/>
- <property name="message" value="Don't use System.out/err, use SLF4J instead."/>
-</module>
-
-
- Example of SuppressWithNearbyCommentFilter configuration (idFormat which
+
+ Example of Checkstyle checks and
+ SuppressWithNearbyCommentFilter configuration (idFormat which
is set to '$1' points that ID of the checks is in the first group of
commentFormat regular expressions):
int a = 42; // DO NOT CHECK THIS LINE
int b = 43; // violation
-
+
To configure the filter to suppress audit events whose check message contains
the word Line. In this case, LineLengthCheck's violation
message contains it:
@@ -134,13 +134,13 @@ int b = 43; // violation
</module>
</module>
-
+
Example:
export FOO=BAR # ok, because violation message is matching suppress pattern
-
+
To configure the filter to suppress audit events only on a check whose id is
ignoreMe:
@@ -159,14 +159,14 @@ export FOO=BAR # ok, because violation message is matching suppress pattern
</module>
</module>
-
+
Example:
int a = 42; // SUPPRESS CHECKSTYLE because i want to
static final int LONG_VAR_NAME_TO_TAKE_MORE_THAN_55_CHARS = 22; // LineLength violation
-
+
To configure the filter to suppress audit events for the current and next 2 lines:
@@ -177,7 +177,7 @@ static final int LONG_VAR_NAME_TO_TAKE_MORE_THAN_55_CHARS = 22; // LineLength vi
<module name="UniqueProperties"/>
</module>
-
+
Example:
@@ -186,7 +186,7 @@ key.one=42 # ok
key.one=43 # ok
key.one=44 # violation
-
+
To configure the filter to suppress audit events for the current and previous line:
-
-int a = 42; // DO NOT CHECK THIS LINE
-int b = 43; // violation
-
-
+
+
+
+
+
To configure the filter to suppress audit events whose check message contains
the word Line. In this case, LineLengthCheck's violation
message contains it:
To configure a filter to suppress audit events between a comment
containing line BEGIN GENERATED CONTENT and a comment
containing line END GENERATED CONTENT
@@ -127,6 +125,7 @@
</module>
+
Example:
//BEGIN GENERATED CONTENT
my.property=value1 // No violation events will be reported
@@ -134,7 +133,7 @@ my.property=value2 // No violation events will be reported
//END GENERATED CONTENT
. . .
-
+
To configure a filter so that -- stop tab
check and -- resume tab check marks allowed tab positions
(Checker is configured to check only sql files):
@@ -151,13 +150,14 @@ my.property=value2 // No violation events will be reported
</module>
+
Example:
-- stop tab check
SELECT * FROM users // won't warn here if there is a tab character on line
-- resume tab check
SELECT 1 // will warn here if there is a tab character on line
-
+
To configure a filter so that name of suppressed check mentioned
in comment CSOFF: regexp
and CSON: regexp mark a matching check
@@ -175,6 +175,7 @@ my.property=value2 // No violation events will be reported
</module>
+
Example:
// CSOFF: RegexpSinglelineCheck
// RegexpSingleline check won't warn any lines below here if the line matches regexp
@@ -185,7 +186,7 @@ my.property=value2 // No violation events will be reported
// RegexpSingleline check will warn below here if the line matches regexp
<property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/>
-
+
To configure a filter to suppress all audit events between a comment
containing CHECKSTYLE_OFF: ALMOST_ALL and a comment containing
CHECKSTYLE_OFF: ALMOST_ALL except for the EqualsHashCode
@@ -206,6 +207,7 @@ my.property=value2 // No violation events will be reported
</module>
+
Example:
// CHECKSTYLE_OFF: ALMOST_ALL
public static final int array [];
@@ -213,7 +215,7 @@ private String [] strArray;
// CHECKSTYLE_ON: ALMOST_ALL
private int array1 [];
-
+
To configure a filter to suppress Check's violation message which matches
specified message in messageFormat (so suppression will not be only by
Check's name, but also by message text, as the same Check can report
@@ -238,26 +240,8 @@ private int array1 [];
with -- CSOFF <ID> (reason) and -- CSON <ID>,
where ID is the ID of checks you want to suppress.
- Example of SuppressWithPlainTextCommentFilter configuration
+
+ Example of Checkstyle checks and SuppressWithPlainTextCommentFilter configuration
(checkFormat which is set to '$1' points that ID of the checks
is in the first group of offCommentFormat and onCommentFormat
regular expressions):
@@ -272,8 +256,25 @@ private int array1 [];
<property name="idFormat" value="$1"/>
</module>
+ <module name="TreeWalker">
+ <module name="RegexpSinglelineJava">
+ <property name="id" value="count"/>
+ <property name="format" value="^.*COUNT(*).*$"/>
+ <property name="message"
+ value="Don't use COUNT(*), use COUNT(1) instead."/>
+ </module>
+
+ <module name="RegexpSinglelineJava">
+ <property name="id" value="join"/>
+ <property name="format" value="^.*JOIN\s.+\s(ON|USING)$"/>
+ <property name="message"
+ value="Don't use JOIN, use sub-select instead."/>
+ </module>
+ </module>
+
</module>
+
Example:
-- CSOFF join (it is ok to use join here for performance reasons)
SELECT name, job_name
@@ -285,7 +286,7 @@ JOIN jobs AS j ON u.job_id = j.id
EXPLAIN SELECT COUNT(*) FROM restaurants
-- CSON count
-
+
Example of how to configure the check to suppress more than one check
(Checker is configured to check only sql files).
To configure a filter to suppress audit events between a comment
containing line BEGIN GENERATED CONTENT and a comment
containing line END GENERATED CONTENT
(Checker is configured to check only properties files):
-
-<module name="Checker">
- <property name="fileExtensions" value="properties"/>
-
- <module name="SuppressWithPlainTextCommentFilter">
- <property name="offCommentFormat" value="BEGIN GENERATED CONTENT"/>
- <property name="onCommentFormat" value="END GENERATED CONTENT"/>
- </module>
-
-</module>
-
-
-//BEGIN GENERATED CONTENT
-my.property=value1 // No violation events will be reported
-my.property=value2 // No violation events will be reported
-//END GENERATED CONTENT
-. . .
-
-
+
+
+
+
+
Example:
+
+
+
+
+
To configure a filter so that -- stop tab
check and -- resume tab check marks allowed tab positions
(Checker is configured to check only sql files):
-
-<module name="Checker">
- <property name="fileExtensions" value="sql"/>
-
- <module name="SuppressWithPlainTextCommentFilter">
- <property name="offCommentFormat" value="stop tab check"/>
- <property name="onCommentFormat" value="resume tab check"/>
- <property name="checkFormat" value="FileTabCharacterCheck"/>
- </module>
-
-</module>
-
-
--- stop tab check
- SELECT * FROM users // won't warn here if there is a tab character on line
--- resume tab check
- SELECT 1 // will warn here if there is a tab character on line
-
-
+
+
+
+
+
Example:
+
+
+
+
+
To configure a filter so that name of suppressed check mentioned
in comment CSOFF: regexp
and CSON: regexp mark a matching check
(Checker is configured to check only xml files):
-
-<module name="Checker">
- <property name="fileExtensions" value="xml"/>
-
- <module name="SuppressWithPlainTextCommentFilter">
- <property name="offCommentFormat" value="CSOFF\: ([\w\|]+)"/>
- <property name="onCommentFormat" value="CSON\: ([\w\|]+)"/>
- <property name="checkFormat" value="$1"/>
- </module>
-
-</module>
-
-
-// CSOFF: RegexpSinglelineCheck
- // RegexpSingleline check won't warn any lines below here if the line matches regexp
-<condition property="checkstyle.ant.skip">
- <isset property="checkstyle.ant.skip"/>
-</condition>
-// CSON: RegexpSinglelineCheck
-// RegexpSingleline check will warn below here if the line matches regexp
-<property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/>
-
-
+
+
+
+
+
Example:
+
+
+
+
+
To configure a filter to suppress all audit events between a comment
containing CHECKSTYLE_OFF: ALMOST_ALL and a comment containing
CHECKSTYLE_OFF: ALMOST_ALL except for the EqualsHashCode
check (Checker is configured to check only java files):
To configure a filter to suppress Check's violation message which matches
specified message in messageFormat (so suppression will not be only by
Check's name, but also by message text, as the same Check can report
violations with different message format) between a comment
containing stop and comment containing resume:
It is possible to specify an ID of checks, so that it can be leveraged by the
SuppressWithPlainTextCommentFilter to skip validations.
@@ -238,78 +194,38 @@ private int array1 [];
with -- CSOFF <ID> (reason) and -- CSON <ID>,
where ID is the ID of checks you want to suppress.
- Example of SuppressWithPlainTextCommentFilter configuration
+
+ Example of Checkstyle checks and SuppressWithPlainTextCommentFilter configuration
(checkFormat which is set to '$1' points that ID of the checks
is in the first group of offCommentFormat and onCommentFormat
regular expressions):
-
-<module name="Checker">
- <property name="fileExtensions" value="sql"/>
-
- <module name="SuppressWithPlainTextCommentFilter">
- <property name="offCommentFormat" value="CSOFF (\w+) \(\w+\)"/>
- <property name="onCommentFormat" value="CSON (\w+)"/>
- <property name="idFormat" value="$1"/>
- </module>
-
-</module>
-
-
--- CSOFF join (it is ok to use join here for performance reasons)
-SELECT name, job_name
-FROM users AS u
-JOIN jobs AS j ON u.job_id = j.id
--- CSON join
-
--- CSOFF count (test query execution plan)
-EXPLAIN SELECT COUNT(*) FROM restaurants
--- CSON count
-
-
+
+
+
+
+
Example:
+
+
+
+
+
Example of how to configure the check to suppress more than one check
(Checker is configured to check only sql files).
- * To configure the check to suppress empty catch block if exception's variable name is
- * {@code expected} or {@code ignore} or there's any comment inside:
- *
- * To configure the check to suppress empty catch block if single-line comment inside
- * is "//This is expected" or exception's
- * variable name is "myException" (any option is matching):
- *
- * class Test
- * { // Violation - '{' should be on the previous line
- * private interface TestInterface { // OK
- * }
- *
- * private
- * class
- * MyClass { // Violation - '{' should be on a new line
- * }
- *
- * enum Colors {RED, // OK
- * BLUE,
- * GREEN;
- * }
- * }
- *
- *
- * An example of how to configure the check to validate enum definitions:
- *
- * class Test
- * { // Violation - '{' should be on the previous line
- * private interface TestInterface
- * { // Violation - '{' should be on the previous line
- * }
- *
- * private
- * class
- * MyClass { // OK
- * }
- *
- * enum Colors {RED, // Violation - '{' should have line break after
- * BLUE,
- * GREEN;
- * }
- * }
- *
- *
* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker}
*
- * if (obj.isValid()) return true; // OK
- * if (true) { // OK
- * return true;
- * } else // OK
- * return false;
- * for (int i = 0; i < 5; i++) { // OK
- * ++count;
- * }
- * do // OK
- * ++count;
- * while (false);
- * for (int j = 0; j < 10; j++); // violation, empty loop body not allowed
- * for(int i = 0; i < 10; value.incrementValue()); // violation, empty loop body not allowed
- * while (counter < 10) // OK
- * ++count;
- * while (value.incrementValue() < 5); // violation, empty loop body not allowed
- * switch (num) {
- * case 1: counter++; break; // OK
- * }
- * while (obj.isValid()) return true; // OK
- * do this.notify(); while (o != null); // OK
- * for (int i = 0; ; ) this.notify(); // OK
- *
- *
- * To configure the check to allow {@code case, default} single-line statements without braces:
- *
- * public class Test {
- *
- * public void test() {
- *
- * if (foo) {
- * bar();
- * } // violation, right curly must be in the same line as the 'else' keyword
- * else {
- * bar();
- * }
- *
- * if (foo) {
- * bar();
- * } else { // OK
- * bar();
- * }
- *
- * if (foo) { bar(); } int i = 0; // violation
- * // ^^^ statement is not allowed on same line after curly right brace
- *
- * if (foo) { bar(); } // OK
- * int i = 0;
- *
- * try {
- * bar();
- * } // violation, rightCurly must be in the same line as 'catch' keyword
- * catch (Exception e) {
- * bar();
- * }
- *
- * try {
- * bar();
- * } catch (Exception e) { // OK
- * bar();
- * }
- *
- * } // OK
- *
- * public void testSingleLine() { bar(); } // OK, because singleline is allowed
- * }
- *
- *
- * To configure the check with policy {@code alone} for {@code else} and
- *
- * METHOD_DEF tokens:
- *
- * class Test {
- *
- * public void method0() {
- * int mode = 0;
- * switch (mode) {
- * case 1:
- * int x = 1;
- * break;
- * default:
- * x = 0;
- * } // ok
- * }
- *
- * public static void method7() {
- * int mode = 0;
- * int x;
- * switch (mode) { case 1: x = 5; } // ok, RightCurly is on the same line as LeftCurly
- * }
- *
- * public void method() {
- * int mode = 0;
- * int x;
- * switch (mode) {
- * case 1:
- * x = 1; } // violation, right curly should be alone on line
- * }
- * }
- *
- *
* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker}
*
- * public abstract class Foo {
- * private int bar;
- *
- * public int m1() {return 2;} // Violation. No javadoc.
- *
- * public int m2() {return 8;} // Violation. No javadoc.
- *
- * private void m3() {m4();} // OK. Private method.
- *
- * protected void m4() { } // OK. No implementation.
- *
- * public abstract void m5(); // OK. Abstract method.
- *
- * /**
- * * This implementation ...
- * @return some int value.
- * */
- * public int m6() {return 1;} // OK. Have required javadoc.
- *
- * /**
- * * Some comments ...
- * */
- * public int m7() {return 1;} // Violation. No required javadoc.
- *
- * /**
- * * This
- * * implementation ...
- * */
- * public int m8() {return 2;} // Violation. No required javadoc.
- *
- * @Override
- * public String toString() { // Violation. No required javadoc.
- * return "";
- * }
- * }
- *
- *
- * To configure the check to allow methods which contain a specified comment text
- * pattern in their javadoc which can span multiple lines
- * to be designed for extension.
- *
- * Property {@code elementStyle} - Define the annotation element styles.
- * Type is {@code
- * com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck$ElementStyleOption}.
- * Default value is {@code compact_no_array}.
- *
- *
* Property {@code closingParens} - Define the policy for ending parenthesis.
* Type is {@code
* com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck$ClosingParensOption}.
* Default value is {@code never}.
*
*
+ * Property {@code elementStyle} - Define the annotation element styles.
+ * Type is {@code
+ * com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck$ElementStyleOption}.
+ * Default value is {@code compact_no_array}.
+ *
+ *
* Property {@code trailingArrayComma} - Define the policy for trailing comma in arrays.
* Type is {@code
* com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck$TrailingArrayCommaOption}.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/annotation/AnnotationUseStyleCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/annotation/AnnotationUseStyleCheck.xml
index d17dcc789a3..b157fed208b 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/annotation/AnnotationUseStyleCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/annotation/AnnotationUseStyleCheck.xml
@@ -74,16 +74,16 @@
Java Language specification, §9.7</a>.
</p>
-
- Define the annotation element styles.
- Define the policy for ending parenthesis.
+
+ Define the annotation element styles.
+
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index bf7ad2c2085..b423aa8b1cf 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -226,6 +226,78 @@ public class XdocsPagesTest {
private static final Set GOOGLE_MODULES = Collections.unmodifiableSet(
CheckUtil.getConfigGoogleStyleModules());
+ // until https://github.com/checkstyle/checkstyle/issues/13666
+ private static final Set MODULES_WITH_UNORDERED_PROPERTIES = Set.of(
+ "Checker",
+ "MissingJavadocMethod",
+ "VariableDeclarationUsageDistance",
+ "LocalVariableName",
+ "JavadocTagContinuationIndentation",
+ "ClassFanOutComplexity",
+ "Translation",
+ "MethodCount",
+ "SummaryJavadoc",
+ "ClassDataAbstractionCoupling",
+ "JavadocMethod",
+ "VisibilityModifier",
+ "MethodLength",
+ "Regexp",
+ "Indentation",
+ "MethodName",
+ "AtclauseOrder",
+ "SuppressWithNearbyTextFilter",
+ "SuppressWithPlainTextCommentFilter",
+ "MemberName",
+ "AvoidStarImport",
+ "ReturnCount",
+ "StaticVariableName",
+ "AvoidEscapedUnicodeCharacters",
+ "ParameterNumber",
+ "RecordComponentNumber",
+ "RegexpSingleline",
+ "RegexpOnFilename",
+ "JavaNCSS",
+ "EmptyCatchBlock",
+ "ParameterName",
+ "IllegalThrows",
+ "HiddenField",
+ "SuppressionXpathSingleFilter",
+ "WhitespaceAround",
+ "RegexpSinglelineJava",
+ "ImportOrder",
+ "IllegalType",
+ "ConstantName",
+ "MutableException",
+ "JavadocType",
+ "CustomImportOrder",
+ "AnnotationLocation",
+ "Header",
+ "DescendantToken",
+ "RegexpMultiline",
+ "JavadocVariable",
+ "SuppressionSingleFilter",
+ "InterfaceMemberImpliedModifier",
+ "IllegalImport",
+ "NewlineAtEndOfFile",
+ "SingleLineJavadoc",
+ "MissingJavadocType",
+ "FileLength",
+ "RegexpHeader",
+ "ThrowsCount",
+ "SuppressionCommentFilter",
+ "TypeName",
+ "MagicNumber",
+ "NeedBraces",
+ "SeverityMatchFilter",
+ "SuppressWithNearbyCommentFilter",
+ "MultipleStringLiterals",
+ "LeftCurly",
+ "AbbreviationAsWordInName",
+ "EmptyLineSeparator",
+ "JavadocStyle",
+ "JavadocParagraph"
+ );
+
/**
* Generate xdoc content from templates before validation.
* This method will be removed once
@@ -797,6 +869,10 @@ private static void validatePropertySection(String fileName, String sectionName,
.that(table.getNodeName())
.isEqualTo("table");
+ if (!MODULES_WITH_UNORDERED_PROPERTIES.contains(sectionName)) {
+ validatePropertySectionPropertiesOrder(fileName, sectionName, table, properties);
+ }
+
validatePropertySectionProperties(fileName, sectionName, table, instance,
properties);
}
@@ -807,6 +883,43 @@ private static void validatePropertySection(String fileName, String sectionName,
.isEmpty();
}
+ private static void validatePropertySectionPropertiesOrder(String fileName, String sectionName,
+ Node table, Set properties) {
+ final Set rows = XmlUtil.getChildrenElements(table);
+ final List orderedPropertyNames = new ArrayList<>(properties);
+ final List tablePropertyNames = new ArrayList<>();
+
+ // javadocTokens and tokens should be last
+ if (orderedPropertyNames.contains("javadocTokens")) {
+ orderedPropertyNames.remove("javadocTokens");
+ orderedPropertyNames.add("javadocTokens");
+ }
+ if (orderedPropertyNames.contains("tokens")) {
+ orderedPropertyNames.remove("tokens");
+ orderedPropertyNames.add("tokens");
+ }
+
+ rows
+ .stream()
+ // First row is header row
+ .skip(1)
+ .forEach(row -> {
+ final List columns = new ArrayList<>(XmlUtil.getChildrenElements(row));
+ assertWithMessage(fileName + " section '" + sectionName
+ + "' should have the requested columns")
+ .that(columns)
+ .hasSize(5);
+
+ final String propertyName = columns.get(0).getTextContent();
+ tablePropertyNames.add(propertyName);
+ });
+
+ assertWithMessage(fileName + " section '" + sectionName
+ + "' should have properties in the requested order")
+ .that(tablePropertyNames)
+ .isEqualTo(orderedPropertyNames);
+ }
+
private static void fixCapturedProperties(String sectionName, Object instance, Class> clss,
Set properties) {
// remove global properties that don't need documentation
diff --git a/src/xdocs/checks/annotation/annotationusestyle.xml b/src/xdocs/checks/annotation/annotationusestyle.xml
index 1d9d23d1668..176107e6651 100644
--- a/src/xdocs/checks/annotation/annotationusestyle.xml
+++ b/src/xdocs/checks/annotation/annotationusestyle.xml
@@ -86,28 +86,28 @@
since
-
elementStyle
+
closingParens
- Define the annotation element styles.
+ Define the policy for ending parenthesis.
- * Property {@code allowSamelineSingleParameterlessAnnotation} - Allow single parameterless
+ * Property {@code allowSamelineParameterizedAnnotation} - Allow one and only parameterized
* annotation to be located on the same line as target element.
* Type is {@code boolean}.
- * Default value is {@code true}.
+ * Default value is {@code false}.
*
*
- * Property {@code allowSamelineParameterizedAnnotation} - Allow one and only parameterized
+ * Property {@code allowSamelineSingleParameterlessAnnotation} - Allow single parameterless
* annotation to be located on the same line as target element.
* Type is {@code boolean}.
- * Default value is {@code false}.
+ * Default value is {@code true}.
*
*
* Property {@code tokens} - tokens to check
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/annotation/AnnotationLocationCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/annotation/AnnotationLocationCheck.xml
index 16ce5ec6cbe..fe6c510b773 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/annotation/AnnotationLocationCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/annotation/AnnotationLocationCheck.xml
@@ -40,17 +40,17 @@
type="boolean">
Allow annotation(s) to be located on
the same line as target element.
-
-
- Allow single parameterless
- annotation to be located on the same line as target element.Allow one and only parameterized
+ annotation to be located on the same line as target element.
+
+
+ Allow single parameterless
annotation to be located on the same line as target element.false
6.0
-
-
allowSamelineSingleParameterlessAnnotation
-
Allow single parameterless annotation to be located on the same line as
- target element.
diff --git a/config/pmd.xml b/config/pmd.xml
index db04ea7ae13..256563495c0 100644
--- a/config/pmd.xml
+++ b/config/pmd.xml
@@ -257,9 +257,11 @@
-
+
+ value="//ClassOrInterfaceDeclaration[@SimpleName='HandlerFactory'
+ or @SimpleName='SiteUtil']"/>
@@ -274,7 +276,9 @@
AbstractElementNode.iterateAxis,
NoWhitespaceAfterCheck.getArrayDeclaratorPreviousElement
are also huge switches, they had to be monolithic.
- SuppressFilterElement is a single constructor and can't be split easily -->
+ SuppressFilterElement is a single constructor and can't be split easily
+ Splitting PropertiesMacro.getDefaultValue will damage readability
+ Splitting SiteUtil.getDefaultValue would not make it more readable -->
"/>
@@ -322,11 +332,13 @@
+ JavadocMethodCheck is in the process of being rewritten.
+ SiteUtil provides a lot of functionality to generate documentation. -->
+ or @SimpleName='JavadocMethodCheck' or @SimpleName='JavaAstVisitor'
+ or @SimpleName='SiteUtil']"/>
@@ -342,21 +354,28 @@
Checker collects external resource locations and sets up the configuration.
CheckstyleAntTask integrates Checkstyle with Ant.
TranslationCheck uses a lot of imports for it's logic and custom violations.
+ SiteUtil uses a lot of imports to provide logic for generating documentation
-->
+ or @SimpleName='AbstractAutomaticBean'
+ or @SimpleName='SiteUtil']"/>
-
+
+ //MethodDeclaration[@Name='getModulePropertyExpectedValue']
+ | //ClassOrInterfaceDeclaration[@SimpleName='SiteUtil']
+ //MethodDeclaration[@Name='getDefaultValue']
+ | //ClassOrInterfaceDeclaration[@SimpleName='DescriptionExtractor']
+ //MethodDeclaration[@Name='getDescriptionFromJavadoc']"/>
@@ -388,4 +407,12 @@
value="//ClassOrInterfaceDeclaration[@SimpleName='JavaAstVisitor']"/>
+
+
+
+
+
+
diff --git a/config/sevntu-suppressions.xml b/config/sevntu-suppressions.xml
index ab08ab33fda..90777a64cca 100644
--- a/config/sevntu-suppressions.xml
+++ b/config/sevntu-suppressions.xml
@@ -46,4 +46,8 @@
+
+
+
+
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/Definitions.java b/src/main/java/com/puppycrawl/tools/checkstyle/Definitions.java
index 28766aa0152..7c256ab5414 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/Definitions.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/Definitions.java
@@ -32,7 +32,8 @@ public final class Definitions {
/** Name of modules which are not checks, but are internal modules. */
public static final Set INTERNAL_MODULES = Set.of(
- "com.puppycrawl.tools.checkstyle.meta.JavadocMetadataScraper");
+ "com.puppycrawl.tools.checkstyle.meta.JavadocMetadataScraper",
+ "com.puppycrawl.tools.checkstyle.site.ClassAndPropertiesSettersJavadocScraper");
/**
* Do no allow {@code Definitions} instances to be created.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractAccessControlNameCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractAccessControlNameCheck.java
index 5a7eab546e6..963df9502f2 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractAccessControlNameCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractAccessControlNameCheck.java
@@ -113,7 +113,7 @@ private static boolean isPublic(DetailAST modifiers) {
}
/**
- * Sets whether we should apply the check to public members.
+ * Setter to control whether we should apply the check to public members.
*
* @param applyTo new value of the property.
*/
@@ -122,7 +122,7 @@ public void setApplyToPublic(boolean applyTo) {
}
/**
- * Sets whether we should apply the check to protected members.
+ * Setter to control whether we should apply the check to protected members.
*
* @param applyTo new value of the property.
*/
@@ -131,7 +131,7 @@ public void setApplyToProtected(boolean applyTo) {
}
/**
- * Sets whether we should apply the check to package-private members.
+ * Setter to control whether we should apply the check to package-private members.
*
* @param applyTo new value of the property.
*/
@@ -140,7 +140,7 @@ public void setApplyToPackage(boolean applyTo) {
}
/**
- * Sets whether we should apply the check to private members.
+ * Setter to control whether we should apply the check to private members.
*
* @param applyTo new value of the property.
*/
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/site/ClassAndPropertiesSettersJavadocScraper.java b/src/main/java/com/puppycrawl/tools/checkstyle/site/ClassAndPropertiesSettersJavadocScraper.java
new file mode 100644
index 00000000000..b336e9d37c5
--- /dev/null
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/ClassAndPropertiesSettersJavadocScraper.java
@@ -0,0 +1,203 @@
+///////////////////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code and other text files for adherence to a set of rules.
+// Copyright (C) 2001-2023 the original author or authors.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+package com.puppycrawl.tools.checkstyle.site;
+
+import java.beans.Introspector;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import com.puppycrawl.tools.checkstyle.FileStatefulCheck;
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+import com.puppycrawl.tools.checkstyle.api.DetailNode;
+import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes;
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+import com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck;
+import com.puppycrawl.tools.checkstyle.utils.BlockCommentPosition;
+
+/**
+ * Class for scraping class javadoc and all property setter javadocs from the
+ * given checkstyle module.
+ */
+@FileStatefulCheck
+public class ClassAndPropertiesSettersJavadocScraper extends AbstractJavadocCheck {
+
+ /**
+ * Map of scraped javadocs - name of property, javadoc detail node.
+ * The class javadoc is stored too, with the key being the module name.
+ */
+ private static final Map JAVADOC_FOR_MODULE_OR_PROPERTY =
+ new LinkedHashMap<>();
+
+ /** List of setter methods that the scraper ignores but shouldn't. */
+ private static final Set SUPERCLASS_SETTERS = Set.of(
+ "AbstractFileSetCheck.setFileExtensions",
+ "AbstractHeaderCheck.setHeader"
+ );
+
+ /** Name of the module being scraped. */
+ private static String moduleName = "";
+
+ /**
+ * Initialize the scraper. Clears static context and sets the module name.
+ *
+ * @param newModuleName the module name.
+ */
+ public static void initialize(String newModuleName) {
+ JAVADOC_FOR_MODULE_OR_PROPERTY.clear();
+ moduleName = newModuleName;
+ }
+
+ /**
+ * Get the module or property javadocs map.
+ *
+ * @return the javadocs.
+ */
+ public static Map getJavadocsForModuleOrProperty() {
+ return Collections.unmodifiableMap(JAVADOC_FOR_MODULE_OR_PROPERTY);
+ }
+
+ @Override
+ public int[] getDefaultJavadocTokens() {
+ return new int[] {
+ JavadocTokenTypes.JAVADOC,
+ };
+ }
+
+ @Override
+ public void visitJavadocToken(DetailNode ast) {
+ final DetailAST blockCommentAst = getBlockCommentAst();
+ if (BlockCommentPosition.isOnMethod(blockCommentAst)) {
+ final DetailAST methodDef = getParentAst(blockCommentAst, TokenTypes.METHOD_DEF);
+ if (methodDef != null) {
+ final String methodName = methodDef.findFirstToken(TokenTypes.IDENT).getText();
+ if (isSetterMethod(methodDef) && isMethodOfScrapedModule(methodDef)
+ || SUPERCLASS_SETTERS.contains(moduleName + "." + methodName)) {
+ final String propertyName = getPropertyName(methodName);
+ JAVADOC_FOR_MODULE_OR_PROPERTY.put(propertyName, ast);
+ }
+ }
+
+ }
+ else if (BlockCommentPosition.isOnClass(blockCommentAst)) {
+ final DetailAST classDef = getParentAst(blockCommentAst, TokenTypes.CLASS_DEF);
+ if (classDef != null) {
+ final String className = classDef.findFirstToken(TokenTypes.IDENT).getText();
+ if (className.equals(moduleName)) {
+ JAVADOC_FOR_MODULE_OR_PROPERTY.put(moduleName, ast);
+ }
+ }
+ }
+ }
+
+ /**
+ * Checks if the given method is a method of the module being scraped. Traverses
+ * parent nodes until it finds the class definition and checks if the class name
+ * is the same as the module name. We want to avoid scraping javadocs from
+ * inner classes.
+ *
+ * @param methodDef the method definition.
+ * @return true if the method is a method of the given module, false otherwise.
+ */
+ private static boolean isMethodOfScrapedModule(DetailAST methodDef) {
+ final DetailAST classDef = getParentAst(methodDef, TokenTypes.CLASS_DEF);
+
+ boolean isMethodOfModule = false;
+ if (classDef != null) {
+ final String className = classDef.findFirstToken(TokenTypes.IDENT).getText();
+ isMethodOfModule = className.equals(moduleName);
+ }
+
+ return isMethodOfModule;
+ }
+
+ /**
+ * Get the parent node of the given type. Traverses up the tree until it finds
+ * the given type.
+ *
+ * @param ast the node to start traversing from.
+ * @param type the type of the parent node to find.
+ * @return the parent node of the given type, or null if not found.
+ */
+ private static DetailAST getParentAst(DetailAST ast, int type) {
+ DetailAST node = ast.getParent();
+
+ while (node != null && node.getType() != type) {
+ node = node.getParent();
+ }
+
+ return node;
+ }
+
+ /**
+ * Get the property name from the setter method name. For example, getPropertyName("setFoo")
+ * returns "foo". This method removes the "set" prefix and decapitalizes the first letter
+ * of the property name.
+ *
+ * @param setterName the setter method name.
+ * @return the property name.
+ */
+ private static String getPropertyName(String setterName) {
+ return Introspector.decapitalize(setterName.substring("set".length()));
+ }
+
+ /**
+ * Returns whether an AST represents a setter method.
+ *
+ * @param ast the AST to check with
+ * @return whether the AST represents a setter method
+ */
+ private static boolean isSetterMethod(DetailAST ast) {
+ boolean setterMethod = false;
+
+ // Check have a method with exactly 7 children which are all that
+ // is allowed in a proper setter method which does not throw any
+ // exceptions.
+ final int setterGetterMaxChildren = 7;
+ if (ast.getType() == TokenTypes.METHOD_DEF
+ && ast.getChildCount() == setterGetterMaxChildren) {
+ final DetailAST type = ast.findFirstToken(TokenTypes.TYPE);
+ final String name = type.getNextSibling().getText();
+ final Pattern setterPattern = Pattern.compile("^set[A-Z].*");
+ final boolean matchesSetterFormat = setterPattern.matcher(name).matches();
+
+ final DetailAST params = ast.findFirstToken(TokenTypes.PARAMETERS);
+ final boolean singleParam = params.getChildCount(TokenTypes.PARAMETER_DEF) == 1;
+
+ if (matchesSetterFormat && singleParam) {
+ // Now verify that the body consists of:
+ // SLIST -> EXPR -> ASSIGN
+ // SEMI
+ // RCURLY
+ final DetailAST slist = ast.findFirstToken(TokenTypes.SLIST);
+
+ // Maximum nodes allowed in a body of setter
+ final int setterBodySize = 3;
+ if (slist != null && slist.getChildCount() == setterBodySize) {
+ final DetailAST expr = slist.getFirstChild();
+ setterMethod = expr.getFirstChild().getType() == TokenTypes.ASSIGN;
+ }
+ }
+ }
+ return setterMethod;
+ }
+}
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/site/ParentModuleMacro.java b/src/main/java/com/puppycrawl/tools/checkstyle/site/ParentModuleMacro.java
index 22bc5127774..5e95ba26882 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/site/ParentModuleMacro.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/ParentModuleMacro.java
@@ -84,7 +84,7 @@ private static void createParentModuleParagraph(XdocSink sink, Class> clss, St
*/
private static String getLinkToParentModule(String parentModule, String moduleName)
throws MacroExecutionException {
- final Path templatePath = getTemplatePath(moduleName);
+ final Path templatePath = SiteUtil.getTemplatePath(moduleName);
if (templatePath == null) {
throw new MacroExecutionException(
String.format(Locale.ROOT, "Could not find template for %s", moduleName));
@@ -100,22 +100,4 @@ private static String getLinkToParentModule(String parentModule, String moduleNa
.replace('\\', '/')
+ "#" + parentModule;
}
-
- /**
- * Returns path to the template for the given module name or throws an exception if the
- * template cannot be found.
- *
- * @param moduleName the module whose template we are looking for.
- * @return path to the template.
- * @throws MacroExecutionException if the template cannot be found.
- */
- private static Path getTemplatePath(String moduleName) throws MacroExecutionException {
- final String fileNamePattern = ".*[\\\\/]"
- + moduleName.toLowerCase(Locale.ROOT) + "\\..*";
- return SiteUtil.getXdocsTemplatesFilePaths()
- .stream()
- .filter(path -> path.toString().matches(fileNamePattern))
- .findFirst()
- .orElse(null);
- }
}
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/site/PropertiesMacro.java b/src/main/java/com/puppycrawl/tools/checkstyle/site/PropertiesMacro.java
new file mode 100644
index 00000000000..60cde7758ce
--- /dev/null
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/PropertiesMacro.java
@@ -0,0 +1,404 @@
+///////////////////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code and other text files for adherence to a set of rules.
+// Copyright (C) 2001-2023 the original author or authors.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+package com.puppycrawl.tools.checkstyle.site;
+
+import java.io.File;
+import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.apache.maven.doxia.macro.AbstractMacro;
+import org.apache.maven.doxia.macro.Macro;
+import org.apache.maven.doxia.macro.MacroExecutionException;
+import org.apache.maven.doxia.macro.MacroRequest;
+import org.apache.maven.doxia.module.xdoc.XdocSink;
+import org.apache.maven.doxia.sink.Sink;
+import org.codehaus.plexus.component.annotations.Component;
+
+import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
+import com.puppycrawl.tools.checkstyle.api.DetailNode;
+import com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck;
+import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
+import com.puppycrawl.tools.checkstyle.utils.JavadocUtil;
+import com.puppycrawl.tools.checkstyle.utils.TokenUtil;
+
+/**
+ * A macro that inserts a table of properties for the given checkstyle module.
+ */
+@Component(role = Macro.class, hint = "properties")
+public class PropertiesMacro extends AbstractMacro {
+
+ /** A newline with 10 spaces of indentation. */
+ private static final String INDENT_LEVEL_10 = SiteUtil.getNewlineAndIndentSpaces(10);
+ /** A newline with 12 spaces of indentation. */
+ private static final String INDENT_LEVEL_12 = SiteUtil.getNewlineAndIndentSpaces(12);
+ /** A newline with 14 spaces of indentation. */
+ private static final String INDENT_LEVEL_14 = SiteUtil.getNewlineAndIndentSpaces(14);
+ /** A newline with 16 spaces of indentation. */
+ private static final String INDENT_LEVEL_16 = SiteUtil.getNewlineAndIndentSpaces(16);
+ /** A newline with 18 spaces of indentation. */
+ private static final String INDENT_LEVEL_18 = SiteUtil.getNewlineAndIndentSpaces(18);
+ /** A newline with 20 spaces of indentation. */
+ private static final String INDENT_LEVEL_20 = SiteUtil.getNewlineAndIndentSpaces(20);
+
+ /** The name of the current module being processed. */
+ private static String currentModuleName = "";
+
+ /** The file of the current module being processed. */
+ private static File currentModuleFile = new File("");
+
+ @Override
+ public void execute(Sink sink, MacroRequest request) throws MacroExecutionException {
+ // until https://github.com/checkstyle/checkstyle/issues/13426
+ if (!(sink instanceof XdocSink)) {
+ throw new MacroExecutionException("Expected Sink to be an XdocSink.");
+ }
+
+ final String modulePath = (String) request.getParameter("modulePath");
+ configureGlobalProperties(modulePath);
+
+ writePropertiesTable((XdocSink) sink);
+ }
+
+ /**
+ * Configures the global properties for the current module.
+ *
+ * @param modulePath the path of the current module processed.
+ */
+ private static void configureGlobalProperties(String modulePath) {
+ final File moduleFile = new File(modulePath);
+ currentModuleFile = moduleFile;
+ currentModuleName = CommonUtil.getFileNameWithoutExtension(moduleFile.getName());
+ }
+
+ /**
+ * Writes the properties table for the given module. Expects that the module has been processed
+ * with the ClassAndPropertiesSettersJavadocScraper before calling this method.
+ *
+ * @param sink the sink to write to.
+ * @throws MacroExecutionException if an error occurs during writing.
+ */
+ private static void writePropertiesTable(XdocSink sink)
+ throws MacroExecutionException {
+ sink.table();
+ sink.setInsertNewline(false);
+ sink.tableRows(null, false);
+ sink.rawText(INDENT_LEVEL_12);
+ writeTableHeaderRow(sink);
+ writeTablePropertiesRows(sink);
+ sink.rawText(INDENT_LEVEL_10);
+ sink.tableRows_();
+ sink.table_();
+ sink.setInsertNewline(true);
+ }
+
+ /**
+ * Writes the table header row with 5 columns - name, description, type, default value, since.
+ *
+ * @param sink sink to write to.
+ */
+ private static void writeTableHeaderRow(Sink sink) {
+ sink.tableRow();
+ writeTableHeaderCell(sink, "name");
+ writeTableHeaderCell(sink, "description");
+ writeTableHeaderCell(sink, "type");
+ writeTableHeaderCell(sink, "default value");
+ writeTableHeaderCell(sink, "since");
+ sink.rawText(INDENT_LEVEL_12);
+ sink.tableRow_();
+ }
+
+ /**
+ * Writes a table header cell with the given text.
+ *
+ * @param sink sink to write to.
+ * @param text the text to write.
+ */
+ private static void writeTableHeaderCell(Sink sink, String text) {
+ sink.rawText(INDENT_LEVEL_14);
+ sink.tableHeaderCell();
+ sink.text(text);
+ sink.tableHeaderCell_();
+ }
+
+ /**
+ * Writes the rows of the table with the 5 columns - name, description, type, default value,
+ * since. Each row corresponds to a property of the module.
+ *
+ * @param sink sink to write to.
+ * @throws MacroExecutionException if an error occurs during writing.
+ */
+ private static void writeTablePropertiesRows(Sink sink)
+ throws MacroExecutionException {
+ final Object instance = SiteUtil.getModuleInstance(currentModuleName);
+ final Class> clss = instance.getClass();
+
+ final Set properties = SiteUtil.getPropertiesForDocumentation(clss, instance);
+ final Map propertiesJavadocs = SiteUtil
+ .getPropertiesJavadocs(properties, currentModuleName, currentModuleFile);
+
+ for (String property : properties) {
+ final DetailNode propertyJavadoc = propertiesJavadocs.get(property);
+ final DetailNode currentModuleJavadoc = propertiesJavadocs.get(currentModuleName);
+ writePropertyRow(sink, property, propertyJavadoc, instance, currentModuleJavadoc);
+ }
+ }
+
+ /**
+ * Writes a table row with 5 columns for the given property - name, description, type,
+ * default value, since.
+ *
+ * @param sink sink to write to.
+ * @param propertyName the name of the property.
+ * @param propertyJavadoc the Javadoc of the property.
+ * @param instance the instance of the module.
+ * @param moduleJavadoc the Javadoc of the module.
+ * @throws MacroExecutionException if an error occurs during writing.
+ */
+ private static void writePropertyRow(Sink sink, String propertyName,
+ DetailNode propertyJavadoc, Object instance,
+ DetailNode moduleJavadoc)
+ throws MacroExecutionException {
+ final Field field = SiteUtil.getField(instance.getClass(), propertyName);
+
+ sink.rawText(INDENT_LEVEL_12);
+ sink.tableRow();
+
+ writePropertyNameCell(sink, propertyName);
+ writePropertyDescriptionCell(sink, propertyName, propertyJavadoc);
+ writePropertyTypeCell(sink, propertyName, field, instance);
+ writePropertyDefaultValueCell(sink, propertyName, field, instance);
+ writePropertySinceVersionCell(
+ sink, propertyName, moduleJavadoc, propertyJavadoc);
+
+ sink.rawText(INDENT_LEVEL_12);
+ sink.tableRow_();
+ }
+
+ /**
+ * Writes a table cell with the given property name.
+ *
+ * @param sink sink to write to.
+ * @param propertyName the name of the property.
+ */
+ private static void writePropertyNameCell(Sink sink, String propertyName) {
+ sink.rawText(INDENT_LEVEL_14);
+ sink.tableCell();
+ sink.text(propertyName);
+ sink.tableCell_();
+ }
+
+ /**
+ * Writes a table cell with the property description.
+ *
+ * @param sink sink to write to.
+ * @param propertyName the name of the property.
+ * @param propertyJavadoc the Javadoc of the property containing the description.
+ * @throws MacroExecutionException if an error occurs during retrieval of the description.
+ */
+ private static void writePropertyDescriptionCell(Sink sink, String propertyName,
+ DetailNode propertyJavadoc)
+ throws MacroExecutionException {
+ sink.rawText(INDENT_LEVEL_14);
+ sink.tableCell();
+ final String description = SiteUtil
+ .getPropertyDescription(propertyName, propertyJavadoc, currentModuleName);
+ sink.rawText(description);
+ sink.tableCell_();
+ }
+
+ /**
+ * Writes a table cell with the property type.
+ *
+ * @param sink sink to write to.
+ * @param propertyName the name of the property.
+ * @param field the field of the property.
+ * @param instance the instance of the module.
+ * @throws MacroExecutionException if link to the property_types.html file cannot be
+ * constructed.
+ */
+ private static void writePropertyTypeCell(Sink sink, String propertyName,
+ Field field, Object instance)
+ throws MacroExecutionException {
+ sink.rawText(INDENT_LEVEL_14);
+ sink.tableCell();
+
+ if (SiteUtil.TOKENS.equals(propertyName)) {
+ final AbstractCheck check = (AbstractCheck) instance;
+ if (check.getRequiredTokens().length == 0
+ && Arrays.equals(check.getAcceptableTokens(), TokenUtil.getAllTokenIds())) {
+ sink.text(SiteUtil.TOKEN_TYPES);
+ }
+ else {
+ final List configurableTokens = SiteUtil
+ .getDifference(check.getAcceptableTokens(),
+ check.getRequiredTokens())
+ .stream()
+ .map(TokenUtil::getTokenName)
+ .collect(Collectors.toList());
+ sink.text("subset of tokens");
+ writeTokensList(sink, configurableTokens, SiteUtil.PATH_TO_TOKEN_TYPES);
+ }
+ }
+ else if (SiteUtil.JAVADOC_TOKENS.equals(propertyName)) {
+ final AbstractJavadocCheck check = (AbstractJavadocCheck) instance;
+ final List configurableTokens = SiteUtil
+ .getDifference(check.getAcceptableJavadocTokens(),
+ check.getRequiredJavadocTokens())
+ .stream()
+ .map(JavadocUtil::getTokenName)
+ .collect(Collectors.toList());
+ sink.text("subset of javadoc tokens");
+ writeTokensList(sink, configurableTokens, SiteUtil.PATH_TO_JAVADOC_TOKEN_TYPES);
+ }
+ else {
+ final String type = SiteUtil.getType(field, propertyName, currentModuleName, instance);
+ final String relativePathToPropertyTypes =
+ SiteUtil.getLinkToDocument(currentModuleName, "property_types.xml");
+ final String escapedType = type
+ .replace("[", ".5B")
+ .replace("]", ".5D");
+ final String url =
+ String.format(Locale.ROOT, "%s#%s", relativePathToPropertyTypes, escapedType);
+ sink.link(url);
+ sink.text(type);
+ sink.link_();
+ }
+ sink.tableCell_();
+ }
+
+ /**
+ * Write a list of tokens with links to the tokenTypesLink file.
+ *
+ * @param sink sink to write to.
+ * @param tokens the list of tokens to write.
+ * @param tokenTypesLink the link to the token types file.
+ * @throws MacroExecutionException if link to the tokenTypesLink file cannot be constructed.
+ */
+ private static void writeTokensList(Sink sink, List tokens, String tokenTypesLink)
+ throws MacroExecutionException {
+ for (int index = 0; index < tokens.size(); index++) {
+ final String token = tokens.get(index);
+ sink.rawText(INDENT_LEVEL_16);
+ if (index != 0) {
+ sink.text(SiteUtil.COMMA_SPACE);
+ }
+ writeLinkToToken(sink, tokenTypesLink, token);
+ }
+ sink.rawText(INDENT_LEVEL_18);
+ sink.text(SiteUtil.DOT);
+ sink.rawText(INDENT_LEVEL_14);
+ }
+
+ /**
+ * Writes a link to the given token.
+ *
+ * @param sink sink to write to.
+ * @param document the document to link to.
+ * @param tokenName the name of the token.
+ * @throws MacroExecutionException if link to the document file cannot be constructed.
+ */
+ private static void writeLinkToToken(Sink sink, String document, String tokenName)
+ throws MacroExecutionException {
+ final String link = SiteUtil.getLinkToDocument(currentModuleName, document)
+ + "#" + tokenName;
+ sink.link(link);
+ sink.rawText(INDENT_LEVEL_20);
+ sink.text(tokenName);
+ sink.link_();
+ }
+
+ /**
+ * Writes a table cell with the property default value.
+ *
+ * @param sink sink to write to.
+ * @param propertyName the name of the property.
+ * @param field the field of the property.
+ * @param instance the instance of the module.
+ * @throws MacroExecutionException if an error occurs during retrieval of the default value.
+ */
+ private static void writePropertyDefaultValueCell(Sink sink, String propertyName,
+ Field field, Object instance)
+ throws MacroExecutionException {
+ sink.rawText(INDENT_LEVEL_14);
+ sink.tableCell();
+
+ if (SiteUtil.TOKENS.equals(propertyName)) {
+ final AbstractCheck check = (AbstractCheck) instance;
+ if (check.getRequiredTokens().length == 0
+ && Arrays.equals(check.getDefaultTokens(), TokenUtil.getAllTokenIds())) {
+ sink.text(SiteUtil.TOKEN_TYPES);
+ }
+ else {
+ final List configurableTokens = SiteUtil
+ .getDifference(check.getDefaultTokens(),
+ check.getRequiredTokens())
+ .stream()
+ .map(TokenUtil::getTokenName)
+ .collect(Collectors.toList());
+ writeTokensList(sink, configurableTokens, SiteUtil.PATH_TO_TOKEN_TYPES);
+ }
+ }
+ else if (SiteUtil.JAVADOC_TOKENS.equals(propertyName)) {
+ final AbstractJavadocCheck check = (AbstractJavadocCheck) instance;
+ final List configurableTokens = SiteUtil
+ .getDifference(check.getDefaultJavadocTokens(),
+ check.getRequiredJavadocTokens())
+ .stream()
+ .map(JavadocUtil::getTokenName)
+ .collect(Collectors.toList());
+ writeTokensList(sink, configurableTokens, SiteUtil.PATH_TO_JAVADOC_TOKEN_TYPES);
+ }
+ else {
+ final String defaultValue = SiteUtil.getDefaultValue(
+ propertyName, field, instance, currentModuleName);
+ sink.rawText("");
+ sink.text(defaultValue);
+ sink.rawText("");
+ }
+
+ sink.tableCell_();
+ }
+
+ /**
+ * Writes a table cell with the property since version.
+ *
+ * @param sink sink to write to.
+ * @param propertyName the name of the property.
+ * @param moduleJavadoc the Javadoc of the module.
+ * @param propertyJavadoc the Javadoc of the property containing the since version.
+ * @throws MacroExecutionException if an error occurs during retrieval of the since version.
+ */
+ private static void writePropertySinceVersionCell(Sink sink, String propertyName,
+ DetailNode moduleJavadoc,
+ DetailNode propertyJavadoc)
+ throws MacroExecutionException {
+ sink.rawText(INDENT_LEVEL_14);
+ sink.tableCell();
+ final String sinceVersion = SiteUtil.getSinceVersion(
+ currentModuleName, moduleJavadoc, propertyName, propertyJavadoc);
+ sink.text(sinceVersion);
+ sink.tableCell_();
+ }
+}
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 e63ed6b6e6c..9abdbc9db07 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java
@@ -19,42 +19,104 @@
package com.puppycrawl.tools.checkstyle.site;
+import java.beans.PropertyDescriptor;
+import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Array;
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.ParameterizedType;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collection;
+import java.util.Deque;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import java.util.stream.IntStream;
import java.util.stream.Stream;
+import org.apache.commons.beanutils.PropertyUtils;
import org.apache.maven.doxia.macro.MacroExecutionException;
+import com.google.common.collect.Lists;
import com.puppycrawl.tools.checkstyle.Checker;
+import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.ModuleFactory;
import com.puppycrawl.tools.checkstyle.PackageNamesLoader;
import com.puppycrawl.tools.checkstyle.PackageObjectFactory;
+import com.puppycrawl.tools.checkstyle.PropertyCacheFile;
import com.puppycrawl.tools.checkstyle.TreeWalker;
import com.puppycrawl.tools.checkstyle.TreeWalkerFilter;
+import com.puppycrawl.tools.checkstyle.XdocsPropertyType;
import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck;
import com.puppycrawl.tools.checkstyle.api.BeforeExecutionFileFilter;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
+import com.puppycrawl.tools.checkstyle.api.DetailNode;
import com.puppycrawl.tools.checkstyle.api.Filter;
+import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes;
+import com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck;
+import com.puppycrawl.tools.checkstyle.checks.naming.AccessModifierOption;
import com.puppycrawl.tools.checkstyle.checks.regexp.RegexpMultilineCheck;
import com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck;
import com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck;
+import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
+import com.puppycrawl.tools.checkstyle.utils.JavadocUtil;
+import com.puppycrawl.tools.checkstyle.utils.TokenUtil;
/**
* Utility class for site generation.
*/
public final class SiteUtil {
- /** Class name and their corresponding parent module name.. */
+ /** The string 'tokens'. */
+ public static final String TOKENS = "tokens";
+ /** The string 'javadocTokens'. */
+ public static final String JAVADOC_TOKENS = "javadocTokens";
+ /** The string '.'. */
+ public static final String DOT = ".";
+ /** The string ', '. */
+ public static final String COMMA_SPACE = ", ";
+ /** The string 'TokenTypes'. */
+ public static final String TOKEN_TYPES = "TokenTypes";
+ /** The path to the TokenTypes.html file. */
+ public static final String PATH_TO_TOKEN_TYPES =
+ "apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html";
+ /** The path to the JavadocTokenTypes.html file. */
+ public static final String PATH_TO_JAVADOC_TOKEN_TYPES =
+ "apidocs/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.html";
+ /** The url of the checkstyle website. */
+ private static final String CHECKSTYLE_ORG_URL = "https://checkstyle.org/";
+ /** The string 'charset'. */
+ private static final String CHARSET = "charset";
+ /** The string '{}'. */
+ private static final String CURLY_BRACKETS = "{}";
+ /** The string 'fileExtensions'. */
+ private static final String FILE_EXTENSIONS = "fileExtensions";
+ /** The string 'checks'. */
+ private static final String CHECKS = "checks";
+ /** The string 'naming'. */
+ private static final String NAMING = "naming";
+ /** The string 'src'. */
+ private static final String SRC = "src";
+
+ /** Class name and their corresponding parent module name. */
private static final Map, String> CLASS_TO_PARENT_MODULE = Map.ofEntries(
Map.entry(AbstractCheck.class, TreeWalker.class.getSimpleName()),
Map.entry(TreeWalkerFilter.class, TreeWalker.class.getSimpleName()),
@@ -63,6 +125,67 @@ public final class SiteUtil {
Map.entry(BeforeExecutionFileFilter.class, Checker.class.getSimpleName())
);
+ /** Set of properties that every check has. */
+ private static final Set CHECK_PROPERTIES =
+ getProperties(AbstractCheck.class);
+
+ /** Set of properties that every Javadoc check has. */
+ private static final Set JAVADOC_CHECK_PROPERTIES =
+ getProperties(AbstractJavadocCheck.class);
+
+ /** Set of properties that every FileSet check has. */
+ private static final Set FILESET_PROPERTIES =
+ getProperties(AbstractFileSetCheck.class);
+
+ /** Set of properties that are undocumented. Those are internal properties. */
+ private static final Set UNDOCUMENTED_PROPERTIES = Set.of(
+ "SuppressWithNearbyCommentFilter.fileContents",
+ "SuppressionCommentFilter.fileContents"
+ );
+
+ /** Properties that can not be gathered from class instance. */
+ private static final Set PROPERTIES_ALLOWED_GET_TYPES_FROM_METHOD = Set.of(
+ // static field (all upper case)
+ "SuppressWarningsHolderCheck.aliasList",
+ // loads string into memory similar to file
+ "HeaderCheck.header",
+ "RegexpHeaderCheck.header",
+ // until https://github.com/checkstyle/checkstyle/issues/13376
+ "CustomImportOrderCheck.customImportOrderRules"
+ );
+
+ /**
+ * Map of properties whose since version is different from module version but
+ * are not specified in code because they are inherited from their super class(es).
+ */
+ private static final Map SINCE_VERSION_FOR_INHERITED_PROPERTY = Map.ofEntries(
+ Map.entry("MissingDeprecatedCheck.violateExecutionOnNonTightHtml", "8.24"),
+ Map.entry("NonEmptyAtclauseDescriptionCheck.violateExecutionOnNonTightHtml", "8.3"),
+ Map.entry("NonEmptyAtclauseDescriptionCheck.javadocTokens", "7.3")
+ );
+
+ /** Map of all superclasses properties and their javadocs. */
+ private static final Map SUPER_CLASS_PROPERTIES_JAVADOCS =
+ new HashMap<>();
+
+ /** Path to main source code folder. */
+ private static final String MAIN_FOLDER_PATH = Paths.get(
+ SRC, "main", "java", "com", "puppycrawl", "tools", "checkstyle").toString();
+
+ /** List of files who are superclasses and contain certain properties that checks inherit. */
+ private static final List MODULE_SUPER_CLASS_FILES = List.of(
+ new File(Paths.get(MAIN_FOLDER_PATH,
+ CHECKS, NAMING, "AbstractAccessControlNameCheck.java").toString()),
+ new File(Paths.get(MAIN_FOLDER_PATH,
+ CHECKS, NAMING, "AbstractNameCheck.java").toString()),
+ new File(Paths.get(MAIN_FOLDER_PATH,
+ CHECKS, "javadoc", "AbstractJavadocCheck.java").toString()),
+ new File(Paths.get(MAIN_FOLDER_PATH,
+ "api", "AbstractFileSetCheck.java").toString()),
+ new File(Paths.get(MAIN_FOLDER_PATH,
+ CHECKS, "header", "AbstractHeaderCheck.java").toString())
+ );
+
/**
* Private utility constructor.
*/
@@ -82,7 +205,7 @@ public static Set getMessageKeys(Class> module)
// We use a TreeSet to sort the message keys alphabetically
final Set messageKeys = new TreeSet<>();
for (Field field : messageKeyFields) {
- messageKeys.add(getFieldValue(field, module));
+ messageKeys.add(getFieldValue(field, module).toString());
}
return messageKeys;
}
@@ -147,12 +270,12 @@ else if (module == RegexpSinglelineCheck.class
* @return the value of the field.
* @throws MacroExecutionException if the value could not be retrieved.
*/
- private static String getFieldValue(Field field, Object instance)
+ public static Object getFieldValue(Field field, Object instance)
throws MacroExecutionException {
try {
// required for package/private classes
field.trySetAccessible();
- return field.get(instance).toString();
+ return field.get(instance);
}
catch (IllegalAccessException ex) {
throw new MacroExecutionException("Couldn't get field value", ex);
@@ -207,6 +330,24 @@ public static String getNewlineAndIndentSpaces(int amountOfSpaces) {
return System.lineSeparator() + " ".repeat(amountOfSpaces);
}
+ /**
+ * Returns path to the template for the given module name or throws an exception if the
+ * template cannot be found.
+ *
+ * @param moduleName the module whose template we are looking for.
+ * @return path to the template.
+ * @throws MacroExecutionException if the template cannot be found.
+ */
+ public static Path getTemplatePath(String moduleName) throws MacroExecutionException {
+ final String fileNamePattern = ".*[\\\\/]"
+ + moduleName.toLowerCase(Locale.ROOT) + "\\..*";
+ return getXdocsTemplatesFilePaths()
+ .stream()
+ .filter(path -> path.toString().matches(fileNamePattern))
+ .findFirst()
+ .orElse(null);
+ }
+
/**
* Gets xdocs template file paths. These are files ending with .xml.template.
* This method will be changed to gather .xml once
@@ -269,4 +410,806 @@ public static String getParentModule(Class> moduleClass)
return parentModuleName;
}
+
+ /**
+ * Get a set of properties for the given class that should be documented.
+ *
+ * @param clss the class to get the properties for.
+ * @param instance the instance of the module.
+ * @return a set of properties for the given class.
+ */
+ public static Set getPropertiesForDocumentation(Class> clss, Object instance) {
+ final Set properties =
+ getProperties(clss).stream()
+ .filter(prop -> {
+ return !isGlobalProperty(clss, prop) && !isUndocumentedProperty(clss, prop);
+ })
+ .collect(Collectors.toSet());
+ properties.addAll(getNonExplicitProperties(instance, clss));
+ return new TreeSet<>(properties);
+ }
+
+ /**
+ * Get the javadocs of the properties of the module. If the property is not present in the
+ * module, then the javadoc of the property from the superclass(es) is used.
+ *
+ * @param properties the properties of the module.
+ * @param moduleName the name of the module.
+ * @param moduleFile the module file.
+ * @return the javadocs of the properties of the module.
+ * @throws MacroExecutionException if an error occurs during processing.
+ */
+ public static Map getPropertiesJavadocs(Set properties,
+ String moduleName, File moduleFile)
+ throws MacroExecutionException {
+ // lazy initialization
+ if (SUPER_CLASS_PROPERTIES_JAVADOCS.isEmpty()) {
+ processSuperclasses();
+ }
+
+ processModule(moduleName, moduleFile);
+
+ final Map unmodifiableJavadocs =
+ ClassAndPropertiesSettersJavadocScraper.getJavadocsForModuleOrProperty();
+ final Map javadocs = new LinkedHashMap<>(unmodifiableJavadocs);
+ properties.forEach(property -> {
+ javadocs.putIfAbsent(property, SUPER_CLASS_PROPERTIES_JAVADOCS.get(property));
+ });
+ return javadocs;
+ }
+
+ /**
+ * Collect the properties setters javadocs of the superclasses.
+ *
+ * @throws MacroExecutionException if an error occurs during processing.
+ */
+ private static void processSuperclasses() throws MacroExecutionException {
+ for (File superclassFile : MODULE_SUPER_CLASS_FILES) {
+ final String superclassName = CommonUtil
+ .getFileNameWithoutExtension(superclassFile.getName());
+ processModule(superclassName, superclassFile);
+ final Map superclassJavadocs =
+ ClassAndPropertiesSettersJavadocScraper.getJavadocsForModuleOrProperty();
+ SUPER_CLASS_PROPERTIES_JAVADOCS.putAll(superclassJavadocs);
+ }
+ }
+
+ /**
+ * Scrape the Javadocs of the class and its properties setters with
+ * ClassAndPropertiesSettersJavadocScraper.
+ *
+ * @param moduleName the name of the module.
+ * @param moduleFile the module file.
+ * @throws MacroExecutionException if an error occurs during processing.
+ */
+ private static void processModule(String moduleName, File moduleFile)
+ throws MacroExecutionException {
+ if (!moduleFile.isFile()) {
+ final String message = String.format(Locale.ROOT,
+ "File %s is not a file. Please check the 'modulePath' property.", moduleFile);
+ throw new MacroExecutionException(message);
+ }
+ ClassAndPropertiesSettersJavadocScraper.initialize(moduleName);
+ final Checker checker = new Checker();
+ checker.setModuleClassLoader(Checker.class.getClassLoader());
+ final DefaultConfiguration scraperCheckConfig =
+ new DefaultConfiguration(
+ ClassAndPropertiesSettersJavadocScraper.class.getName());
+ final DefaultConfiguration defaultConfiguration =
+ new DefaultConfiguration("configuration");
+ final DefaultConfiguration treeWalkerConfig =
+ new DefaultConfiguration(TreeWalker.class.getName());
+ defaultConfiguration.addProperty(CHARSET, StandardCharsets.UTF_8.name());
+ defaultConfiguration.addChild(treeWalkerConfig);
+ treeWalkerConfig.addChild(scraperCheckConfig);
+ try {
+ checker.configure(defaultConfiguration);
+ final List filesToProcess = List.of(moduleFile);
+ checker.process(filesToProcess);
+ checker.destroy();
+ }
+ catch (CheckstyleException checkstyleException) {
+ final String message = String.format(Locale.ROOT, "Failed processing %s", moduleName);
+ throw new MacroExecutionException(message, checkstyleException);
+ }
+ }
+
+ /**
+ * Get a set of properties for the given class.
+ *
+ * @param clss the class to get the properties for.
+ * @return a set of properties for the given class.
+ */
+ public static Set getProperties(Class> clss) {
+ final Set result = new TreeSet<>();
+ final PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(clss);
+
+ for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
+ if (propertyDescriptor.getWriteMethod() != null) {
+ result.add(propertyDescriptor.getName());
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Checks if the property is a global property. Global properties come from the base classes
+ * and are common to all checks. For example id, severity, tabWidth, etc.
+ *
+ * @param clss the class of the module.
+ * @param propertyName the name of the property.
+ * @return true if the property is a global property.
+ */
+ private static boolean isGlobalProperty(Class> clss, String propertyName) {
+ return AbstractCheck.class.isAssignableFrom(clss)
+ && CHECK_PROPERTIES.contains(propertyName)
+ || AbstractJavadocCheck.class.isAssignableFrom(clss)
+ && JAVADOC_CHECK_PROPERTIES.contains(propertyName)
+ || AbstractFileSetCheck.class.isAssignableFrom(clss)
+ && FILESET_PROPERTIES.contains(propertyName);
+ }
+
+ /**
+ * Checks if the property is supposed to be documented.
+ *
+ * @param clss the class of the module.
+ * @param propertyName the name of the property.
+ * @return true if the property is supposed to be documented.
+ */
+ private static boolean isUndocumentedProperty(Class> clss, String propertyName) {
+ return UNDOCUMENTED_PROPERTIES.contains(clss.getSimpleName() + DOT + propertyName);
+ }
+
+ /**
+ * Gets properties that are not explicitly captured but should be documented if
+ * certain conditions are met.
+ *
+ * @param instance the instance of the module.
+ * @param clss the class of the module.
+ * @return the non explicit properties.
+ */
+ private static Set getNonExplicitProperties(
+ Object instance, Class> clss) {
+ final Set result = new TreeSet<>();
+ if (AbstractCheck.class.isAssignableFrom(clss)) {
+ final AbstractCheck check = (AbstractCheck) instance;
+
+ final int[] acceptableTokens = check.getAcceptableTokens();
+ Arrays.sort(acceptableTokens);
+ final int[] defaultTokens = check.getDefaultTokens();
+ Arrays.sort(defaultTokens);
+ final int[] requiredTokens = check.getRequiredTokens();
+ Arrays.sort(requiredTokens);
+
+ if (!Arrays.equals(acceptableTokens, defaultTokens)
+ || !Arrays.equals(acceptableTokens, requiredTokens)) {
+ result.add(TOKENS);
+ }
+ }
+
+ if (AbstractJavadocCheck.class.isAssignableFrom(clss)) {
+ final AbstractJavadocCheck check = (AbstractJavadocCheck) instance;
+ result.add("violateExecutionOnNonTightHtml");
+
+ final int[] acceptableJavadocTokens = check.getAcceptableJavadocTokens();
+ Arrays.sort(acceptableJavadocTokens);
+ final int[] defaultJavadocTokens = check.getDefaultJavadocTokens();
+ Arrays.sort(defaultJavadocTokens);
+ final int[] requiredJavadocTokens = check.getRequiredJavadocTokens();
+ Arrays.sort(requiredJavadocTokens);
+
+ if (!Arrays.equals(acceptableJavadocTokens, defaultJavadocTokens)
+ || !Arrays.equals(acceptableJavadocTokens, requiredJavadocTokens)) {
+ result.add(JAVADOC_TOKENS);
+ }
+ }
+
+ if (AbstractFileSetCheck.class.isAssignableFrom(clss)) {
+ result.add(FILE_EXTENSIONS);
+ }
+ return result;
+ }
+
+ /**
+ * Get the description of the property.
+ *
+ * @param propertyName the name of the property.
+ * @param javadoc the Javadoc of the property setter method.
+ * @param moduleName the name of the module.
+ * @return the description of the property.
+ * @throws MacroExecutionException if the description could not be extracted.
+ */
+ public static String getPropertyDescription(
+ String propertyName, DetailNode javadoc, String moduleName)
+ throws MacroExecutionException {
+ final String description;
+ if (TOKENS.equals(propertyName)) {
+ description = "tokens to check";
+ }
+ else if (JAVADOC_TOKENS.equals(propertyName)) {
+ description = "javadoc tokens to check";
+ }
+ else {
+ final String descriptionString = DescriptionExtractor
+ .getDescriptionFromJavadoc(javadoc, moduleName)
+ .substring("Setter to ".length());
+ final String firstLetterCapitalized = descriptionString.substring(0, 1)
+ .toUpperCase(Locale.ROOT);
+ description = firstLetterCapitalized + descriptionString.substring(1);
+ }
+ return description;
+ }
+
+ /**
+ * Get the since version of the property.
+ *
+ * @param moduleName the name of the module.
+ * @param moduleJavadoc the Javadoc of the module.
+ * @param propertyName the name of the property.
+ * @param propertyJavadoc the Javadoc of the property setter method.
+ * @return the since version of the property.
+ * @throws MacroExecutionException if the since version could not be extracted.
+ */
+ public static String getSinceVersion(String moduleName, DetailNode moduleJavadoc,
+ String propertyName, DetailNode propertyJavadoc)
+ throws MacroExecutionException {
+ final String sinceVersion;
+ if (SINCE_VERSION_FOR_INHERITED_PROPERTY.containsKey(moduleName + DOT + propertyName)) {
+ sinceVersion = SINCE_VERSION_FOR_INHERITED_PROPERTY
+ .get(moduleName + DOT + propertyName);
+ }
+ else if (SUPER_CLASS_PROPERTIES_JAVADOCS.containsKey(propertyName)
+ || TOKENS.equals(propertyName)
+ || JAVADOC_TOKENS.equals(propertyName)) {
+ // Use module's since version for inherited properties
+ sinceVersion = getSinceVersionFromJavadoc(moduleJavadoc);
+ }
+ else {
+ sinceVersion = getSinceVersionFromJavadoc(propertyJavadoc);
+ }
+
+ if (sinceVersion == null) {
+ final String message = String.format(Locale.ROOT,
+ "Failed to find since version for %s", propertyName);
+ throw new MacroExecutionException(message);
+ }
+
+ return sinceVersion;
+ }
+
+ /**
+ * Extract the since version from the Javadoc.
+ *
+ * @param javadoc the Javadoc to extract the since version from.
+ * @return the since version of the setter.
+ */
+ private static String getSinceVersionFromJavadoc(DetailNode javadoc) {
+ final DetailNode sinceJavadocTag = getSinceJavadocTag(javadoc);
+ final DetailNode description = JavadocUtil.findFirstToken(sinceJavadocTag,
+ JavadocTokenTypes.DESCRIPTION);
+ final DetailNode text = JavadocUtil.findFirstToken(description, JavadocTokenTypes.TEXT);
+ return text.getText();
+ }
+
+ /**
+ * Find the since Javadoc tag node in the given Javadoc.
+ *
+ * @param javadoc the Javadoc to search.
+ * @return the since Javadoc tag node or null if not found.
+ */
+ private static DetailNode getSinceJavadocTag(DetailNode javadoc) {
+ final DetailNode[] children = javadoc.getChildren();
+ DetailNode javadocTagWithSince = null;
+ for (final DetailNode child : children) {
+ if (child.getType() == JavadocTokenTypes.JAVADOC_TAG) {
+ final DetailNode sinceNode = JavadocUtil.findFirstToken(
+ child, JavadocTokenTypes.SINCE_LITERAL);
+ if (sinceNode != null) {
+ javadocTagWithSince = child;
+ break;
+ }
+ }
+ }
+ return javadocTagWithSince;
+ }
+
+ /**
+ * Get the type of the property.
+ *
+ * @param field the field to get the type of.
+ * @param propertyName the name of the property.
+ * @param moduleName the name of the module.
+ * @param instance the instance of the module.
+ * @return the type of the property.
+ * @throws MacroExecutionException if an error occurs during getting the type.
+ */
+ public static String getType(Field field, String propertyName,
+ String moduleName, Object instance)
+ throws MacroExecutionException {
+ final Class> fieldClass = getFieldClass(field, propertyName, moduleName, instance);
+ return Optional.ofNullable(field)
+ .map(nonNullField -> nonNullField.getAnnotation(XdocsPropertyType.class))
+ .map(propertyType -> propertyType.value().getDescription())
+ .orElseGet(fieldClass::getSimpleName);
+ }
+
+ /**
+ * Get the default value of the property.
+ *
+ * @param propertyName the name of the property.
+ * @param field the field to get the default value of.
+ * @param classInstance the instance of the class to get the default value of.
+ * @param moduleName the name of the module.
+ * @return the default value of the property.
+ * @throws MacroExecutionException if an error occurs during getting the default value.
+ * @noinspection IfStatementWithTooManyBranches
+ * @noinspectionreason IfStatementWithTooManyBranches - complex nature of getting properties
+ * from XML files requires giant if/else statement
+ */
+ // -@cs[CyclomaticComplexity] Splitting would not make the code more readable
+ public static String getDefaultValue(String propertyName, Field field,
+ Object classInstance, String moduleName)
+ throws MacroExecutionException {
+ final Object value = getFieldValue(field, classInstance);
+ final Class> fieldClass = getFieldClass(field, propertyName, moduleName, classInstance);
+ String result = null;
+ if (CHARSET.equals(propertyName)) {
+ result = "the charset property of the parent Checker module";
+ }
+ else if (classInstance instanceof PropertyCacheFile) {
+ result = "null (no cache file)";
+ }
+ else if (fieldClass == boolean.class) {
+ result = value.toString();
+ }
+ else if (fieldClass == int.class) {
+ result = value.toString();
+ }
+ else if (fieldClass == int[].class) {
+ result = getIntArrayPropertyValue(value);
+ }
+ else if (fieldClass == double[].class) {
+ result = removeSquareBrackets(Arrays.toString((double[]) value).replace(".0", ""));
+ if (result.isEmpty()) {
+ result = CURLY_BRACKETS;
+ }
+ }
+ else if (fieldClass == String[].class) {
+ result = getStringArrayPropertyValue(propertyName, value);
+ }
+ else if (fieldClass == URI.class || fieldClass == String.class) {
+ if (value != null) {
+ result = '"' + value.toString() + '"';
+ }
+ }
+ else if (fieldClass == Pattern.class) {
+ if (value != null) {
+ result = '"' + value.toString().replace("\n", "\\n").replace("\t", "\\t")
+ .replace("\r", "\\r").replace("\f", "\\f") + '"';
+ }
+ }
+ else if (fieldClass == Pattern[].class) {
+ result = getPatternArrayPropertyValue(value);
+ }
+ else if (fieldClass.isEnum()) {
+ if (value != null) {
+ result = value.toString().toLowerCase(Locale.ENGLISH);
+ }
+ }
+ else if (fieldClass == AccessModifierOption[].class) {
+ result = removeSquareBrackets(Arrays.toString((Object[]) value));
+ }
+ else {
+ final String message = String.format(Locale.ROOT,
+ "Unknown property type: %s", fieldClass.getSimpleName());
+ throw new MacroExecutionException(message);
+ }
+
+ if (result == null) {
+ result = "null";
+ }
+
+ return result;
+ }
+
+ /**
+ * Gets the name of the bean property's default value for the Pattern array class.
+ *
+ * @param fieldValue The bean property's value
+ * @return String form of property's default value
+ */
+ private static String getPatternArrayPropertyValue(Object fieldValue) {
+ Object value = fieldValue;
+ if (value instanceof Collection) {
+ final Collection> collection = (Collection>) value;
+
+ value = collection.stream()
+ .map(Pattern.class::cast)
+ .toArray(Pattern[]::new);
+ }
+
+ String result = "";
+ if (value != null && Array.getLength(value) > 0) {
+ result = removeSquareBrackets(
+ Arrays.stream((Pattern[]) value)
+ .map(Pattern::pattern)
+ .collect(Collectors.joining(COMMA_SPACE)));
+ }
+
+ if (result.isEmpty()) {
+ result = CURLY_BRACKETS;
+ }
+ return result;
+ }
+
+ /**
+ * Removes square brackets [ and ] from the given string.
+ *
+ * @param value the string to remove square brackets from.
+ * @return the string without square brackets.
+ */
+ private static String removeSquareBrackets(String value) {
+ return value
+ .replace("[", "")
+ .replace("]", "");
+ }
+
+ /**
+ * Gets the name of the bean property's default value for the string array class.
+ *
+ * @param propertyName The bean property's name
+ * @param value The bean property's value
+ * @return String form of property's default value
+ */
+ private static String getStringArrayPropertyValue(String propertyName, Object value) {
+ String result;
+ if (value == null) {
+ result = "";
+ }
+ else {
+ try (Stream> valuesStream = getValuesStream(value)) {
+ result = valuesStream
+ .map(String.class::cast)
+ .sorted()
+ .collect(Collectors.joining(COMMA_SPACE));
+ }
+ }
+
+ if (result.isEmpty()) {
+ if (FILE_EXTENSIONS.equals(propertyName)) {
+ result = "all files";
+ }
+ else {
+ result = CURLY_BRACKETS;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Generates a stream of values from the given value.
+ *
+ * @param value the value to generate the stream from.
+ * @return the stream of values.
+ */
+ private static Stream> getValuesStream(Object value) {
+ final Stream> valuesStream;
+ if (value instanceof Collection) {
+ final Collection> collection = (Collection>) value;
+ valuesStream = collection.stream();
+ }
+ else {
+ final Object[] array = (Object[]) value;
+ valuesStream = Arrays.stream(array);
+ }
+ return valuesStream;
+ }
+
+ /**
+ * Returns the name of the bean property's default value for the int array class.
+ *
+ * @param value The bean property's value.
+ * @return String form of property's default value.
+ */
+ private static String getIntArrayPropertyValue(Object value) {
+ try (IntStream stream = getIntStream(value)) {
+ String result = stream
+ .mapToObj(TokenUtil::getTokenName)
+ .sorted()
+ .collect(Collectors.joining(COMMA_SPACE));
+ if (result.isEmpty()) {
+ result = CURLY_BRACKETS;
+ }
+ return result;
+ }
+ }
+
+ /**
+ * Get the int stream from the given value.
+ *
+ * @param value the value to get the int stream from.
+ * @return the int stream.
+ */
+ private static IntStream getIntStream(Object value) {
+ final IntStream stream;
+ if (value instanceof Collection) {
+ final Collection> collection = (Collection>) value;
+ stream = collection.stream()
+ .mapToInt(int.class::cast);
+ }
+ else if (value instanceof BitSet) {
+ stream = ((BitSet) value).stream();
+ }
+ else {
+ stream = Arrays.stream((int[]) value);
+ }
+ return stream;
+ }
+
+ /**
+ * Gets the class of the given field.
+ *
+ * @param field the field to get the class of.
+ * @param propertyName the name of the property.
+ * @param moduleName the name of the module.
+ * @param instance the instance of the module.
+ * @return the class of the field.
+ * @throws MacroExecutionException if an error occurs during getting the class.
+ */
+ // -@cs[CyclomaticComplexity] Splitting would not make the code more readable
+ private static Class> getFieldClass(Field field, String propertyName,
+ String moduleName, Object instance)
+ throws MacroExecutionException {
+ Class> result = null;
+
+ if (field != null) {
+ result = field.getType();
+ }
+ if (result == null) {
+ if (!PROPERTIES_ALLOWED_GET_TYPES_FROM_METHOD
+ .contains(moduleName + DOT + propertyName)) {
+ throw new MacroExecutionException(
+ "Could not find field " + propertyName + " in class " + moduleName);
+ }
+
+ try {
+ final PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(instance,
+ propertyName);
+ result = descriptor.getPropertyType();
+ }
+ catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException exc) {
+ throw new MacroExecutionException(exc.getMessage(), exc);
+ }
+ }
+ if (field != null && (result == List.class || result == Set.class)) {
+ final ParameterizedType type = (ParameterizedType) field.getGenericType();
+ final Class> parameterClass = (Class>) type.getActualTypeArguments()[0];
+
+ if (parameterClass == Integer.class) {
+ result = int[].class;
+ }
+ else if (parameterClass == String.class) {
+ result = String[].class;
+ }
+ else if (parameterClass == Pattern.class) {
+ result = Pattern[].class;
+ }
+ else {
+ final String message = "Unknown parameterized type: "
+ + parameterClass.getSimpleName();
+ throw new MacroExecutionException(message);
+ }
+ }
+ else if (result == BitSet.class) {
+ result = int[].class;
+ }
+
+ return result;
+ }
+
+ /**
+ * Get the difference between two lists of tokens.
+ *
+ * @param tokens the list of tokens to remove from.
+ * @param subtractions the tokens to remove.
+ * @return the difference between the two lists.
+ */
+ public static List getDifference(int[] tokens, int... subtractions) {
+ final Set subtractionsSet = Arrays.stream(subtractions)
+ .boxed()
+ .collect(Collectors.toSet());
+ return Arrays.stream(tokens)
+ .boxed()
+ .filter(token -> !subtractionsSet.contains(token))
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Gets the field with the given name from the given class.
+ *
+ * @param fieldClass the class to get the field from.
+ * @param propertyName the name of the field.
+ * @return the field we are looking for.
+ */
+ public static Field getField(Class> fieldClass, String propertyName) {
+ Field result = null;
+ Class> currentClass = fieldClass;
+
+ while (!Object.class.equals(currentClass)) {
+ try {
+ result = currentClass.getDeclaredField(propertyName);
+ result.trySetAccessible();
+ break;
+ }
+ catch (NoSuchFieldException ignored) {
+ currentClass = currentClass.getSuperclass();
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Constructs string with relative link to the provided document.
+ *
+ * @param moduleName the name of the module.
+ * @param document the path of the document.
+ * @return relative link to the document.
+ * @throws MacroExecutionException if link to the document cannot be constructed.
+ */
+ public static String getLinkToDocument(String moduleName, String document)
+ throws MacroExecutionException {
+ final Path templatePath = getTemplatePath(moduleName.replace("Check", ""));
+ if (templatePath == null) {
+ throw new MacroExecutionException(
+ String.format(Locale.ROOT,
+ "Could not find template for %s", moduleName));
+ }
+ final Path templatePathParent = templatePath.getParent();
+ if (templatePathParent == null) {
+ throw new MacroExecutionException("Failed to get parent path for " + templatePath);
+ }
+ return templatePathParent
+ .relativize(Paths.get(SRC, "xdocs", document))
+ .toString()
+ .replace(".xml", ".html")
+ .replace('\\', '/');
+ }
+
+ /** Utility class for extracting description from a method's Javadoc. */
+ private static final class DescriptionExtractor {
+
+ /**
+ * Extracts the description from the javadoc detail node. Performs a DFS traversal on the
+ * detail node and extracts the text nodes.
+ *
+ * @param javadoc the Javadoc to extract the description from.
+ * @param moduleName the name of the module.
+ * @return the description of the setter.
+ * @throws MacroExecutionException if the description could not be extracted.
+ * @noinspection TooBroadScope
+ * @noinspectionreason TooBroadScope - complex nature of method requires large scope
+ */
+ // -@cs[NPathComplexity] Splitting would not make the code more readable
+ // -@cs[CyclomaticComplexity] Splitting would not make the code more readable.
+ private static String getDescriptionFromJavadoc(DetailNode javadoc, String moduleName)
+ throws MacroExecutionException {
+ boolean isInCodeLiteral = false;
+ boolean isInHtmlElement = false;
+ boolean isInHrefAttribute = false;
+ final StringBuilder description = new StringBuilder(128);
+ final Deque queue = new ArrayDeque<>();
+ final List descriptionNodes = getDescriptionNodes(javadoc);
+ Lists.reverse(descriptionNodes).forEach(queue::push);
+
+ // Perform DFS traversal on description nodes
+ while (!queue.isEmpty()) {
+ final DetailNode node = queue.pop();
+ Lists.reverse(Arrays.asList(node.getChildren())).forEach(queue::push);
+
+ if (node.getType() == JavadocTokenTypes.HTML_TAG_NAME
+ && "href".equals(node.getText())) {
+ isInHrefAttribute = true;
+ }
+ if (isInHrefAttribute && node.getType() == JavadocTokenTypes.ATTR_VALUE) {
+ final String href = node.getText();
+ if (href.contains(CHECKSTYLE_ORG_URL)) {
+ handleInternalLink(description, moduleName, href);
+ }
+ else {
+ description.append(href);
+ }
+
+ isInHrefAttribute = false;
+ continue;
+ }
+ if (node.getType() == JavadocTokenTypes.HTML_ELEMENT) {
+ isInHtmlElement = true;
+ }
+ if (node.getType() == JavadocTokenTypes.END
+ && node.getParent().getType() == JavadocTokenTypes.HTML_ELEMENT_END) {
+ description.append(node.getText());
+ isInHtmlElement = false;
+ }
+ if (node.getType() == JavadocTokenTypes.TEXT
+ // If a node has children, its text is not part of the description
+ || isInHtmlElement && node.getChildren().length == 0
+ // Some HTML elements span multiple lines, so we avoid the asterisk
+ && node.getType() != JavadocTokenTypes.LEADING_ASTERISK) {
+ description.append(node.getText());
+ }
+ if (node.getType() == JavadocTokenTypes.CODE_LITERAL) {
+ isInCodeLiteral = true;
+ description.append("");
+ }
+ if (isInCodeLiteral
+ && node.getType() == JavadocTokenTypes.JAVADOC_INLINE_TAG_END) {
+ isInCodeLiteral = false;
+ description.append("");
+ }
+ }
+ return description.toString().trim();
+ }
+
+ /**
+ * Converts the href value to a relative link to the document and appends it to the
+ * description.
+ *
+ * @param description the description to append the relative link to.
+ * @param moduleName the name of the module.
+ * @param value the href value.
+ * @throws MacroExecutionException if the relative link could not be created.
+ */
+ private static void handleInternalLink(StringBuilder description,
+ String moduleName, String value)
+ throws MacroExecutionException {
+ String href = value;
+ href = href.replace(CHECKSTYLE_ORG_URL, "");
+ // Remove first and last characters, they are always double quotes
+ href = href.substring(1, href.length() - 1);
+
+ final String relativeHref = getLinkToDocument(moduleName, href);
+ final char doubleQuote = '\"';
+ description.append(doubleQuote).append(relativeHref).append(doubleQuote);
+ }
+
+ /**
+ * Extracts description nodes from javadoc.
+ *
+ * @param javadoc the Javadoc to extract the description from.
+ * @return the description nodes of the setter.
+ */
+ private static List getDescriptionNodes(DetailNode javadoc) {
+ final DetailNode[] children = javadoc.getChildren();
+ final List descriptionNodes = new ArrayList<>();
+ for (final DetailNode child : children) {
+ if (isEndOfDescription(child)) {
+ break;
+ }
+ descriptionNodes.add(child);
+ }
+ return descriptionNodes;
+ }
+
+ /**
+ * Determines if the given child index is the end of the description. The end of the
+ * description is defined as 4 consecutive nodes of type NEWLINE, LEADING_ASTERISK, NEWLINE,
+ * LEADING_ASTERISK. This is an asterisk that is alone on a line. Just like the one below
+ * this line.
+ *
+ * @param child the child to check.
+ * @return true if the given child index is the end of the description.
+ */
+ private static boolean isEndOfDescription(DetailNode child) {
+ final DetailNode nextSibling = JavadocUtil.getNextSibling(child);
+ final DetailNode secondNextSibling = JavadocUtil.getNextSibling(nextSibling);
+ final DetailNode thirdNextSibling = JavadocUtil.getNextSibling(secondNextSibling);
+
+ return child.getType() == JavadocTokenTypes.NEWLINE
+ && nextSibling.getType() == JavadocTokenTypes.LEADING_ASTERISK
+ && secondNextSibling.getType() == JavadocTokenTypes.NEWLINE
+ && thirdNextSibling.getType() == JavadocTokenTypes.LEADING_ASTERISK;
+ }
+ }
}
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/site/XdocsTemplateSink.java b/src/main/java/com/puppycrawl/tools/checkstyle/site/XdocsTemplateSink.java
index 798c1046103..7aab543facd 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/site/XdocsTemplateSink.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/XdocsTemplateSink.java
@@ -82,4 +82,27 @@ public void link(String href) {
attributes.addAttribute(SinkEventAttributes.HREF, href);
writeStartTag(HtmlMarkup.A, attributes);
}
+
+ /**
+ * Write a table row tag. We override this method because the default implementation
+ * adds a {@code align="top"} attribute to the row which we don't want.
+ */
+ @Override
+ public void tableRow() {
+ writeStartTag(TR);
+ }
+
+ /**
+ * Write a table tag. We override this method because the default implementation
+ * adds different attributes which we don't want. We ignore the parameters
+ * because we don't need them, but the default implementation will take them
+ * into account once this class is removed.
+ *
+ * @param justification ignored
+ * @param grid ignored
+ */
+ @Override
+ public void tableRows(int[] justification, boolean grid) {
+ writeStartTag(HtmlMarkup.TABLE);
+ }
}
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index 2a2a6741623..dc3b6abaa90 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -315,7 +315,10 @@ public void testAllChecksPresentOnAvailableChecksPage() throws Exception {
CheckUtil.getSimpleNames(CheckUtil.getCheckstyleChecks())
.stream()
- .filter(checkName -> !"JavadocMetadataScraper".equals(checkName))
+ .filter(checkName -> {
+ return !"JavadocMetadataScraper".equals(checkName)
+ && !"ClassAndPropertiesSettersJavadocScraper".equals(checkName);
+ })
.forEach(checkName -> {
if (!isPresent(availableChecks, checkName)) {
assertWithMessage(
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/CheckUtil.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/CheckUtil.java
index ef28d693202..324897c8795 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/CheckUtil.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/CheckUtil.java
@@ -195,7 +195,8 @@ private static Set> getCheckstyleModulesRecursive(
private static boolean isFromAllowedPackages(Class> cls) {
final String canonicalName = cls.getCanonicalName();
return !canonicalName.startsWith("com.puppycrawl.tools.checkstyle.packageobjectfactory")
- && !canonicalName.startsWith("com.puppycrawl.tools.checkstyle.internal.testmodules");
+ && !canonicalName.startsWith("com.puppycrawl.tools.checkstyle.internal.testmodules")
+ && !canonicalName.startsWith("com.puppycrawl.tools.checkstyle.site");
}
/**
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/meta/MetadataGeneratorUtilTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/meta/MetadataGeneratorUtilTest.java
index 8edc5defa5d..2476b4ac42f 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/meta/MetadataGeneratorUtilTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/meta/MetadataGeneratorUtilTest.java
@@ -47,7 +47,8 @@ public final class MetadataGeneratorUtilTest extends AbstractModuleTestSupport {
private final Set modulesContainingNoMetadataFile = Set.of(
"Checker",
"TreeWalker",
- "JavadocMetadataScraper"
+ "JavadocMetadataScraper",
+ "ClassAndPropertiesSettersJavadocScraper"
);
@Override
diff --git a/src/xdocs/checks/annotation/annotationlocation.xml b/src/xdocs/checks/annotation/annotationlocation.xml
index c750bee0e21..fb90dcf3052 100644
--- a/src/xdocs/checks/annotation/annotationlocation.xml
+++ b/src/xdocs/checks/annotation/annotationlocation.xml
@@ -60,16 +60,14 @@ public String getNameIfPresent() { ... }
allowSamelineParameterizedAnnotation
-
Allow one and only parameterized annotation to be located on the same line as
- target element.
+
Allow one and only parameterized annotation to be located on the same line as target element.
From 2d69d7e99e58c5ccf66b644366efd0fa40e1063e Mon Sep 17 00:00:00 2001
From: piyush kumar sadangi
Date: Thu, 24 Aug 2023 16:25:03 +0530
Subject: [PATCH 017/833] Issue #13596: Moved utility methods from CheckUtil to
MissingJavadocMethodCheck
---
.../javadoc/MissingJavadocMethodCheck.java | 87 ++++++++++++++++++-
.../tools/checkstyle/utils/CheckUtil.java | 85 ------------------
.../MissingJavadocMethodCheckTest.java | 63 +++++++++++++-
.../internal/XdocsJavaDocsTest.java | 4 +-
.../tools/checkstyle/utils/CheckUtilTest.java | 67 +++-----------
.../InputMissingJavadocMethodBasic.java} | 4 +-
...nputMissingJavadocMethodSetterGetter3.java | 73 ++++++++++++++++
...putMissingJavadocMethodSetterGetter4.java} | 4 +-
8 files changed, 239 insertions(+), 148 deletions(-)
rename src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/{utils/checkutil/InputCheckUtil1.java => checks/javadoc/missingjavadocmethod/InputMissingJavadocMethodBasic.java} (76%)
create mode 100644 src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadocmethod/InputMissingJavadocMethodSetterGetter3.java
rename src/test/resources/com/puppycrawl/tools/checkstyle/{utils/checkutil/InputCheckUtil9.java => checks/javadoc/missingjavadocmethod/InputMissingJavadocMethodSetterGetter4.java} (84%)
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck.java
index a8b0dda5498..1523da9541b 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck.java
@@ -31,7 +31,6 @@
import com.puppycrawl.tools.checkstyle.api.TextBlock;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
import com.puppycrawl.tools.checkstyle.utils.AnnotationUtil;
-import com.puppycrawl.tools.checkstyle.utils.CheckUtil;
import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
import com.puppycrawl.tools.checkstyle.utils.ScopeUtil;
@@ -142,6 +141,18 @@ public class MissingJavadocMethodCheck extends AbstractCheck {
*/
public static final String MSG_JAVADOC_MISSING = "javadoc.missing";
+ /** Maximum children allowed in setter/getter. */
+ private static final int SETTER_GETTER_MAX_CHILDREN = 7;
+
+ /** Pattern matching names of getter methods. */
+ private static final Pattern GETTER_PATTERN = Pattern.compile("^(is|get)[A-Z].*");
+
+ /** Pattern matching names of setter methods. */
+ private static final Pattern SETTER_PATTERN = Pattern.compile("^set[A-Z].*");
+
+ /** Maximum nodes allowed in a body of setter. */
+ private static final int SETTER_BODY_SIZE = 3;
+
/** Default value of minimal amount of lines in method to allow no documentation.*/
private static final int DEFAULT_MIN_LINE_COUNT = -1;
@@ -290,7 +301,7 @@ private static int getMethodsNumberOfLine(DetailAST methodDef) {
*/
private boolean isMissingJavadocAllowed(final DetailAST ast) {
return allowMissingPropertyJavadoc
- && (CheckUtil.isSetterMethod(ast) || CheckUtil.isGetterMethod(ast))
+ && (isSetterMethod(ast) || isGetterMethod(ast))
|| matchesSkipRegex(ast)
|| isContentsAllowMissingJavadoc(ast);
}
@@ -345,4 +356,76 @@ private boolean shouldCheck(final DetailAST ast, final Scope nodeScope) {
&& surroundingScope.isIn(scope);
}
+ /**
+ * Returns whether an AST represents a getter method.
+ *
+ * @param ast the AST to check with
+ * @return whether the AST represents a getter method
+ */
+ public static boolean isGetterMethod(final DetailAST ast) {
+ boolean getterMethod = false;
+
+ // Check have a method with exactly 7 children which are all that
+ // is allowed in a proper getter method which does not throw any
+ // exceptions.
+ if (ast.getType() == TokenTypes.METHOD_DEF
+ && ast.getChildCount() == SETTER_GETTER_MAX_CHILDREN) {
+ final DetailAST type = ast.findFirstToken(TokenTypes.TYPE);
+ final String name = type.getNextSibling().getText();
+ final boolean matchesGetterFormat = GETTER_PATTERN.matcher(name).matches();
+
+ final DetailAST params = ast.findFirstToken(TokenTypes.PARAMETERS);
+ final boolean noParams = params.getChildCount(TokenTypes.PARAMETER_DEF) == 0;
+
+ if (matchesGetterFormat && noParams) {
+ // Now verify that the body consists of:
+ // SLIST -> RETURN
+ // RCURLY
+ final DetailAST slist = ast.findFirstToken(TokenTypes.SLIST);
+
+ if (slist != null) {
+ final DetailAST expr = slist.getFirstChild();
+ getterMethod = expr.getType() == TokenTypes.LITERAL_RETURN;
+ }
+ }
+ }
+ return getterMethod;
+ }
+
+ /**
+ * Returns whether an AST represents a setter method.
+ *
+ * @param ast the AST to check with
+ * @return whether the AST represents a setter method
+ */
+ public static boolean isSetterMethod(final DetailAST ast) {
+ boolean setterMethod = false;
+
+ // Check have a method with exactly 7 children which are all that
+ // is allowed in a proper setter method which does not throw any
+ // exceptions.
+ if (ast.getType() == TokenTypes.METHOD_DEF
+ && ast.getChildCount() == SETTER_GETTER_MAX_CHILDREN) {
+ final DetailAST type = ast.findFirstToken(TokenTypes.TYPE);
+ final String name = type.getNextSibling().getText();
+ final boolean matchesSetterFormat = SETTER_PATTERN.matcher(name).matches();
+
+ final DetailAST params = ast.findFirstToken(TokenTypes.PARAMETERS);
+ final boolean singleParam = params.getChildCount(TokenTypes.PARAMETER_DEF) == 1;
+
+ if (matchesSetterFormat && singleParam) {
+ // Now verify that the body consists of:
+ // SLIST -> EXPR -> ASSIGN
+ // SEMI
+ // RCURLY
+ final DetailAST slist = ast.findFirstToken(TokenTypes.SLIST);
+
+ if (slist != null && slist.getChildCount() == SETTER_BODY_SIZE) {
+ final DetailAST expr = slist.getFirstChild();
+ setterMethod = expr.getFirstChild().getType() == TokenTypes.ASSIGN;
+ }
+ }
+ }
+ return setterMethod;
+ }
}
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/utils/CheckUtil.java b/src/main/java/com/puppycrawl/tools/checkstyle/utils/CheckUtil.java
index 3e706cd04f7..a45fff620d6 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/utils/CheckUtil.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/utils/CheckUtil.java
@@ -54,21 +54,9 @@ public final class CheckUtil {
/** Hex radix. */
private static final int BASE_16 = 16;
- /** Maximum children allowed in setter/getter. */
- private static final int SETTER_GETTER_MAX_CHILDREN = 7;
-
- /** Maximum nodes allowed in a body of setter. */
- private static final int SETTER_BODY_SIZE = 3;
-
/** Pattern matching underscore characters ('_'). */
private static final Pattern UNDERSCORE_PATTERN = Pattern.compile("_");
- /** Pattern matching names of setter methods. */
- private static final Pattern SETTER_PATTERN = Pattern.compile("^set[A-Z].*");
-
- /** Pattern matching names of getter methods. */
- private static final Pattern GETTER_PATTERN = Pattern.compile("^(is|get)[A-Z].*");
-
/** Compiled pattern for all system newlines. */
private static final Pattern ALL_NEW_LINES = Pattern.compile("\\R");
@@ -280,79 +268,6 @@ public static List getTypeParameters(final DetailAST node) {
return typeParams;
}
- /**
- * Returns whether an AST represents a setter method.
- *
- * @param ast the AST to check with
- * @return whether the AST represents a setter method
- */
- public static boolean isSetterMethod(final DetailAST ast) {
- boolean setterMethod = false;
-
- // Check have a method with exactly 7 children which are all that
- // is allowed in a proper setter method which does not throw any
- // exceptions.
- if (ast.getType() == TokenTypes.METHOD_DEF
- && ast.getChildCount() == SETTER_GETTER_MAX_CHILDREN) {
- final DetailAST type = ast.findFirstToken(TokenTypes.TYPE);
- final String name = type.getNextSibling().getText();
- final boolean matchesSetterFormat = SETTER_PATTERN.matcher(name).matches();
-
- final DetailAST params = ast.findFirstToken(TokenTypes.PARAMETERS);
- final boolean singleParam = params.getChildCount(TokenTypes.PARAMETER_DEF) == 1;
-
- if (matchesSetterFormat && singleParam) {
- // Now verify that the body consists of:
- // SLIST -> EXPR -> ASSIGN
- // SEMI
- // RCURLY
- final DetailAST slist = ast.findFirstToken(TokenTypes.SLIST);
-
- if (slist != null && slist.getChildCount() == SETTER_BODY_SIZE) {
- final DetailAST expr = slist.getFirstChild();
- setterMethod = expr.getFirstChild().getType() == TokenTypes.ASSIGN;
- }
- }
- }
- return setterMethod;
- }
-
- /**
- * Returns whether an AST represents a getter method.
- *
- * @param ast the AST to check with
- * @return whether the AST represents a getter method
- */
- public static boolean isGetterMethod(final DetailAST ast) {
- boolean getterMethod = false;
-
- // Check have a method with exactly 7 children which are all that
- // is allowed in a proper getter method which does not throw any
- // exceptions.
- if (ast.getType() == TokenTypes.METHOD_DEF
- && ast.getChildCount() == SETTER_GETTER_MAX_CHILDREN) {
- final DetailAST type = ast.findFirstToken(TokenTypes.TYPE);
- final String name = type.getNextSibling().getText();
- final boolean matchesGetterFormat = GETTER_PATTERN.matcher(name).matches();
-
- final DetailAST params = ast.findFirstToken(TokenTypes.PARAMETERS);
- final boolean noParams = params.getChildCount(TokenTypes.PARAMETER_DEF) == 0;
-
- if (matchesGetterFormat && noParams) {
- // Now verify that the body consists of:
- // SLIST -> RETURN
- // RCURLY
- final DetailAST slist = ast.findFirstToken(TokenTypes.SLIST);
-
- if (slist != null) {
- final DetailAST expr = slist.getFirstChild();
- getterMethod = expr.getType() == TokenTypes.LITERAL_RETURN;
- }
- }
- }
- return getterMethod;
- }
-
/**
* Checks whether a method is a not void one.
*
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheckTest.java
index eaefbf408c7..eda65da14bc 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheckTest.java
@@ -22,10 +22,14 @@
import static com.google.common.truth.Truth.assertWithMessage;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.MSG_JAVADOC_MISSING;
+import java.io.File;
+
import org.junit.jupiter.api.Test;
import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+import com.puppycrawl.tools.checkstyle.utils.CheckUtilTest;
import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport {
@@ -313,7 +317,7 @@ public void testSetterGetterOff() throws Exception {
}
@Test
- public void testSetterGetterOn() throws Exception {
+ public void testSetterGetterOnCheck() throws Exception {
final String[] expected = {
"30:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"35:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
@@ -467,4 +471,61 @@ public void testAnnotationField() throws Exception {
getPath("InputMissingJavadocMethodAnnotationField.java"),
expected);
}
+
+ @Test
+ public void testIsGetterMethod() throws Exception {
+ final File testFile =
+ new File(getPath("InputMissingJavadocMethodSetterGetter3.java"));
+ final DetailAST notGetterMethod =
+ CheckUtilTest.getNode(testFile, TokenTypes.METHOD_DEF);
+ final DetailAST getterMethod = notGetterMethod.getNextSibling().getNextSibling();
+
+ assertWithMessage("Invalid result: AST provided is getter method")
+ .that(MissingJavadocMethodCheck.isGetterMethod(getterMethod))
+ .isTrue();
+ assertWithMessage("Invalid result: AST provided is not getter method")
+ .that(MissingJavadocMethodCheck.isGetterMethod(notGetterMethod))
+ .isFalse();
+ }
+
+ @Test
+ public void testIsSetterMethod() throws Exception {
+ final File testFile =
+ new File(getPath("InputMissingJavadocMethodSetterGetter3.java"));
+ final DetailAST firstClassMethod =
+ CheckUtilTest.getNode(testFile, TokenTypes.METHOD_DEF);
+ final DetailAST setterMethod =
+ firstClassMethod.getNextSibling().getNextSibling().getNextSibling();
+ final DetailAST notSetterMethod = setterMethod.getNextSibling();
+
+ assertWithMessage("Invalid result: AST provided is not setter method")
+ .that(MissingJavadocMethodCheck.isSetterMethod(setterMethod))
+ .isTrue();
+ assertWithMessage("Invalid result: AST provided is not setter method")
+ .that(MissingJavadocMethodCheck.isSetterMethod(notSetterMethod))
+ .isFalse();
+ }
+
+ @Test
+ public void testSetterGetterOn() throws Exception {
+ final String[] expected = {
+ "20:5: " + getCheckMessage(MissingJavadocMethodCheck.class,
+ MSG_JAVADOC_MISSING),
+ "24:5: " + getCheckMessage(MissingJavadocMethodCheck.class,
+ MSG_JAVADOC_MISSING),
+ "29:5: " + getCheckMessage(MissingJavadocMethodCheck.class,
+ MSG_JAVADOC_MISSING),
+ };
+ verifyWithInlineConfigParser(
+ getPath("InputMissingJavadocMethodSetterGetter4.java"), expected);
+ }
+
+ @Test
+ public void missingJavadoc() throws Exception {
+ final String[] expected = {
+ "13:5: " + getCheckMessage(MissingJavadocMethodCheck.class, MSG_JAVADOC_MISSING),
+ };
+ verifyWithInlineConfigParser(
+ getNonCompilablePath("InputMissingJavadocMethodBasic.java"), expected);
+ }
}
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java
index 730d64cd7de..ce22a7c2612 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java
@@ -63,13 +63,13 @@
import com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyOption;
import com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderOption;
import com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocContentLocationOption;
+import com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck;
import com.puppycrawl.tools.checkstyle.checks.naming.AccessModifierOption;
import com.puppycrawl.tools.checkstyle.checks.whitespace.PadOption;
import com.puppycrawl.tools.checkstyle.checks.whitespace.WrapOption;
import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil;
import com.puppycrawl.tools.checkstyle.internal.utils.XdocUtil;
import com.puppycrawl.tools.checkstyle.internal.utils.XmlUtil;
-import com.puppycrawl.tools.checkstyle.utils.CheckUtil;
import com.puppycrawl.tools.checkstyle.utils.JavadocUtil;
import com.puppycrawl.tools.checkstyle.utils.ScopeUtil;
import com.puppycrawl.tools.checkstyle.utils.TokenUtil;
@@ -693,7 +693,7 @@ private static void visitMethod(DetailAST node, DetailAST parentNode) {
/**
* Returns whether an AST represents a setter method. This is similar to
- * {@link CheckUtil#isSetterMethod(DetailAST)} except this doesn't care
+ * {@link MissingJavadocMethodCheck#isSetterMethod(DetailAST)} except this doesn't care
* about the number of children in the method.
*
* @param ast the AST to check with.
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/utils/CheckUtilTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/utils/CheckUtilTest.java
index a29ab23530f..3b0cf86b9b2 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/CheckUtilTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/CheckUtilTest.java
@@ -24,7 +24,6 @@
import static com.puppycrawl.tools.checkstyle.checks.coding.MultipleVariableDeclarationsCheck.MSG_MULTIPLE;
import static com.puppycrawl.tools.checkstyle.checks.coding.NestedIfDepthCheck.MSG_KEY;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_EXPECTED_TAG;
-import static com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.MSG_JAVADOC_MISSING;
import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.findTokenInAstByPredicate;
import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsClassHasPrivateConstructor;
@@ -46,7 +45,6 @@
import com.puppycrawl.tools.checkstyle.checks.coding.MultipleVariableDeclarationsCheck;
import com.puppycrawl.tools.checkstyle.checks.coding.NestedIfDepthCheck;
import com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck;
-import com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck;
import com.puppycrawl.tools.checkstyle.checks.naming.AccessModifierOption;
public class CheckUtilTest extends AbstractModuleTestSupport {
@@ -185,34 +183,6 @@ public void testIsNonVoidMethod() throws Exception {
.isFalse();
}
- @Test
- public void testIsGetterMethod() throws Exception {
- final DetailAST notGetterMethod = getNodeFromFile(TokenTypes.METHOD_DEF);
- final DetailAST getterMethod = notGetterMethod.getNextSibling().getNextSibling();
-
- assertWithMessage("Invalid result: AST provided is getter method")
- .that(CheckUtil.isGetterMethod(getterMethod))
- .isTrue();
- assertWithMessage("Invalid result: AST provided is not getter method")
- .that(CheckUtil.isGetterMethod(notGetterMethod))
- .isFalse();
- }
-
- @Test
- public void testIsSetterMethod() throws Exception {
- final DetailAST firstClassMethod = getNodeFromFile(TokenTypes.METHOD_DEF);
- final DetailAST setterMethod =
- firstClassMethod.getNextSibling().getNextSibling().getNextSibling();
- final DetailAST notSetterMethod = setterMethod.getNextSibling();
-
- assertWithMessage("Invalid result: AST provided is setter method")
- .that(CheckUtil.isSetterMethod(setterMethod))
- .isTrue();
- assertWithMessage("Invalid result: AST provided is not setter method")
- .that(CheckUtil.isSetterMethod(notSetterMethod))
- .isFalse();
- }
-
@Test
public void testGetAccessModifierFromModifiersToken() throws Exception {
final DetailAST interfaceDef = getNodeFromFile(TokenTypes.INTERFACE_DEF);
@@ -422,29 +392,6 @@ public void testJavaDocMethod2() throws Exception {
getPath("InputCheckUtil5.java"), expected);
}
- @Test
- public void testSetterGetterOn() throws Exception {
- final String[] expected = {
- "20:5: " + getCheckMessage(MissingJavadocMethodCheck.class,
- MSG_JAVADOC_MISSING),
- "24:5: " + getCheckMessage(MissingJavadocMethodCheck.class,
- MSG_JAVADOC_MISSING),
- "29:5: " + getCheckMessage(MissingJavadocMethodCheck.class,
- MSG_JAVADOC_MISSING),
- };
- verifyWithInlineConfigParser(
- getPath("InputCheckUtil9.java"), expected);
- }
-
- @Test
- public void missingJavadoc() throws Exception {
- final String[] expected = {
- "13:5: " + getCheckMessage(MissingJavadocMethodCheck.class, MSG_JAVADOC_MISSING),
- };
- verifyWithInlineConfigParser(
- getNonCompilablePath("InputCheckUtil1.java"), expected);
- }
-
@Test
public void testJavadoc() throws Exception {
final String[] expected = {
@@ -460,6 +407,19 @@ private DetailAST getNodeFromFile(int type) throws Exception {
JavaParser.Options.WITH_COMMENTS), type);
}
+ /**
+ * Retrieves the AST node from a specific file based on the specified token type.
+ *
+ * @param type The token type to search for in the file.
+ * This parameter determines the type of AST node to retrieve.
+ * @param file The file from which the AST node should be retrieved.
+ * @return The AST node associated with the specified token type from the given file.
+ * @throws Exception If there's an issue reading or parsing the file.
+ */
+ public static DetailAST getNode(File file, int type) throws Exception {
+ return getNode(JavaParser.parseFile(file, JavaParser.Options.WITH_COMMENTS), type);
+ }
+
private static DetailAST getNode(DetailAST root, int type) {
final Optional node = findTokenInAstByPredicate(root,
ast -> ast.getType() == type);
@@ -470,5 +430,4 @@ private static DetailAST getNode(DetailAST root, int type) {
return node.get();
}
-
}
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/utils/checkutil/InputCheckUtil1.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadocmethod/InputMissingJavadocMethodBasic.java
similarity index 76%
rename from src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/utils/checkutil/InputCheckUtil1.java
rename to src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadocmethod/InputMissingJavadocMethodBasic.java
index 25b490fc2b5..960e7ddc038 100644
--- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/utils/checkutil/InputCheckUtil1.java
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadocmethod/InputMissingJavadocMethodBasic.java
@@ -6,9 +6,9 @@
*/
//non-compiled with javac: Compilable with Java14
-package com.puppycrawl.tools.checkstyle.utils.checkutil;
+package com.puppycrawl.tools.checkstyle.checks.javadoc.missingjavadocmethod;
-public class InputCheckUtil1 {
+public class InputMissingJavadocMethodBasic {
public void validAssign(String result) { // violation 'Missing a Javadoc comment'
result = switch ("in") {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadocmethod/InputMissingJavadocMethodSetterGetter3.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadocmethod/InputMissingJavadocMethodSetterGetter3.java
new file mode 100644
index 00000000000..bc2810bf678
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadocmethod/InputMissingJavadocMethodSetterGetter3.java
@@ -0,0 +1,73 @@
+package com.puppycrawl.tools.checkstyle.checks.javadoc.missingjavadocmethod;
+import com.google.common.base.Objects;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * It is class.
+ * @param ssss
+ * @param dddd
+ */
+public class InputMissingJavadocMethodSetterGetter3 {
+ private Map field = new HashMap<>();
+ protected int[] array = new int[10];
+ public static final Long VAR_1 = 1L;
+ static final double VAR_2 = 5.0;
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ InputMissingJavadocMethodSetterGetter3 that =
+ (InputMissingJavadocMethodSetterGetter3) o;
+ return Objects.equal(field, that.field) &&
+ Objects.equal(array, that.array);
+ }
+
+ public void doSomething(int value) {
+ if (field.isEmpty()) {
+ field.put(String.valueOf(value), value << 1);
+ } else {
+ if(!field.containsKey(String.valueOf(value))){
+ field.put(String.valueOf(value), value << 1);
+ }
+ }
+
+ if(!field.containsKey(String.valueOf(value))){
+ field.put(String.valueOf(value), value << 1);
+ } else if (value == 10) {
+ array[9] = -1;
+ }
+
+ if(field.size() < 10){
+ array[9] = field.getOrDefault(String.valueOf(value), -1);
+ }
+
+ }
+
+ public Map getField() {
+ return new HashMap<>(field);
+ }
+
+ public void setField(Map field) {
+ this.field = field;
+ }
+
+ public void setArray(String name, int... array) {
+ this.array = array;
+ }
+
+ public void anotherMethod(int... array) {
+ this.array = array;
+ }
+
+ public void testReceiver(InputMissingJavadocMethodSetterGetter3this, int variable) {}
+
+ public interface Example {
+ void method();
+ }
+}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/utils/checkutil/InputCheckUtil9.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadocmethod/InputMissingJavadocMethodSetterGetter4.java
similarity index 84%
rename from src/test/resources/com/puppycrawl/tools/checkstyle/utils/checkutil/InputCheckUtil9.java
rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadocmethod/InputMissingJavadocMethodSetterGetter4.java
index 95999633645..0c1e17ff345 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/utils/checkutil/InputCheckUtil9.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadocmethod/InputMissingJavadocMethodSetterGetter4.java
@@ -11,9 +11,9 @@
*/
-package com.puppycrawl.tools.checkstyle.utils.checkutil;
+package com.puppycrawl.tools.checkstyle.checks.javadoc.missingjavadocmethod;
-public class InputCheckUtil9 {
+public class InputMissingJavadocMethodSetterGetter4 {
private int mNumber;
From 8a10da1b5e36464d2b1bea4963da42523d190e29 Mon Sep 17 00:00:00 2001
From: Roman Ivanov
Date: Tue, 29 Aug 2023 06:12:01 -0700
Subject: [PATCH 018/833] Issue #13660: restore examples for
nonemptyatclausedescription
---
.../nonemptyatclausedescription/Example1.txt | 10 ++++++++++
.../nonemptyatclausedescription/Example2.txt | 10 ++++++++++
.../javadoc/nonemptyatclausedescription.xml | 20 +++++++++++++++++++
3 files changed, 40 insertions(+)
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/Example1.txt
index a0291de3582..f742f948e5b 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/Example1.txt
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/Example1.txt
@@ -13,4 +13,14 @@ class Test
/**
* Some summary.
*
+ * @param a Some description
+ * @param b
+ * @deprecated
+ * @throws Exception
+ * @return
+ */
+ public int method(String a, int b) throws Exception {
+ return 1;
+ }
+}
// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/Example2.txt
index ec2675d3e14..fa6aad0ab98 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/Example2.txt
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/Example2.txt
@@ -15,4 +15,14 @@ class Test
/**
* Some summary.
*
+ * @param a Some description
+ * @param b
+ * @deprecated
+ * @throws Exception
+ * @return
+ */
+ public int method(String a, int b) throws Exception {
+ return 1;
+ }
+}
// xdoc section -- end
diff --git a/src/xdocs/checks/javadoc/nonemptyatclausedescription.xml b/src/xdocs/checks/javadoc/nonemptyatclausedescription.xml
index 4dd8e3097ff..77cccf2110c 100644
--- a/src/xdocs/checks/javadoc/nonemptyatclausedescription.xml
+++ b/src/xdocs/checks/javadoc/nonemptyatclausedescription.xml
@@ -92,6 +92,16 @@ class Test
/**
* Some summary.
*
+ * <code>@param</code> a Some description
+ * <code>@param</code> b
+ * <code>@deprecated</code>
+ * <code>@throws</code> Exception
+ * <code>@return</code>
+ */
+ public int method(String a, int b) throws Exception {
+ return 1;
+ }
+}
To configure the check to validate @param,
@@ -116,6 +126,16 @@ class Test
/**
* Some summary.
*
+ * <code>@param</code> a Some description
+ * <code>@param</code> b
+ * <code>@deprecated</code>
+ * <code>@throws</code> Exception
+ * <code>@return</code>
+ */
+ public int method(String a, int b) throws Exception {
+ return 1;
+ }
+}
* Please read more about Xpath syntax at
- * Xpath Syntax.
+ * Xpath Syntax.
* Information regarding Xpath functions can be found at
- * XSLT/XPath Reference.
+ *
+ * XSLT/XPath Reference.
* Note, that @text attribute can be used only with token types that are listed in
*
* XpathUtil.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/MatchXpathCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/MatchXpathCheck.xml
index 2ff9162451b..908c8110f57 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/MatchXpathCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/MatchXpathCheck.xml
@@ -17,9 +17,10 @@
</p>
<p>
Please read more about Xpath syntax at
- <a href="https://www.saxonica.com/html/documentation10/expressions/">Xpath Syntax</a>.
+ <a href="https://www.saxonica.com/html/documentation10/expressions/index.html">Xpath Syntax</a>.
Information regarding Xpath functions can be found at
- <a href="https://www.saxonica.com/html/documentation10/functions/fn/">XSLT/XPath Reference</a>.
+ <a href="https://www.saxonica.com/html/documentation10/functions/fn/index.html">
+ XSLT/XPath Reference</a>.
Note, that <b>@text</b> attribute can be used only with token types that are listed in
<a href="https://github.com/checkstyle/checkstyle/search?q=%22TOKEN_TYPES_WITH_TEXT_ATTRIBUTE+%3D+Arrays.asList%22">
XpathUtil</a>.
diff --git a/src/xdocs/checks/coding/matchxpath.xml b/src/xdocs/checks/coding/matchxpath.xml
index 717dad3782e..325af727f31 100644
--- a/src/xdocs/checks/coding/matchxpath.xml
+++ b/src/xdocs/checks/coding/matchxpath.xml
@@ -22,10 +22,12 @@
Please read more about Xpath syntax at
- Xpath Syntax.
+
+ Xpath Syntax.
Information regarding Xpath functions can be found at
- XSLT/XPath
- Reference. Note, that @text attribute can be used only with token types that
+
+ XSLT/XPath Reference.
+ Note, that @text attribute can be used only with token types that
are listed in
XpathUtil.
diff --git a/src/xdocs/checks/coding/matchxpath.xml.template b/src/xdocs/checks/coding/matchxpath.xml.template
index d532b769d1e..aadd67d014f 100644
--- a/src/xdocs/checks/coding/matchxpath.xml.template
+++ b/src/xdocs/checks/coding/matchxpath.xml.template
@@ -22,10 +22,12 @@
Please read more about Xpath syntax at
- Xpath Syntax.
+
+ Xpath Syntax.
Information regarding Xpath functions can be found at
- XSLT/XPath
- Reference. Note, that @text attribute can be used only with token types that
+
+ XSLT/XPath Reference.
+ Note, that @text attribute can be used only with token types that
are listed in
XpathUtil.
From ca7d6d66d191747919b6ea30710dab3d539985f6 Mon Sep 17 00:00:00 2001
From: piyush kumar sadangi
Date: Fri, 1 Sep 2023 17:27:27 +0530
Subject: [PATCH 020/833] Issue #13213: Remove '//ok' comments from Input files
(InputGenericWhitespaceList)
---
config/checkstyle-input-suppressions.xml | 10 ----------
.../InputGenericWhitespaceEndsTheLine.java | 2 +-
.../InputGenericWhitespaceInnerClass.java | 2 +-
.../genericwhitespace/InputGenericWhitespaceList.java | 2 +-
.../InputGenericWhitespaceMethodRef1.java | 2 +-
.../InputGenericWhitespaceWithEmoji.java | 2 +-
6 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/config/checkstyle-input-suppressions.xml b/config/checkstyle-input-suppressions.xml
index 373c3ce1459..abe29672f37 100644
--- a/config/checkstyle-input-suppressions.xml
+++ b/config/checkstyle-input-suppressions.xml
@@ -7841,16 +7841,6 @@
files="checks[\\/]whitespace[\\/]emptylineseparator[\\/]packageinfo[\\/]test1[\\/]package-info.java"/>
-
-
-
-
- ;
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceInnerClass.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceInnerClass.java
index 79e501fb164..edb2c5566f3 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceInnerClass.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceInnerClass.java
@@ -4,7 +4,7 @@
*/
-package com.puppycrawl.tools.checkstyle.checks.whitespace.genericwhitespace; // ok
+package com.puppycrawl.tools.checkstyle.checks.whitespace.genericwhitespace;
import java.util.List;
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceList.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceList.java
index b1c0af92527..0e40ecf450c 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceList.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceList.java
@@ -8,7 +8,7 @@
import java.util.List;
-public class InputGenericWhitespaceList // ok
+public class InputGenericWhitespaceList
{
public List[]> listOfListOFArrays;
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceMethodRef1.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceMethodRef1.java
index d4b88100cdf..5deeb60de3c 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceMethodRef1.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceMethodRef1.java
@@ -8,7 +8,7 @@
import java.util.function.Supplier;
public class InputGenericWhitespaceMethodRef1
{
- public static class SomeClass { // ok
+ public static class SomeClass {
public static class Nested {
private Nested() {
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceWithEmoji.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceWithEmoji.java
index b51622c8bcd..e8a941f3207 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceWithEmoji.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace/InputGenericWhitespaceWithEmoji.java
@@ -12,7 +12,7 @@
public class InputGenericWhitespaceWithEmoji {
- /* 👇🏻dsad */public static class SomeClass { /* 😂 */ // ok
+ /* 👇🏻dsad */public static class SomeClass { /* 😂 */
public static class Nested {
From 08814f209de43368cf9078a56e9175bf1f91f7a9 Mon Sep 17 00:00:00 2001
From: Kevin222004
Date: Sat, 2 Sep 2023 09:51:11 +0530
Subject: [PATCH 021/833] Issue #13672: Kill mutation in TreeWalker-1
---
.../pitest-tree-walker-suppressions.xml | 27 -------------------
.../tools/checkstyle/TreeWalkerTest.java | 7 +++++
2 files changed, 7 insertions(+), 27 deletions(-)
diff --git a/config/pitest-suppressions/pitest-tree-walker-suppressions.xml b/config/pitest-suppressions/pitest-tree-walker-suppressions.xml
index 187867d8dc0..10f2641da1a 100644
--- a/config/pitest-suppressions/pitest-tree-walker-suppressions.xml
+++ b/config/pitest-suppressions/pitest-tree-walker-suppressions.xml
@@ -107,31 +107,4 @@
replaced return value with "" for com/puppycrawl/tools/checkstyle/TreeWalker::lambda$createNewCheckSortedSet$3Comparator.<AbstractCheck, String>comparing(check -> check.getClass().getName())
-
-
- TreeWalker.java
- com.puppycrawl.tools.checkstyle.TreeWalker
- registerCheck
- org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator
- removed call to java/lang/Class::getName
- + "method to return 'true'", check.getClass().getName(),
-
-
-
- TreeWalker.java
- com.puppycrawl.tools.checkstyle.TreeWalker
- registerCheck
- org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator
- removed call to com/puppycrawl/tools/checkstyle/utils/TokenUtil::getTokenName
- TokenUtil.getTokenName(tokenId));
-
-
-
- TreeWalker.java
- com.puppycrawl.tools.checkstyle.TreeWalker
- registerCheck
- org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator
- replaced call to java/lang/String::format with argument
- final String message = String.format(Locale.ROOT, "Check '%s' waits for comment type "
-
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java
index 94c222b2a3f..d36a0e7ee41 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java
@@ -306,6 +306,13 @@ public void testForInvalidCheckImplementation() throws Exception {
assertWithMessage("Exception is expected").fail();
}
catch (CheckstyleException ex) {
+ assertWithMessage("Error message is unexpected")
+ .that(ex.getMessage())
+ .isEqualTo("cannot initialize module com.puppycrawl.tools.checkstyle."
+ + "TreeWalker - Check 'com.puppycrawl.tools.checkstyle."
+ + "TreeWalkerTest$BadJavaDocCheck' waits for comment type token "
+ + "('SINGLE_LINE_COMMENT') and should override "
+ + "'isCommentNodesRequired()' method to return 'true'");
assertWithMessage("Error message is unexpected")
.that(ex.getMessage())
.contains("isCommentNodesRequired");
From 2972a0c8eb57e5d552fed2373518c7e9129a168a Mon Sep 17 00:00:00 2001
From: Rohanraj123
Date: Fri, 1 Sep 2023 18:53:34 +0530
Subject: [PATCH 022/833] Issue #13213: Remove '//ok' comments from
annotationlocation
---
config/checkstyle-input-suppressions.xml | 210 ------------------
...otationLocationRecordsAndCompactCtors.java | 2 +-
.../InputAnnotationLocationCorrect.java | 66 +++---
...tionLocationCustomAnnotationsDeclared.java | 6 +-
...AnnotationLocationDeprecatedAndCustom.java | 6 +-
.../InputAnnotationLocationEmpty.java | 2 +-
.../InputAnnotationLocationIncorrect.java | 28 +--
.../InputAnnotationLocationIncorrect2.java | 58 ++---
.../InputAnnotationLocationIncorrect3.java | 32 +--
.../InputAnnotationLocationMultiple.java | 2 +-
...AnnotationLocationSingleParameterless.java | 8 +-
...tAnnotationLocationWithoutAnnotations.java | 4 +-
.../inputs/PackageAnnotations.java | 2 +-
13 files changed, 108 insertions(+), 318 deletions(-)
diff --git a/config/checkstyle-input-suppressions.xml b/config/checkstyle-input-suppressions.xml
index abe29672f37..2cfc5436c66 100644
--- a/config/checkstyle-input-suppressions.xml
+++ b/config/checkstyle-input-suppressions.xml
@@ -139,8 +139,6 @@
files="[\\/]meta[\\/]javadocmetadatascraper[\\/]InputJavadocMetadataScraperWriteTagCheck.java"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- () {
public void foo() {
@@ -25,7 +25,7 @@ void bar(Bar bar) {
}
}
- static abstract class Bar { // ok
+ static abstract class Bar {
abstract void foo();
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/annotationlocation/inputs/PackageAnnotations.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/annotationlocation/inputs/PackageAnnotations.java
index b7d54330e91..a97eeea9159 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/annotationlocation/inputs/PackageAnnotations.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/annotationlocation/inputs/PackageAnnotations.java
@@ -15,7 +15,7 @@
*/
@Target(ElementType.PACKAGE)
-@interface PackageAnnotations { // ok
+@interface PackageAnnotations {
PackageAnnotation[] value();
From 8fe8c70b8a11683d304d98f5b6b6b0806735e8a2 Mon Sep 17 00:00:00 2001
From: piyush kumar sadangi
Date: Fri, 1 Sep 2023 22:50:49 +0530
Subject: [PATCH 023/833] Issue #13213: Remove '//ok' comments from Input files
(RedundantImport and UnusedImport)
---
config/checkstyle-input-suppressions.xml | 64 -------------------
.../InputUnusedImportsAnnotations.java | 2 +-
...utUnusedImportsRecordsAndCompactCtors.java | 18 +++---
.../InputRedundantImportBug.java | 2 +-
.../InputRedundantImportWithoutWarnings.java | 2 +-
.../InputUnusedImports15Extensions.java | 2 +-
.../InputUnusedImportsArrayRef.java | 2 +-
.../unusedimports/InputUnusedImportsBug.java | 2 +-
.../InputUnusedImportsFromJavaLang.java | 8 +--
...nputUnusedImportsJavadocQualifiedName.java | 2 +-
.../InputUnusedImportsShadowed.java | 16 ++---
...nusedImportsWithBlockMethodParameters.java | 2 +-
...utUnusedImportsWithNewlinesInsideTags.java | 2 +-
.../InputUnusedImportsWithValueTag.java | 2 +-
.../InputUnusedImportsWithoutWarnings.java | 2 +-
15 files changed, 32 insertions(+), 96 deletions(-)
diff --git a/config/checkstyle-input-suppressions.xml b/config/checkstyle-input-suppressions.xml
index 2cfc5436c66..e421a7d02e5 100644
--- a/config/checkstyle-input-suppressions.xml
+++ b/config/checkstyle-input-suppressions.xml
@@ -991,26 +991,6 @@
files="checks[\\/]imports[\\/]importorder[\\/]InputImportOrder_MultiplePatternMatches2.java"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- CONSTANTS = asList("a", "b");
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImports15Extensions.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImports15Extensions.java
index ca561ef5aa9..603adb842c5 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImports15Extensions.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImports15Extensions.java
@@ -7,7 +7,7 @@
// someexamples of 1.5 extensions
package com.puppycrawl.tools.checkstyle.checks.imports.unusedimports;
-@interface MyAnnotation1 { // ok
+@interface MyAnnotation1 {
String name();
int version();
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsArrayRef.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsArrayRef.java
index 51bed3cee27..375e5b7ede0 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsArrayRef.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsArrayRef.java
@@ -7,7 +7,7 @@
package com.puppycrawl.tools.checkstyle.checks.imports.unusedimports;
-import java.util.HashMap; // ok
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.ArrayList; // violation
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsBug.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsBug.java
index 921ef6f7255..c84e387b8d2 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsBug.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsBug.java
@@ -9,7 +9,7 @@
import java.net.URL;
-public class InputUnusedImportsBug { // ok
+public class InputUnusedImportsBug {
//same as a class name
private static String URL = "This is a String object";
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsFromJavaLang.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsFromJavaLang.java
index 0a46b294680..0947ae59106 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsFromJavaLang.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsFromJavaLang.java
@@ -19,11 +19,11 @@
import java.lang.Float; // violation
import java.lang.Short; // violation
-import java.lang.annotation.Annotation; // OK
-import java.lang.reflect.Modifier; // OK
-import java.lang.reflect.Field; // OK
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Field;
-import java.lang.*; // OK
+import java.lang.*;
public class InputUnusedImportsFromJavaLang {
private static final String SOMETHING = "a string";
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsJavadocQualifiedName.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsJavadocQualifiedName.java
index a28ded96027..4d104c3f779 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsJavadocQualifiedName.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsJavadocQualifiedName.java
@@ -7,7 +7,7 @@
package com.puppycrawl.tools.checkstyle.checks.imports.unusedimports;
-import java.util.Map; // ok
+import java.util.Map;
import java.util.List; // violation
/**
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsShadowed.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsShadowed.java
index 32f71c81bd3..52c4dbd205b 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsShadowed.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsShadowed.java
@@ -7,18 +7,18 @@
package com.puppycrawl.tools.checkstyle.checks.imports.unusedimports;
-import java.util.AbstractMap; // ok
-import java.util.List; // ok
+import java.util.AbstractMap;
+import java.util.List;
import java.util.Map; // violation
import java.util.Set; // violation
-import java.util.concurrent.Callable; // ok
+import java.util.concurrent.Callable;
import com.puppycrawl.tools.checkstyle.checks.imports.unusedimports.InputUnusedImportsShadowed; // violation
-import com.puppycrawl.tools.checkstyle.checks.imports.unusedimports.InputUnusedImportsShadowed.Deprecated; // ok
-import com.puppycrawl.tools.checkstyle.checks.imports.unusedimports.InputUnusedImportsShadowed.Foo; // ok
-import com.puppycrawl.tools.checkstyle.checks.imports.unusedimports.InputUnusedImportsShadowed.Inner; // ok
-import com.puppycrawl.tools.checkstyle.checks.imports.unusedimports.InputUnusedImportsShadowed.Nested; // ok
-import com.puppycrawl.tools.checkstyle.checks.imports.unusedimports.InputUnusedImportsShadowed.Nested.List.Map.Entry; // ok
+import com.puppycrawl.tools.checkstyle.checks.imports.unusedimports.InputUnusedImportsShadowed.Deprecated;
+import com.puppycrawl.tools.checkstyle.checks.imports.unusedimports.InputUnusedImportsShadowed.Foo;
+import com.puppycrawl.tools.checkstyle.checks.imports.unusedimports.InputUnusedImportsShadowed.Inner;
+import com.puppycrawl.tools.checkstyle.checks.imports.unusedimports.InputUnusedImportsShadowed.Nested;
+import com.puppycrawl.tools.checkstyle.checks.imports.unusedimports.InputUnusedImportsShadowed.Nested.List.Map.Entry;
@Deprecated(foo = Foo.class, classes = {Inner.class})
public class InputUnusedImportsShadowed
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithBlockMethodParameters.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithBlockMethodParameters.java
index 914207ddce4..ac837a926b5 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithBlockMethodParameters.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithBlockMethodParameters.java
@@ -11,7 +11,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
-public class InputUnusedImportsWithBlockMethodParameters { // ok
+public class InputUnusedImportsWithBlockMethodParameters {
/**
* @see ExecutorService#invokeAll(Collection, long, TimeUnit)
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithNewlinesInsideTags.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithNewlinesInsideTags.java
index 9facfd18a59..fef6c8ed683 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithNewlinesInsideTags.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithNewlinesInsideTags.java
@@ -10,7 +10,7 @@
import java.net.ResponseCache;
import java.util.List;
-public class InputUnusedImportsWithNewlinesInsideTags { // ok
+public class InputUnusedImportsWithNewlinesInsideTags {
/**
* This javadoc demonstrates issue #2840.
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithValueTag.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithValueTag.java
index c93f49ff6d4..604b53572e0 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithValueTag.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithValueTag.java
@@ -9,7 +9,7 @@
import java.util.Calendar;
-public class InputUnusedImportsWithValueTag { // ok
+public class InputUnusedImportsWithValueTag {
/**
* Method determines current month as for {@value Calendar#MONTH}.
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithoutWarnings.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithoutWarnings.java
index 938189b1e5d..80f5ae006f8 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithoutWarnings.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/unusedimports/InputUnusedImportsWithoutWarnings.java
@@ -10,6 +10,6 @@
import java.util.Arrays;
import java.util.List;
-public class InputUnusedImportsWithoutWarnings { // ok
+public class InputUnusedImportsWithoutWarnings {
private static final List CONSTANTS = Arrays.asList("a", "b");
}
From 1f25965812bdae95735a836dc91650e29c8c498a Mon Sep 17 00:00:00 2001
From: piyush kumar sadangi
Date: Sat, 2 Sep 2023 12:42:41 +0530
Subject: [PATCH 024/833] Issue #13213: Remove '//ok' comments from Input files
(ImportControlCheck)
---
config/checkstyle-input-suppressions.xml | 18 ------------------
.../importcontrol/InputImportControl11.java | 2 +-
.../importcontrol/InputImportControl18.java | 2 +-
.../importcontrol/InputImportControl20.java | 2 +-
.../importcontrol/InputImportControl23.java | 2 +-
.../importcontrol/InputImportControl24.java | 2 +-
.../importcontrol/InputImportControl7.java | 2 +-
.../importcontrol/InputImportControl8.java | 2 +-
.../InputImportControlBeginTree2.java | 1 -
...lWithoutRegexAndWithStrategyOnMismatch.java | 2 +-
10 files changed, 8 insertions(+), 27 deletions(-)
diff --git a/config/checkstyle-input-suppressions.xml b/config/checkstyle-input-suppressions.xml
index e421a7d02e5..5b77f483c0b 100644
--- a/config/checkstyle-input-suppressions.xml
+++ b/config/checkstyle-input-suppressions.xml
@@ -3887,24 +3887,6 @@
files="checks[\\/]imports[\\/]illegalimport[\\/]InputIllegalImportDefault7.java"/>
-
-
-
-
-
-
-
-
-
Date: Sat, 2 Sep 2023 13:50:22 +0530
Subject: [PATCH 025/833] Issue #13213: Remove '//ok' comments from Input files
(CustomImportOrder)
---
config/checkstyle-input-suppressions.xml | 24 -------------------
...tCustomImportOrderSamePackageDepth254.java | 2 +-
...putCustomImportOrderThirdPartyPackage.java | 2 +-
.../InputCustomImportOrderDefault5.java | 2 +-
.../InputCustomImportOrderDefault6.java | 2 +-
.../InputCustomImportOrderDefault7.java | 2 +-
.../InputCustomImportOrderDefault8.java | 2 +-
.../InputCustomImportOrderNoValid.java | 2 +-
...CustomImportOrderSpecialImportsRegExp.java | 2 +-
...tomImportOrder_MultiplePatternMatches.java | 2 +-
...omImportOrder_MultiplePatternMatches2.java | 2 +-
...omImportOrder_MultiplePatternMatches3.java | 2 +-
.../InputCustomImportOrder_NoImports.java | 2 +-
13 files changed, 12 insertions(+), 36 deletions(-)
diff --git a/config/checkstyle-input-suppressions.xml b/config/checkstyle-input-suppressions.xml
index 5b77f483c0b..2bf9f2a9669 100644
--- a/config/checkstyle-input-suppressions.xml
+++ b/config/checkstyle-input-suppressions.xml
@@ -549,10 +549,6 @@
files="checks[\\/]design[\\/]onetoplevelclass[\\/]package-info.java"/>
-
-
-
-
-
-
-
-
-
-
-
-
Date: Fri, 1 Sep 2023 16:18:16 +0200
Subject: [PATCH 026/833] Issue #13680: Simplify requirement for what we
consider a setter method in ClassAndPropertiesSettersJavadocScraper
---
...llness-optional-interning-suppressions.xml | 11 -----
...assAndPropertiesSettersJavadocScraper.java | 46 ++++---------------
.../tools/checkstyle/site/SiteUtil.java | 35 +++++++++++++-
.../checks/coding/matchxpath.xml.template | 20 ++------
4 files changed, 46 insertions(+), 66 deletions(-)
diff --git a/config/checker-framework-suppressions/checker-nullness-optional-interning-suppressions.xml b/config/checker-framework-suppressions/checker-nullness-optional-interning-suppressions.xml
index 9c4c583376f..e33bf86b67c 100644
--- a/config/checker-framework-suppressions/checker-nullness-optional-interning-suppressions.xml
+++ b/config/checker-framework-suppressions/checker-nullness-optional-interning-suppressions.xml
@@ -6226,17 +6226,6 @@
-
- src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java
- argument
- incompatible argument for parameter value of putIfAbsent.
- javadocs.putIfAbsent(property, SUPER_CLASS_PROPERTIES_JAVADOCS.get(property));
-
- found : @Initialized @Nullable DetailNode
- required: @Initialized @NonNull DetailNode
-
-
-
src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.javadereference.of.nullable
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/site/ClassAndPropertiesSettersJavadocScraper.java b/src/main/java/com/puppycrawl/tools/checkstyle/site/ClassAndPropertiesSettersJavadocScraper.java
index b336e9d37c5..8b239420f9e 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/site/ClassAndPropertiesSettersJavadocScraper.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/ClassAndPropertiesSettersJavadocScraper.java
@@ -23,7 +23,6 @@
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
-import java.util.Set;
import java.util.regex.Pattern;
import com.puppycrawl.tools.checkstyle.FileStatefulCheck;
@@ -48,12 +47,6 @@ public class ClassAndPropertiesSettersJavadocScraper extends AbstractJavadocChec
private static final Map JAVADOC_FOR_MODULE_OR_PROPERTY =
new LinkedHashMap<>();
- /** List of setter methods that the scraper ignores but shouldn't. */
- private static final Set SUPERCLASS_SETTERS = Set.of(
- "AbstractFileSetCheck.setFileExtensions",
- "AbstractHeaderCheck.setHeader"
- );
-
/** Name of the module being scraped. */
private static String moduleName = "";
@@ -88,13 +81,12 @@ public void visitJavadocToken(DetailNode ast) {
final DetailAST blockCommentAst = getBlockCommentAst();
if (BlockCommentPosition.isOnMethod(blockCommentAst)) {
final DetailAST methodDef = getParentAst(blockCommentAst, TokenTypes.METHOD_DEF);
- if (methodDef != null) {
+ if (methodDef != null
+ && isSetterMethod(methodDef)
+ && isMethodOfScrapedModule(methodDef)) {
final String methodName = methodDef.findFirstToken(TokenTypes.IDENT).getText();
- if (isSetterMethod(methodDef) && isMethodOfScrapedModule(methodDef)
- || SUPERCLASS_SETTERS.contains(moduleName + "." + methodName)) {
- final String propertyName = getPropertyName(methodName);
- JAVADOC_FOR_MODULE_OR_PROPERTY.put(propertyName, ast);
- }
+ final String propertyName = getPropertyName(methodName);
+ JAVADOC_FOR_MODULE_OR_PROPERTY.put(propertyName, ast);
}
}
@@ -169,34 +161,12 @@ private static String getPropertyName(String setterName) {
private static boolean isSetterMethod(DetailAST ast) {
boolean setterMethod = false;
- // Check have a method with exactly 7 children which are all that
- // is allowed in a proper setter method which does not throw any
- // exceptions.
- final int setterGetterMaxChildren = 7;
- if (ast.getType() == TokenTypes.METHOD_DEF
- && ast.getChildCount() == setterGetterMaxChildren) {
+ if (ast.getType() == TokenTypes.METHOD_DEF) {
final DetailAST type = ast.findFirstToken(TokenTypes.TYPE);
final String name = type.getNextSibling().getText();
final Pattern setterPattern = Pattern.compile("^set[A-Z].*");
- final boolean matchesSetterFormat = setterPattern.matcher(name).matches();
-
- final DetailAST params = ast.findFirstToken(TokenTypes.PARAMETERS);
- final boolean singleParam = params.getChildCount(TokenTypes.PARAMETER_DEF) == 1;
-
- if (matchesSetterFormat && singleParam) {
- // Now verify that the body consists of:
- // SLIST -> EXPR -> ASSIGN
- // SEMI
- // RCURLY
- final DetailAST slist = ast.findFirstToken(TokenTypes.SLIST);
-
- // Maximum nodes allowed in a body of setter
- final int setterBodySize = 3;
- if (slist != null && slist.getChildCount() == setterBodySize) {
- final DetailAST expr = slist.getFirstChild();
- setterMethod = expr.getFirstChild().getType() == TokenTypes.ASSIGN;
- }
- }
+
+ setterMethod = setterPattern.matcher(name).matches();
}
return setterMethod;
}
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 9abdbc9db07..deec29879f0 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java
@@ -452,12 +452,45 @@ public static Map getPropertiesJavadocs(Set properti
final Map unmodifiableJavadocs =
ClassAndPropertiesSettersJavadocScraper.getJavadocsForModuleOrProperty();
final Map javadocs = new LinkedHashMap<>(unmodifiableJavadocs);
+
properties.forEach(property -> {
- javadocs.putIfAbsent(property, SUPER_CLASS_PROPERTIES_JAVADOCS.get(property));
+ final DetailNode superClassPropertyJavadoc =
+ SUPER_CLASS_PROPERTIES_JAVADOCS.get(property);
+ if (superClassPropertyJavadoc != null) {
+ javadocs.putIfAbsent(property, superClassPropertyJavadoc);
+ }
});
+
+ assertAllPropertySetterJavadocsAreFound(properties, moduleName, javadocs);
+
return javadocs;
}
+ /**
+ * Assert that each property has a corresponding setter javadoc that is not null.
+ * 'tokens' and 'javadocTokens' are excluded from this check, because their
+ * description is different from the description of the setter.
+ *
+ * @param properties the properties of the module.
+ * @param moduleName the name of the module.
+ * @param javadocs the javadocs of the properties of the module.
+ * @throws MacroExecutionException if an error occurs during processing.
+ */
+ private static void assertAllPropertySetterJavadocsAreFound(
+ Set properties, String moduleName, Map javadocs)
+ throws MacroExecutionException {
+ for (String property : properties) {
+ final boolean isPropertySetterJavadocFound = javadocs.containsKey(property)
+ || TOKENS.equals(property) || JAVADOC_TOKENS.equals(property);
+ if (!isPropertySetterJavadocFound) {
+ final String message = String.format(Locale.ROOT,
+ "%s: Failed to find setter javadoc for property '%s'",
+ moduleName, property);
+ throw new MacroExecutionException(message);
+ }
+ }
+ }
+
/**
* Collect the properties setters javadocs of the superclasses.
*
diff --git a/src/xdocs/checks/coding/matchxpath.xml.template b/src/xdocs/checks/coding/matchxpath.xml.template
index aadd67d014f..8ea5e2daf6b 100644
--- a/src/xdocs/checks/coding/matchxpath.xml.template
+++ b/src/xdocs/checks/coding/matchxpath.xml.template
@@ -37,22 +37,10 @@
From 7011a36484b1a65c9cc2f421c48ce720aa436188 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 4 Sep 2023 21:16:05 +0000
Subject: [PATCH 027/833] dependency: bump org.slf4j:slf4j-simple from 2.0.7 to
2.0.9
Bumps org.slf4j:slf4j-simple from 2.0.7 to 2.0.9.
---
updated-dependencies:
- dependency-name: org.slf4j:slf4j-simple
dependency-type: direct:development
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 8a59baf0ac2..f2fc3fa3b58 100644
--- a/pom.xml
+++ b/pom.xml
@@ -361,7 +361,7 @@
org.slf4jslf4j-simple
- 2.0.7
+ 2.0.9test
From a583508cfe3478137d58f3776f860dd4fa548a03 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 4 Sep 2023 21:15:34 +0000
Subject: [PATCH 028/833] dependency: bump org.eclipse.jgit:org.eclipse.jgit
Bumps org.eclipse.jgit:org.eclipse.jgit from 6.6.0.202305301015-r to 6.6.1.202309021850-r.
---
updated-dependencies:
- dependency-name: org.eclipse.jgit:org.eclipse.jgit
dependency-type: direct:development
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index f2fc3fa3b58..16c78a6e1e9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -355,7 +355,7 @@
org.eclipse.jgitorg.eclipse.jgit
- 6.6.0.202305301015-r
+ 6.6.1.202309021850-rtest
From 858eadec3e3c09786c3dca7ff97785a63f161889 Mon Sep 17 00:00:00 2001
From: Rohanraj123
Date: Sat, 2 Sep 2023 17:04:13 +0530
Subject: [PATCH 029/833] Issue #13213: Remove '//ok' comments from
arraytypestyle
---
config/checkstyle-input-suppressions.xml | 6 ------
.../arraytypestyle/InputArrayTypeStyleNestedGenerics.java | 6 +++---
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/config/checkstyle-input-suppressions.xml b/config/checkstyle-input-suppressions.xml
index 2bf9f2a9669..f316e5effaf 100644
--- a/config/checkstyle-input-suppressions.xml
+++ b/config/checkstyle-input-suppressions.xml
@@ -1569,12 +1569,6 @@
files="checks[\\/]annotation[\\/]suppresswarnings[\\/]InputSuppressWarningsConstants.java"/>
-
-
- [] values1; // ok
- protected Pair[]>[] values2; // ok
- protected Pair>[]>[] values3a; // ok
+ protected Pair[] values1;
+ protected Pair[]>[] values2;
+ protected Pair>[]>[] values3a;
protected Pair<
Integer,
Pair<
From 635652787a37dc3523520fbb8757374427f7a8c6 Mon Sep 17 00:00:00 2001
From: piyush kumar sadangi
Date: Mon, 4 Sep 2023 13:35:54 +0530
Subject: [PATCH 030/833] Issue #13213: Remove '//ok' comments from Input files
(IllegalImport)
---
config/checkstyle-input-suppressions.xml | 314 ------------------
.../InputIllegalImportDefault.java | 10 +-
.../InputIllegalImportDefault1.java | 50 +--
.../InputIllegalImportDefault2.java | 60 ++--
.../InputIllegalImportDefault3.java | 50 +--
.../InputIllegalImportDefault4.java | 50 +--
.../InputIllegalImportDefault5.java | 42 +--
.../InputIllegalImportDefault6.java | 50 +--
.../InputIllegalImportDefault7.java | 30 +-
9 files changed, 171 insertions(+), 485 deletions(-)
diff --git a/config/checkstyle-input-suppressions.xml b/config/checkstyle-input-suppressions.xml
index f316e5effaf..fbd1b1d0ac5 100644
--- a/config/checkstyle-input-suppressions.xml
+++ b/config/checkstyle-input-suppressions.xml
@@ -549,16 +549,6 @@
files="checks[\\/]design[\\/]onetoplevelclass[\\/]package-info.java"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Date: Sun, 3 Sep 2023 01:26:31 +0530
Subject: [PATCH 031/833] Issue #13213: Remove '//ok' comments from Input files
(AvoidStaticImport)
---
config/checkstyle-input-suppressions.xml | 2 --
.../avoidstaticimport/InputAvoidStaticImportNestedClass.java | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/config/checkstyle-input-suppressions.xml b/config/checkstyle-input-suppressions.xml
index fbd1b1d0ac5..10323c79e34 100644
--- a/config/checkstyle-input-suppressions.xml
+++ b/config/checkstyle-input-suppressions.xml
@@ -3541,8 +3541,6 @@
files="checks[\\/]design[\\/]visibilitymodifier[\\/]inputs[\\/]InetSocketAddress.java"/>
-
Date: Wed, 30 Aug 2023 22:07:47 +0530
Subject: [PATCH 032/833] Issue #13552: Updated fall through violation messages
---
.../checks/coding/FallThroughCheckTest.java | 2 +-
.../coding/fallthrough/InputFallThrough2.java | 10 +--
.../coding/fallthrough/InputFallThrough3.java | 2 +-
.../coding/fallthrough/InputFallThrough.java | 32 ++++-----
.../coding/fallthrough/InputFallThrough2.java | 18 ++---
.../coding/fallthrough/InputFallThrough3.java | 72 +++++++++----------
.../coding/fallthrough/InputFallThrough4.java | 2 +-
.../coding/fallthrough/InputFallThrough5.java | 2 +-
.../coding/fallthrough/InputFallThrough6.java | 14 ++--
.../coding/fallthrough/InputFallThrough7.java | 2 +-
.../coding/fallthrough/InputFallThrough8.java | 4 +-
.../InputFallThroughCharacterSwitch.java | 12 ++--
.../fallthrough/InputFallThroughDefault.java | 46 ++++++------
...utFallThroughFallThroughLotsOfComment.java | 4 +-
.../InputFallThroughLastLineCommentCheck.java | 6 +-
.../InputFallThroughStringSwitch.java | 2 +-
.../InputFallThroughTryCatchInSwitch.java | 2 +-
.../fallthrough/InputFallThroughWeird.java | 2 +-
.../InputFallThroughWithEmoji.java | 8 +--
.../checks/coding/fallthrough/Example1.java | 4 +-
.../checks/coding/fallthrough/Example2.java | 6 +-
.../checks/coding/fallthrough/Example3.java | 2 +-
src/xdocs/checks/coding/fallthrough.xml | 12 ++--
23 files changed, 133 insertions(+), 133 deletions(-)
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheckTest.java
index 0d2f9d62fa7..9f29ab41f3f 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheckTest.java
@@ -48,7 +48,7 @@ public void testDefault() throws Exception {
"187:11: " + getCheckMessage(MSG_FALL_THROUGH),
"377:11: " + getCheckMessage(MSG_FALL_THROUGH),
"380:11: " + getCheckMessage(MSG_FALL_THROUGH),
- "382:40: " + getCheckMessage(MSG_FALL_THROUGH),
+ "382:27: " + getCheckMessage(MSG_FALL_THROUGH),
"424:13: " + getCheckMessage(MSG_FALL_THROUGH),
"432:9: " + getCheckMessage(MSG_FALL_THROUGH),
"444:9: " + getCheckMessage(MSG_FALL_THROUGH),
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough2.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough2.java
index 299b517e8ac..34055fe4e8b 100644
--- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough2.java
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough2.java
@@ -51,30 +51,30 @@ void tryResource() throws Exception {
return;
}
// fallthru
- case 7: // violation 'Fall through from previous branch of the switch statement.'
+ case 7: // violation 'Fall\ through from previous branch of the switch statement.'
try (final Resource resource = new Resource()) {
}
// fallthru
- case 8: // violation 'Fall through from previous branch of the switch statement.'
+ case 8: // violation 'Fall\ through from previous branch of the switch statement.'
try (final Resource resource = new Resource()) {
}
finally {
}
// fallthru
- case 9: // violation 'Fall through from previous branch of the switch statement.'
+ case 9: // violation 'Fall\ through from previous branch of the switch statement.'
try (final Resource resource = new Resource()) {
}
catch (Exception ex) {
}
// fallthru
- case 10: // violation 'Fall through from previous branch of the switch statement.'
+ case 10: // violation 'Fall\ through from previous branch of the switch statement.'
try (final Resource resource = new Resource()) {
return;
}
catch (Exception ex) {
}
// fallthru
- default: // violation 'Fall through from previous branch of the switch statement.'
+ default: // violation 'Fall\ through from previous branch of the switch statement.'
break;
}
}
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough3.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough3.java
index b74f11bb980..61ce51251af 100644
--- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough3.java
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough3.java
@@ -16,7 +16,7 @@ int hasYield() {
return switch (hashCode()) {
case 1:
i++;
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
yield 2;
case 3: // ok
// fall through
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough.java
index cd07f89440d..ab4fc210c7f 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough.java
@@ -19,7 +19,7 @@ void method(int i, int j, boolean cond) {
break;
case 2:
i++;
- case 3: // violation 'Fall through from previous branch of the switch statement.'
+ case 3: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
break;
case 4:
@@ -43,7 +43,7 @@ void method(int i, int j, boolean cond) {
case 11: {
i++;
}
- case 12: // violation 'Fall through from previous branch of the switch statement.'
+ case 12: // violation 'Fall\ through from previous branch of the switch statement.'
if (false)
break;
else
@@ -52,13 +52,13 @@ void method(int i, int j, boolean cond) {
if (true) {
return;
}
- case 14: // violation 'Fall through from previous branch of the switch statement.'
+ case 14: // violation 'Fall\ through from previous branch of the switch statement.'
if (true) {
return;
} else {
//do nothing
}
- case 15: // violation 'Fall through from previous branch of the switch statement.'
+ case 15: // violation 'Fall\ through from previous branch of the switch statement.'
do {
System.identityHashCode("something");
return;
@@ -75,7 +75,7 @@ void method(int i, int j, boolean cond) {
while(cond) {
break;
}
- case 19: // violation 'Fall through from previous branch of the switch statement.'
+ case 19: // violation 'Fall\ through from previous branch of the switch statement.'
try {
i++;
break;
@@ -92,7 +92,7 @@ void method(int i, int j, boolean cond) {
} catch (Error e) {
return;
}
- case 21: // violation 'Fall through from previous branch of the switch statement.'
+ case 21: // violation 'Fall\ through from previous branch of the switch statement.'
try {
i++;
} catch (RuntimeException e) {
@@ -184,7 +184,7 @@ void methodFallThru(int i, int j, boolean cond) {
if (true) {
return;
}
- case 14: // violation 'Fall through from previous branch of the switch statement.'
+ case 14: // violation 'Fall\ through from previous branch of the switch statement.'
if (true) {
return;
} else {
@@ -374,12 +374,12 @@ void methodFallThruCCustomWords(int i, int j, boolean cond) {
case 0:
i++; /* Continue with next case */
- case 1: // violation 'Fall through from previous branch of the switch statement.'
+ case 1: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
/* Continue with next case */
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
- /* Continue with next case */case 3: // violation 'Fall through from prev.*'
+ /* Continue with next case */case 3: // violation 'Fall\ through from prev.*'
break;
case 4: // violation 'Fall .* from the last branch of the switch statement.'
i++;
@@ -421,7 +421,7 @@ void nestedSwitches() {
switch (hashCode()) { // causing NullPointerException in the past
case 1:
}
- default: // violation 'Fall through from previous branch of the switch statement.'
+ default: // violation 'Fall\ through from previous branch of the switch statement.'
}
}
@@ -429,7 +429,7 @@ void nextedSwitches2() {
switch(hashCode()) {
case 1:
switch(hashCode()){}
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
System.lineSeparator();
break;
}
@@ -441,7 +441,7 @@ void ifWithoutBreak() {
if (true) {
System.lineSeparator();
}
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
System.lineSeparator();
break;
}
@@ -451,7 +451,7 @@ void noCommentAtTheEnd() {
switch(hashCode()) {
case 1: System.lineSeparator();
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
System.lineSeparator();
break;
}
@@ -488,8 +488,8 @@ void multipleCasesOnOneLine() {
switch (i) {
case 0: case 1: i *= i; // fall through
case 2: case 3: i *= i;
- case 4: case 5: i *= i; // violation 'Fall through from prev.* br.* switch statement.'
- case 6: case 7: i *= i; // violation 'Fall through from prev.* br.* switch statement.'
+ case 4: case 5: i *= i; // violation 'Fall\ through from prev.* br.* switch statement.'
+ case 6: case 7: i *= i; // violation 'Fall\ through from prev.* br.* switch statement.'
break;
default:
throw new RuntimeException();
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough2.java
index 94c752089c7..695d61ad4fd 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough2.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough2.java
@@ -25,7 +25,7 @@ public static void test() {
// some work
break;
}
- case C: // violation 'Fall through from previous branch of the switch statement.'
+ case C: // violation 'Fall\ through from previous branch of the switch statement.'
break;
}
@@ -40,18 +40,18 @@ public static void test() {
if (true) {
return;
}
- case 4: // violation 'Fall through from previous branch of the switch statement.'
+ case 4: // violation 'Fall\ through from previous branch of the switch statement.'
if (var2 == 2) {
break;
}
- case 5: // violation 'Fall through from previous branch of the switch statement.'
+ case 5: // violation 'Fall\ through from previous branch of the switch statement.'
if (var2 == 1) {
}
else if (true) {
return;
}
- case 6: // violation 'Fall through from previous branch of the switch statement.'
+ case 6: // violation 'Fall\ through from previous branch of the switch statement.'
if (var2 > 1) {
break;
}
@@ -65,14 +65,14 @@ else if (true) {
else if (true) {
return;
}
- case 8: // violation 'Fall through from previous branch of the switch statement.'
+ case 8: // violation 'Fall\ through from previous branch of the switch statement.'
if(var2 == 5) {
System.identityHashCode("0xB16B00B5");
}
else {
break;
}
- case 9: // violation 'Fall through from previous branch of the switch statement.'
+ case 9: // violation 'Fall\ through from previous branch of the switch statement.'
if(var2 == 5) {
System.identityHashCode("0xCAFED00D");
}
@@ -85,15 +85,15 @@ else if (true) {
switch (var3) {
case 0xCAFEBABE:
String.CASE_INSENSITIVE_ORDER.equals("0x1CEB00DA");
- default: // violation 'Fall through from prev.* br.* switch statement.'
+ default: // violation 'Fall\ through from prev.* br.* switch statement.'
String.CASE_INSENSITIVE_ORDER.equals("");
}
if(true) {
break;
}
- case 11: // violation 'Fall through from previous branch of the switch statement.'
+ case 11: // violation 'Fall\ through from previous branch of the switch statement.'
if(false) {break;}
- case 12: // violation 'Fall through from previous branch of the switch statement.'
+ case 12: // violation 'Fall\ through from previous branch of the switch statement.'
if(true);
break;
default:
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough3.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough3.java
index 508618aee96..f75d672a46a 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough3.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough3.java
@@ -19,7 +19,7 @@ void method(int i, int j, boolean cond) {
break;
case 2:
i++;
- case 3: // violation 'Fall through from previous branch of the switch statement.'
+ case 3: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
break;
case 4:
@@ -43,7 +43,7 @@ void method(int i, int j, boolean cond) {
case 11: {
i++;
}
- case 12: // violation 'Fall through from previous branch of the switch statement.'
+ case 12: // violation 'Fall\ through from previous branch of the switch statement.'
if (false)
break;
else
@@ -52,13 +52,13 @@ void method(int i, int j, boolean cond) {
if (true) {
return;
}
- case 14: // violation 'Fall through from previous branch of the switch statement.'
+ case 14: // violation 'Fall\ through from previous branch of the switch statement.'
if (true) {
return;
} else {
//do nothing
}
- case 15: // violation 'Fall through from previous branch of the switch statement.'
+ case 15: // violation 'Fall\ through from previous branch of the switch statement.'
do {
System.identityHashCode("something");
return;
@@ -75,7 +75,7 @@ void method(int i, int j, boolean cond) {
while(cond) {
break;
}
- case 19: // violation 'Fall through from previous branch of the switch statement.'
+ case 19: // violation 'Fall\ through from previous branch of the switch statement.'
try {
i++;
break;
@@ -92,7 +92,7 @@ void method(int i, int j, boolean cond) {
} catch (Error e) {
return;
}
- case 21: // violation 'Fall through from previous branch of the switch statement.'
+ case 21: // violation 'Fall\ through from previous branch of the switch statement.'
try {
i++;
} catch (RuntimeException e) {
@@ -128,7 +128,7 @@ void method(int i, int j, boolean cond) {
default:
return;
}
- default: // violation 'Fall through from previous branch of the switch statement.'
+ default: // violation 'Fall\ through from previous branch of the switch statement.'
// this is the last label
i++;
}
@@ -150,7 +150,7 @@ void methodFallThru(int i, int j, boolean cond) {
case 2:
i++;
// fallthru
- case 3: // violation 'Fall through from previous branch of the switch statement.'
+ case 3: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
break;
case 4:
@@ -175,7 +175,7 @@ void methodFallThru(int i, int j, boolean cond) {
i++;
}
// fallthru
- case 12: // violation 'Fall through from previous branch of the switch statement.'
+ case 12: // violation 'Fall\ through from previous branch of the switch statement.'
if (false)
break;
else
@@ -184,14 +184,14 @@ void methodFallThru(int i, int j, boolean cond) {
if (true) {
return;
}
- case 14: // violation 'Fall through from previous branch of the switch statement.'
+ case 14: // violation 'Fall\ through from previous branch of the switch statement.'
if (true) {
return;
} else {
//do nothing
}
// fallthru
- case 15: // violation 'Fall through from previous branch of the switch statement.'
+ case 15: // violation 'Fall\ through from previous branch of the switch statement.'
do {
System.identityHashCode("something");
return;
@@ -209,7 +209,7 @@ void methodFallThru(int i, int j, boolean cond) {
break;
}
// fallthru
- case 19: // violation 'Fall through from previous branch of the switch statement.'
+ case 19: // violation 'Fall\ through from previous branch of the switch statement.'
try {
i++;
break;
@@ -227,7 +227,7 @@ void methodFallThru(int i, int j, boolean cond) {
return;
}
// fallthru
- case 21: // violation 'Fall through from previous branch of the switch statement.'
+ case 21: // violation 'Fall\ through from previous branch of the switch statement.'
try {
i++;
} catch (RuntimeException e) {
@@ -257,7 +257,7 @@ void methodFallThru(int i, int j, boolean cond) {
}
case 24:
i++;
- /* fallthru */ case 25: // violation 'Fall through from prev.* br.* switch statement.'
+ /* fallthru */ case 25: // violation 'Fall\ through from prev.* br.* switch statement.'
i++;
break;
@@ -271,7 +271,7 @@ void methodFallThru(int i, int j, boolean cond) {
return;
}
// fallthru
- default: // violation 'Fall through from previous branch of the switch statement.'
+ default: // violation 'Fall\ through from previous branch of the switch statement.'
// this is the last label
i++;
// fallthru
@@ -286,16 +286,16 @@ void methodFallThruCC(int i, int j, boolean cond) {
case 0:
i++; // fallthru
- case 1: // violation 'Fall through from previous branch of the switch statement.'
+ case 1: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
// fallthru
- case 2: { // violation 'Fall through from previous branch of the switch statement.'
+ case 2: { // violation 'Fall\ through from previous branch of the switch statement.'
i++;
}
// fallthru
- case 3: // violation 'Fall through from previous branch of the switch statement.'
+ case 3: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
- /* fallthru */case 4: // violation 'Fall through from prev.* br.* switch statement.'
+ /* fallthru */case 4: // violation 'Fall\ through from prev.* br.* switch statement.'
break;
case 5:
i++;
@@ -311,12 +311,12 @@ void methodFallThruC(int i, int j, boolean cond) {
case 0:
i++; /* fallthru */
- case 1: // violation 'Fall through from previous branch of the switch statement.'
+ case 1: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
/* fallthru */
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
- /* fallthru */case 3: // violation 'Fall through from prev.* br.* switch statement.'
+ /* fallthru */case 3: // violation 'Fall\ through from prev.* br.* switch statement.'
break;
case 4:
i++;
@@ -332,12 +332,12 @@ void methodFallThruC2(int i, int j, boolean cond) {
case 0:
i++; /*fallthru*/
- case 1: // violation 'Fall through from previous branch of the switch statement.'
+ case 1: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
/*fallthru*/
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
- /*fallthru*/case 3: // violation 'Fall through from prev.* br.* switch statement.'
+ /*fallthru*/case 3: // violation 'Fall\ through from prev.* br.* switch statement.'
break;
case 4:
i++;
@@ -353,12 +353,12 @@ void methodFallThruCOtherWords(int i, int j, boolean cond) {
case 0:
i++; /* falls through */
- case 1: // violation 'Fall through from previous branch of the switch statement.'
+ case 1: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
/* falls through */
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
- /* falls through */case 3: // violation 'Fall through from prev.* br.* switch statement.'
+ /* falls through */case 3: // violation 'Fall\ through from prev.* br.* switch statement.'
break;
case 4:
i++;
@@ -421,7 +421,7 @@ void nestedSwitches() {
switch (hashCode()) { // causing NullPointerException in the past
case 1:
}
- default: // violation 'Fall through from previous branch of the switch statement.'
+ default: // violation 'Fall\ through from previous branch of the switch statement.'
}
}
@@ -429,7 +429,7 @@ void nextedSwitches2() {
switch(hashCode()) {
case 1:
switch(hashCode()){}
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
System.lineSeparator();
break;
}
@@ -441,7 +441,7 @@ void ifWithoutBreak() {
if (true) {
System.lineSeparator();
}
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
System.lineSeparator();
break;
}
@@ -451,7 +451,7 @@ void noCommentAtTheEnd() {
switch(hashCode()) {
case 1: System.lineSeparator();
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
System.lineSeparator();
break;
}
@@ -478,7 +478,7 @@ void synchronizedStatement() {
synchronized (this) {
}
// fallthru
- default: // violation 'Fall through from previous branch of the switch statement.'
+ default: // violation 'Fall\ through from previous branch of the switch statement.'
break;
}
}
@@ -487,9 +487,9 @@ void multipleCasesOnOneLine() {
int i = 0;
switch (i) {
case 0: case 1: i *= i; // fall through
- case 2: case 3: i *= i; // violation 'Fall through from prev.* br.* switch statement.'
- case 4: case 5: i *= i; // violation 'Fall through from prev.* br.* switch statement.'
- case 6: case 7: i *= i; // violation 'Fall through from prev.* br.* switch statement.'
+ case 2: case 3: i *= i; // violation 'Fall\ through from prev.* br.* switch statement.'
+ case 4: case 5: i *= i; // violation 'Fall\ through from prev.* br.* switch statement.'
+ case 6: case 7: i *= i; // violation 'Fall\ through from prev.* br.* switch statement.'
break;
default:
throw new RuntimeException();
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough4.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough4.java
index 217d02c6a77..0c2c78d53b1 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough4.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough4.java
@@ -109,7 +109,7 @@ void method4(int i, int j, boolean cond) {
void method5(int i, int j, boolean cond) {
while (true) {
switch (i){
- case 5: // violation 'Fall through from the last branch of the switch statement'
+ case 5: // violation 'Fall\ through from the last branch of the switch statement'
i++;
/* block */ /* fallthru */ // comment
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough5.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough5.java
index 6a33883c4ee..d537f638f3a 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough5.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough5.java
@@ -91,7 +91,7 @@ void method6() {
// fall through
i++;
// i am comment
- case 2: // violation 'Fall through from previous branch of the switch statement'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement'
break;
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough6.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough6.java
index e44557313ad..cbbfa1c4880 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough6.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough6.java
@@ -20,11 +20,11 @@ void foo(int i){
case 4:
int fallthru2 = 3;
// fall - thru
- case 5: // violation 'Fall through from previous branch of the switch statement.'
+ case 5: // violation 'Fall\ through from previous branch of the switch statement.'
int fallthru3 = 4; // This is a fallthru comment
case 6:
int fallthru4 = 5; // falldown
- default: // violation 'Fall through from previous branch of the switch statement.'
+ default: // violation 'Fall\ through from previous branch of the switch statement.'
}
}
@@ -49,7 +49,7 @@ void method() {
case 1:
// fall through
i++;
- case 2: // violation 'Fall through from previous branch of the switch statement'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement'
break;
}
}
@@ -62,7 +62,7 @@ void method2() {
case 1: // random
// fall through
i++;
- case 2: // violation 'Fall through from previous branch of the switch statement'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement'
break;
}
}
@@ -77,7 +77,7 @@ void method3() {
// non fall
/* comment */
i++;
- case 2: // violation 'Fall through from previous branch of the switch statement'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement'
break;
}
}
@@ -91,7 +91,7 @@ void method4() {
/* fallthru */
// comment
i++;
- case 2: // violation 'Fall through from previous branch of the switch statement'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement'
break;
}
}
@@ -106,7 +106,7 @@ void method5() {
// fall through
// comment
System.out.println("check");
- case 2: // violation 'Fall through from previous branch of the switch statement'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement'
break;
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough7.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough7.java
index 60e1d30ce7c..81f98177276 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough7.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough7.java
@@ -61,7 +61,7 @@ public void method3() {
case 4:
case 3:
c = 4;
- case 2: // violation 'Fall through from previous branch of the switch statement'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement'
case 1:
default:
c = 9;
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough8.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough8.java
index 5acebb6d80f..370d36096a7 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough8.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough8.java
@@ -22,7 +22,7 @@ void methodLastLine(int i) {
case 2:
i++;
/* comment */ /* fall thru */ /* comment */
- case 3: // violation 'Fall through from previous branch of the switch statement'
+ case 3: // violation 'Fall\ through from previous branch of the switch statement'
i--;
break;
}
@@ -31,7 +31,7 @@ void methodLastLine(int i) {
void testLastCase(int i) {
switch (i) {
- case 0: // violation 'Fall through from the last branch of the switch statement'
+ case 0: // violation 'Fall\ through from the last branch of the switch statement'
i++;
/* comment */ /* fall thru */ /* comment */
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughCharacterSwitch.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughCharacterSwitch.java
index 4f4ec0895d1..10eba51fbc6 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughCharacterSwitch.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughCharacterSwitch.java
@@ -16,7 +16,7 @@ void foo(char c, int i) {
case 'a':
case 'b':
i++;
- case 'c': // violation 'Fall through from previous branch of the switch statement.'
+ case 'c': // violation 'Fall\ through from previous branch of the switch statement.'
String.valueOf(i);
break;
case 'd':
@@ -27,7 +27,7 @@ void foo(char c, int i) {
if (true) {
return;
}
- case 'g': // violation 'Fall through from previous branch of the switch statement.'
+ case 'g': // violation 'Fall\ through from previous branch of the switch statement.'
try {
i++;
break;
@@ -35,17 +35,17 @@ void foo(char c, int i) {
} catch (Error e) {
return;
}
- case 'h': // violation 'Fall through from previous branch of the switch statement.'
+ case 'h': // violation 'Fall\ through from previous branch of the switch statement.'
switch (i) {
case 1:
continue;
case 2:
i++;
- case 3: // violation 'Fall through from previous branch of the switch statement.'
+ case 3: // violation 'Fall\ through from previous branch of the switch statement.'
String.valueOf(i);
return;
}
- case 'i': // violation 'Fall through from previous branch of the switch statement.'
+ case 'i': // violation 'Fall\ through from previous branch of the switch statement.'
switch (i) {
case 1:
continue;
@@ -60,7 +60,7 @@ void foo(char c, int i) {
case 'A':
i++;
// FALL-THRU (case-sensitive)
- case 'B': // violation 'Fall through from previous branch of the switch statement.'
+ case 'B': // violation 'Fall\ through from previous branch of the switch statement.'
i++;
// fall-through
default:
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughDefault.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughDefault.java
index 7928f6b32a9..a7b51796a28 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughDefault.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughDefault.java
@@ -19,7 +19,7 @@ void method(int i, int j, boolean cond) {
break;
case 2:
i++;
- case 3: // violation 'Fall through from previous branch of the switch statement.'
+ case 3: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
break;
case 4:
@@ -43,7 +43,7 @@ void method(int i, int j, boolean cond) {
case 11: {
i++;
}
- case 12: // violation 'Fall through from previous branch of the switch statement.'
+ case 12: // violation 'Fall\ through from previous branch of the switch statement.'
if (false)
break;
else
@@ -52,13 +52,13 @@ void method(int i, int j, boolean cond) {
if (true) {
return;
}
- case 14: // violation 'Fall through from previous branch of the switch statement.'
+ case 14: // violation 'Fall\ through from previous branch of the switch statement.'
if (true) {
return;
} else {
//do nothing
}
- case 15: // violation 'Fall through from previous branch of the switch statement.'
+ case 15: // violation 'Fall\ through from previous branch of the switch statement.'
do {
System.identityHashCode("something");
return;
@@ -75,7 +75,7 @@ void method(int i, int j, boolean cond) {
while(cond) {
break;
}
- case 19: // violation 'Fall through from previous branch of the switch statement.'
+ case 19: // violation 'Fall\ through from previous branch of the switch statement.'
try {
i++;
break;
@@ -92,7 +92,7 @@ void method(int i, int j, boolean cond) {
} catch (Error e) {
return;
}
- case 21: // violation 'Fall through from previous branch of the switch statement.'
+ case 21: // violation 'Fall\ through from previous branch of the switch statement.'
try {
i++;
} catch (RuntimeException e) {
@@ -128,7 +128,7 @@ void method(int i, int j, boolean cond) {
default:
return;
}
- default: // violation 'Fall through from previous branch of the switch statement.'
+ default: // violation 'Fall\ through from previous branch of the switch statement.'
// this is the last label
i++;
}
@@ -184,7 +184,7 @@ void methodFallThru(int i, int j, boolean cond) {
if (true) {
return;
}
- case 14: // violation 'Fall through from previous branch of the switch statement.'
+ case 14: // violation 'Fall\ through from previous branch of the switch statement.'
if (true) {
return;
} else {
@@ -374,12 +374,12 @@ void methodFallThruCCustomWords(int i, int j, boolean cond) {
case 0:
i++; /* Continue with next case */
- case 1: // violation 'Fall through from previous branch of the switch statement.'
+ case 1: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
/* Continue with next case */
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
i++;
- /* Continue with next case */case 3: // violation 'Fall through from prev.* br.* switch.*'
+ /* Continue.* */case 3: // violation 'Fall\ through from previous branch.* switch.*'
break;
case 4:
i++;
@@ -421,7 +421,7 @@ void nestedSwitches() {
switch (hashCode()) { // causing NullPointerException in the past
case 1:
}
- default: // violation 'Fall through from previous branch of the switch statement.'
+ default: // violation 'Fall\ through from previous branch of the switch statement.'
}
}
@@ -429,7 +429,7 @@ void nextedSwitches2() {
switch(hashCode()) {
case 1:
switch(hashCode()){}
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
System.lineSeparator();
break;
}
@@ -441,7 +441,7 @@ void ifWithoutBreak() {
if (true) {
System.lineSeparator();
}
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
System.lineSeparator();
break;
}
@@ -451,7 +451,7 @@ void noCommentAtTheEnd() {
switch(hashCode()) {
case 1: System.lineSeparator();
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
System.lineSeparator();
break;
}
@@ -487,9 +487,9 @@ void multipleCasesOnOneLine() {
int i = 0;
switch (i) {
case 0: case 1: i *= i;
- case 2: case 3: i *= i; // violation 'Fall through from prev.* br.* switch statement.'
- case 4: case 5: i *= i; // violation 'Fall through from prev.* br.* switch statement.'
- case 6: case 7: i *= i; // violation 'Fall through from prev.* br.* switch statement.'
+ case 2: case 3: i *= i; // violation 'Fall\ through from prev.* br.* switch statement.'
+ case 4: case 5: i *= i; // violation 'Fall\ through from prev.* br.* switch statement.'
+ case 6: case 7: i *= i; // violation 'Fall\ through from prev.* br.* switch statement.'
break;
default:
throw new RuntimeException();
@@ -526,15 +526,15 @@ void methodFallThruWithDash(int i, int j, boolean cond) {
i++; // falls-through
case 12:
i++; // fall--through
- case 13: // violation 'Fall through from previous branch of the switch statement.'
+ case 13: // violation 'Fall\ through from previous branch of the switch statement.'
i++; // fall+through
- case 14: // violation 'Fall through from previous branch of the switch statement.'
+ case 14: // violation 'Fall\ through from previous branch of the switch statement.'
i++; // falls_thru
- case 15: // violation 'Fall through from previous branch of the switch statement.'
+ case 15: // violation 'Fall\ through from previous branch of the switch statement.'
i++; // falls=through
- case 16: // violation 'Fall through from previous branch of the switch statement.'
+ case 16: // violation 'Fall\ through from previous branch of the switch statement.'
i++; // falls-throug
- default: // violation 'Fall through from previous branch of the switch statement.'
+ default: // violation 'Fall\ through from previous branch of the switch statement.'
throw new RuntimeException();
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughFallThroughLotsOfComment.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughFallThroughLotsOfComment.java
index f96998728d3..1ed902689c8 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughFallThroughLotsOfComment.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughFallThroughLotsOfComment.java
@@ -17,7 +17,7 @@ void method(int lineNumber) {
int line = 2;
// fall-through intended - the line contains already the first entries
// the following 4 lines contain additional satellite ids
- case 4: // violation 'Fall through from previous branch of the switch statement'
+ case 4: // violation 'Fall\ through from previous branch of the switch statement'
case 5:
case 6:
case 7: {
@@ -40,7 +40,7 @@ void method(int lineNumber) {
// base = line.substring(14, 26).trim();
}
- case 16: // violation 'Fall through from previous branch of the switch statement'
+ case 16: // violation 'Fall\ through from previous branch of the switch statement'
case 17:
case 18:
// ignore additional custom parameters
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughLastLineCommentCheck.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughLastLineCommentCheck.java
index 9231b37c3bb..bca74ffbf73 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughLastLineCommentCheck.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughLastLineCommentCheck.java
@@ -18,7 +18,7 @@ public void method(int i) {
// comment
// fall through
// check
- case 2: // violation 'Fall through from previous branch of the switch statement'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement'
break;
case 3:
break;
@@ -30,7 +30,7 @@ public void method2(int i) {
case 1:
i++;
/* block */ /* fallthru */ // comment
- case 2: // violation 'Fall through from previous branch of the switch statement'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement'
// this is comment
i++;
// fall through
@@ -104,7 +104,7 @@ void method6(String str) {
void method7(int i, int j, boolean cond) {
while (true) {
switch (i){
- case 5: // violation 'Fall through from the last branch of the switch statement'
+ case 5: // violation 'Fall\ through from the last branch of the switch statement'
i++;
/* block */ i++; /* fallthru */ // comment
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughStringSwitch.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughStringSwitch.java
index 545f173b90d..2d95ad7b247 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughStringSwitch.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughStringSwitch.java
@@ -18,7 +18,7 @@ int method(String arg) {
break;
case "violation":
i++;
- case "fallthru": // violation 'Fall through from previous branch of the switch statement.'
+ case "fallthru": // violation 'Fall\ through from previous branch of the switch statement.'
}
return i;
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughTryCatchInSwitch.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughTryCatchInSwitch.java
index dd3a3bc82dd..94c71856d00 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughTryCatchInSwitch.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughTryCatchInSwitch.java
@@ -34,7 +34,7 @@ public int foo(int x) {
} finally {
// Some code
}
- default: // violation 'Fall through from previous branch of the switch statement.'
+ default: // violation 'Fall\ through from previous branch of the switch statement.'
// Some code
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughWeird.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughWeird.java
index 68bb1ff3ac7..bdc8ce6f2e3 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughWeird.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughWeird.java
@@ -12,7 +12,7 @@ void foo(int i){
switch(i) {
case 1:
int fallthru = 2; // some comment
- case 2: // violation 'Fall through from previous branch of the switch statement.'
+ case 2: // violation 'Fall\ through from previous branch of the switch statement.'
break;
case 3:
int c = 2; // fall thru
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughWithEmoji.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughWithEmoji.java
index 0951442f73a..aef11a9e679 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughWithEmoji.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughWithEmoji.java
@@ -20,10 +20,10 @@ void foo() {
case "👇🏻":
i++;
case "😂sda":
- // violation above 'Fall through from previous branch of the switch statement.'
+ // violation above 'Fall\ through from previous branch of the switch statement.'
i++;
case "d😂sda": return;
- // violation above 'Fall through from previous branch of the switch statement.'
+ // violation above 'Fall\ through from previous branch of the switch statement.'
case "5😆": throw new RuntimeException("");
case "🧐6":
@@ -47,9 +47,9 @@ void foo() {
}
// fall👉🏻through,
case "9": String s = "s🥳d🥳s";
- // violation above 'Fall through from previous branch of the switch statement.'
+ // violation above 'Fall\ through from previous branch of the switch statement.'
// FALLTHRU (case-sensitive)
- default: // violation 'Fall through from previous branch of the switch statement.'
+ default: // violation 'Fall\ through from previous branch of the switch statement.'
"🥳".toString().equals("🥳");
// this is the last label
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/Example1.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/Example1.java
index acff087cb2d..c173b75a818 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/Example1.java
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/Example1.java
@@ -18,7 +18,7 @@ public void foo() throws Exception {
switch (i) {
case 1:
i++;
- case 2: // violation 'Fall through from previous branch of the switch'
+ case 2: // violation 'Fall\ through from previous branch of the switch'
i++;
break;
case 3:
@@ -29,7 +29,7 @@ public void foo() throws Exception {
throw new Exception();
case 5:
i++; // no break by design
- case 6: // violation 'Fall through from previous branch of the switch'
+ case 6: // violation 'Fall\ through from previous branch of the switch'
case 7:
i++;
continue;
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/Example2.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/Example2.java
index 80a701c7600..eafa329b281 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/Example2.java
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/Example2.java
@@ -20,7 +20,7 @@ public void foo() throws Exception {
switch (i) {
case 1:
i++;
- case 2: // violation 'Fall through from previous branch of the switch'
+ case 2: // violation 'Fall\ through from previous branch of the switch'
i++;
break;
case 3:
@@ -31,11 +31,11 @@ public void foo() throws Exception {
throw new Exception();
case 5:
i++; // no break by design
- case 6: // violation 'Fall through from previous branch of the switch'
+ case 6: // violation 'Fall\ through from previous branch of the switch'
case 7:
i++;
continue;
- case 11: // violation 'Fall through from the last branch of the switch'
+ case 11: // violation 'Fall\ through from the last branch of the switch'
i++;
}
}
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/Example3.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/Example3.java
index f5b61221b9b..ed84cb1c541 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/Example3.java
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/Example3.java
@@ -20,7 +20,7 @@ public void foo() throws Exception {
switch (i) {
case 1:
i++;
- case 2: // violation 'Fall through from previous branch of the switch'
+ case 2: // violation 'Fall\ through from previous branch of the switch'
i++;
break;
case 3:
diff --git a/src/xdocs/checks/coding/fallthrough.xml b/src/xdocs/checks/coding/fallthrough.xml
index 9ce8047564b..bf30e9a6205 100644
--- a/src/xdocs/checks/coding/fallthrough.xml
+++ b/src/xdocs/checks/coding/fallthrough.xml
@@ -89,7 +89,7 @@ class Example1 {
switch (i) {
case 1:
i++;
- case 2: // violation 'Fall through from previous branch of the switch'
+ case 2: // violation 'Fall\ through from previous branch of the switch'
i++;
break;
case 3:
@@ -100,7 +100,7 @@ class Example1 {
throw new Exception();
case 5:
i++; // no break by design
- case 6: // violation 'Fall through from previous branch of the switch'
+ case 6: // violation 'Fall\ through from previous branch of the switch'
case 7:
i++;
continue;
@@ -134,7 +134,7 @@ class Example2 {
switch (i) {
case 1:
i++;
- case 2: // violation 'Fall through from previous branch of the switch'
+ case 2: // violation 'Fall\ through from previous branch of the switch'
i++;
break;
case 3:
@@ -145,11 +145,11 @@ class Example2 {
throw new Exception();
case 5:
i++; // no break by design
- case 6: // violation 'Fall through from previous branch of the switch'
+ case 6: // violation 'Fall\ through from previous branch of the switch'
case 7:
i++;
continue;
- case 11: // violation 'Fall through from the last branch of the switch'
+ case 11: // violation 'Fall\ through from the last branch of the switch'
i++;
}
}
@@ -177,7 +177,7 @@ class Example3 {
switch (i) {
case 1:
i++;
- case 2: // violation 'Fall through from previous branch of the switch'
+ case 2: // violation 'Fall\ through from previous branch of the switch'
i++;
break;
case 3:
From f58e45eb77487425249b7b0cc2b8bebe54662b51 Mon Sep 17 00:00:00 2001
From: Rohanraj123
Date: Sun, 3 Sep 2023 20:20:36 +0530
Subject: [PATCH 033/833] Issue #13213: Remove '//ok' comments from
annotationusestyle
---
config/checkstyle-input-suppressions.xml | 92 -------------------
...utAnnotationUseStyleWithTrailingComma.java | 2 +-
.../InputAnnotationUseStyle.java | 2 +-
...nputAnnotationUseStyleEverythingMixed.java | 56 +++++------
...nnotationUseStyleNoTrailingCommaNever.java | 18 ++--
.../InputAnnotationUseStyleParams.java | 2 +-
...utAnnotationUseStyleWithTrailingComma.java | 30 ++----
7 files changed, 47 insertions(+), 155 deletions(-)
diff --git a/config/checkstyle-input-suppressions.xml b/config/checkstyle-input-suppressions.xml
index 10323c79e34..ee14f96b3bc 100644
--- a/config/checkstyle-input-suppressions.xml
+++ b/config/checkstyle-input-suppressions.xml
@@ -143,8 +143,6 @@
files="checks[\\/]annotation[\\/]annotationonsameline[\\/]InputAnnotationOnSameLineRecordsAndCompactCtors.java"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [] tokens();
int[] other();
}
From dbcbd67be9cd897d7fb46c7b7bb9cf448276f8fc Mon Sep 17 00:00:00 2001
From: Kevin222004
Date: Fri, 1 Sep 2023 23:41:28 +0530
Subject: [PATCH 034/833] Issue #13501: Kill mutation for DetailAstImpl-4
---
.../pitest-common-2-suppressions.xml | 32 +++++++++----------
.../tools/checkstyle/DetailAstImpl.java | 1 -
.../tools/checkstyle/DetailAstImplTest.java | 21 ++++++++++++
3 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/config/pitest-suppressions/pitest-common-2-suppressions.xml b/config/pitest-suppressions/pitest-common-2-suppressions.xml
index 37be04256b1..8cfe9bc1364 100644
--- a/config/pitest-suppressions/pitest-common-2-suppressions.xml
+++ b/config/pitest-suppressions/pitest-common-2-suppressions.xml
@@ -9,23 +9,23 @@
-
- DetailAstImpl.java
- com.puppycrawl.tools.checkstyle.DetailAstImpl
- addChild
- org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator
- removed call to com/puppycrawl/tools/checkstyle/DetailAstImpl::getLastChild
- astImpl.previousSibling = (DetailAstImpl) getLastChild();
-
-
- DetailAstImpl.java
- com.puppycrawl.tools.checkstyle.DetailAstImpl
- addChild
- org.pitest.mutationtest.engine.gregor.mutators.experimental.MemberVariableMutator
- Removed assignment to member variable previousSibling
- astImpl.previousSibling = (DetailAstImpl) getLastChild();
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
DetailAstImpl.java
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/DetailAstImpl.java b/src/main/java/com/puppycrawl/tools/checkstyle/DetailAstImpl.java
index db25b2752ce..870971dbf7c 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/DetailAstImpl.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/DetailAstImpl.java
@@ -166,7 +166,6 @@ public void addChild(DetailAST child) {
if (child != null) {
final DetailAstImpl astImpl = (DetailAstImpl) child;
astImpl.setParent(this);
- astImpl.previousSibling = (DetailAstImpl) getLastChild();
}
DetailAST temp = firstChild;
if (temp == null) {
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java
index 257e46d2a12..8ae777dc021 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java
@@ -674,6 +674,27 @@ public void testRemoveChildren() {
.isEqualTo(0);
}
+ @Test
+ public void testAddChild() {
+ final DetailAstImpl grandParent = new DetailAstImpl();
+ grandParent.setText("grandparent");
+ final DetailAstImpl parent = new DetailAstImpl();
+ parent.setText("parent");
+ grandParent.setFirstChild(parent);
+
+ final DetailAstImpl child = new DetailAstImpl();
+ child.setText("child");
+ parent.setFirstChild(child);
+
+ final DetailAstImpl secondChild = new DetailAstImpl();
+ secondChild.setText("SecondChild");
+ parent.addChild(secondChild);
+
+ assertWithMessage("Invalid previous sibling")
+ .that(secondChild.getPreviousSibling())
+ .isEqualTo(child);
+ }
+
private static List getAllFiles(File dir) {
final List result = new ArrayList<>();
From 790cd17bc5757b139589999d714c7f4203a610d8 Mon Sep 17 00:00:00 2001
From: Roman Ivanov
Date: Mon, 4 Sep 2023 08:10:52 -0700
Subject: [PATCH 035/833] Issue #13693: use property macros in few coding
modules
---
.../checks/coding/DeclarationOrderCheck.java | 4 +--
.../checks/coding/DeclarationOrderCheck.xml | 4 +--
.../checks/coding/arraytrailingcomma.xml | 5 +---
.../coding/arraytrailingcomma.xml.template | 23 +++-------------
src/xdocs/checks/coding/declarationorder.xml | 4 +--
.../coding/declarationorder.xml.template | 27 +++----------------
src/xdocs/checks/coding/defaultcomeslast.xml | 5 +---
.../coding/defaultcomeslast.xml.template | 23 +++-------------
8 files changed, 20 insertions(+), 75 deletions(-)
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java
index 872f988eecb..a0c732f246b 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java
@@ -73,12 +73,12 @@
*
*
*
- * Property {@code ignoreConstructors} - control whether to ignore constructors.
+ * Property {@code ignoreConstructors} - Control whether to ignore constructors.
* Type is {@code boolean}.
* Default value is {@code false}.
*
*
- * Property {@code ignoreModifiers} - control whether to ignore modifiers (fields, ...).
+ * Property {@code ignoreModifiers} - Control whether to ignore modifiers (fields, ...).
* Type is {@code boolean}.
* Default value is {@code false}.
*
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/DeclarationOrderCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/DeclarationOrderCheck.xml
index b0f99807d5b..b1355c9e37a 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/DeclarationOrderCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/DeclarationOrderCheck.xml
@@ -45,10 +45,10 @@
</pre>
- control whether to ignore constructors.
+ Control whether to ignore constructors.
- control whether to ignore modifiers (fields, ...).
+ Control whether to ignore modifiers (fields, ...).
diff --git a/src/xdocs/checks/coding/arraytrailingcomma.xml b/src/xdocs/checks/coding/arraytrailingcomma.xml
index d5068b62451..b108f0732be 100644
--- a/src/xdocs/checks/coding/arraytrailingcomma.xml
+++ b/src/xdocs/checks/coding/arraytrailingcomma.xml
@@ -89,10 +89,7 @@ return new int[] {
alwaysDemandTrailingComma
-
- Control whether to always check for a trailing comma, even when an array is
- inline.
-
+
Control whether to always check for a trailing comma, even when an array is inline.
diff --git a/src/xdocs/checks/coding/declarationorder.xml b/src/xdocs/checks/coding/declarationorder.xml
index b5af45646ad..505e96ee412 100644
--- a/src/xdocs/checks/coding/declarationorder.xml
+++ b/src/xdocs/checks/coding/declarationorder.xml
@@ -71,14 +71,14 @@ public class A {
diff --git a/src/xdocs/checks/coding/declarationorder.xml.template b/src/xdocs/checks/coding/declarationorder.xml.template
index 84bbdc91dc7..3e1e3219410 100644
--- a/src/xdocs/checks/coding/declarationorder.xml.template
+++ b/src/xdocs/checks/coding/declarationorder.xml.template
@@ -61,29 +61,10 @@ public class A {
- * Property {@code onlyObjectReferences} - control whether only explicit
+ * Property {@code onlyObjectReferences} - Control whether only explicit
* initializations made to null for objects should be checked.
* Type is {@code boolean}.
* Default value is {@code false}.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/ExplicitInitializationCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/ExplicitInitializationCheck.xml
index c09ece8261e..b9faeda14cd 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/ExplicitInitializationCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/ExplicitInitializationCheck.xml
@@ -20,7 +20,7 @@
</p>
- control whether only explicit
+ Control whether only explicit
initializations made to null for objects should be checked.
diff --git a/src/xdocs/checks/coding/equalsavoidnull.xml b/src/xdocs/checks/coding/equalsavoidnull.xml
index f9e58162cba..c810f873a2b 100644
--- a/src/xdocs/checks/coding/equalsavoidnull.xml
+++ b/src/xdocs/checks/coding/equalsavoidnull.xml
@@ -38,9 +38,7 @@
ignoreEqualsIgnoreCase
-
- Control whether to ignore String.equalsIgnoreCase(String) invocations.
-
+
Control whether to ignore String.equalsIgnoreCase(String) invocations.
-class Foo {
+class Example1 {
- @SuppressWarnings("deprecation") // violation, annotation should be on the same line
- public Foo() {
+ @SuppressWarnings("deprecation") // violation
+ public Example1() {
}
@SuppressWarnings("unchecked") public void fun2() { // OK
}
+ public void fun1() {
+ }
+
}
-@SuppressWarnings("unchecked") class Bar extends Foo { // OK
+@SuppressWarnings("unchecked") class Test1 extends Example1 { // OK
- @Deprecated public Bar() { // OK
+ @Deprecated public Test1() { // OK
}
- @Override // violation, annotation should be on the same line
+ @Override // violation
public void fun1() {
}
- @Before @Override public void fun2() { // OK
+ @Before // violation
+ @Override public void fun2() { // OK
}
- @SuppressWarnings("deprecation") // violation, annotation should be on the same line
+ @SuppressWarnings("deprecation") // violation
@Before public void fun3() {
}
}
-
+
+
To configure the check to check for annotations applied on
interfaces, variables and constructors:
@Deprecated interface Foo { // OK
@@ -151,17 +160,17 @@ class Foo {
}
-class Bar implements Foo {
+class Example2 implements Foo {
- @SuppressWarnings("deprecation") // violation, annotation should be on the same line
- public Bar() {
+ @SuppressWarnings("deprecation") // violation
+ public Example2() {
}
@Override // OK
public void doSomething() {
}
- @Nullable // violation, annotation should be on the same line
+ @Nullable // violation
String s;
}
diff --git a/src/xdocs/checks/annotation/annotationonsameline.xml.template b/src/xdocs/checks/annotation/annotationonsameline.xml.template
index fd8bca3d9a2..4bc43aabcde 100644
--- a/src/xdocs/checks/annotation/annotationonsameline.xml.template
+++ b/src/xdocs/checks/annotation/annotationonsameline.xml.template
@@ -92,80 +92,36 @@
-
+
To configure the check:
-
-<module name="AnnotationOnSameLine"/>
-
-
- Example:
-
-
-class Foo {
-
- @SuppressWarnings("deprecation") // violation, annotation should be on the same line
- public Foo() {
- }
-
- @SuppressWarnings("unchecked") public void fun2() { // OK
- }
-
-}
-
-@SuppressWarnings("unchecked") class Bar extends Foo { // OK
-
- @Deprecated public Bar() { // OK
- }
-
- @Override // violation, annotation should be on the same line
- public void fun1() {
- }
-
- @Before @Override public void fun2() { // OK
- }
-
- @SuppressWarnings("deprecation") // violation, annotation should be on the same line
- @Before public void fun3() {
- }
+
+
+
+
+
Example:
+
+
+
+
-}
-
-
+
To configure the check to check for annotations applied on
interfaces, variables and constructors:
-
-@Deprecated interface Foo { // OK
-
- void doSomething();
-
-}
-
-class Bar implements Foo {
-
- @SuppressWarnings("deprecation") // violation, annotation should be on the same line
- public Bar() {
- }
-
- @Override // OK
- public void doSomething() {
- }
-
- @Nullable // violation, annotation should be on the same line
- String s;
-
-}
-
+
+
+
+
+
Example:
+
+
+
+
From f61e24307e6b77cb2aa705226f492257fca03654 Mon Sep 17 00:00:00 2001
From: piyush kumar sadangi
Date: Fri, 8 Sep 2023 12:40:26 +0530
Subject: [PATCH 063/833] Issue #13213: Remove '//ok' comments from blocks
package
---
config/checkstyle-input-suppressions.xml | 946 ------------------
.../InputNeedBracesTestSwitchExpression.java | 18 +-
...tRightCurlyTestRecordsAndCompactCtors.java | 2 +-
.../InputRightCurlyTestSwitchExpression.java | 18 +-
.../InputRightCurlyTestSwitchExpression2.java | 16 +-
.../InputRightCurlyTestSwitchExpression3.java | 2 +-
.../InputRightCurlyTestSwitchExpression4.java | 20 +-
.../InputRightCurlyTestSwitchExpression5.java | 14 +-
.../InputRightCurlyTestSwitchExpression6.java | 12 +-
.../InputRightCurlyTestSwitchExpression7.java | 8 +-
...putAvoidNestedBlocksAllowInSwitchCase.java | 6 +-
.../InputAvoidNestedBlocksDefault.java | 6 +-
...putEmptyBlockAnnotationDefaultKeyword.java | 2 +-
.../emptyblock/InputEmptyBlockCase.java | 8 +-
.../emptyblock/InputEmptyBlockCase2.java | 6 +-
.../emptyblock/InputEmptyBlockDefault.java | 18 +-
.../emptyblock/InputEmptyBlockDefault2.java | 12 +-
.../emptyblock/InputEmptyBlockSemantic.java | 6 +-
.../InputEmptyBlockSemantic2Statement.java | 6 +-
.../InputEmptyBlockSemantic2Text.java | 6 +-
.../InputEmptyBlockSemanticInvalid.java | 6 +-
.../InputEmptyBlockSemanticStatement.java | 6 +-
.../InputEmptyBlockSemanticText.java | 12 +-
...EmptyBlockTestUppercaseOptionProperty.java | 4 +-
.../emptyblock/InputEmptyBlockWithEmoji.java | 4 +-
.../InputEmptyCatchBlockDefault.java | 2 +-
.../InputLeftCurlyCommentBeforeLeftCurly.java | 14 +-
...InputLeftCurlyCommentBeforeLeftCurly2.java | 14 +-
.../InputLeftCurlyDefaultTestNl.java | 10 +-
.../InputLeftCurlyDefaultTestNlow.java | 6 +-
.../InputLeftCurlyIgnoreEnumsOptTrue.java | 2 +-
.../leftcurly/InputLeftCurlyMethod.java | 16 +-
.../InputLeftCurlyMethodTestNewLine2.java | 30 +-
.../leftcurly/InputLeftCurlyTestDefault.java | 20 +-
.../leftcurly/InputLeftCurlyTestDefault3.java | 10 +-
.../InputLeftCurlyTestDefaultLambda.java | 2 +-
...utLeftCurlyTestDefaultWithAnnotations.java | 8 +-
.../InputLeftCurlyTestFirstLine.java | 2 +-
.../InputLeftCurlyTestInvalidOption.java | 30 +-
.../leftcurly/InputLeftCurlyTestNewLine3.java | 50 +-
...tLeftCurlyTestNewLineOptionWithLambda.java | 4 +-
.../InputLeftCurlyTestNlWithAnnotations.java | 12 +-
...InputLeftCurlyTestNlowWithAnnotations.java | 8 +-
.../leftcurly/InputLeftCurlyWithEmoji.java | 16 +-
.../leftcurly/InputLeftCurlyWithEmojiNl.java | 20 +-
.../InputLeftCurlyWithTrimOptionProperty.java | 2 +-
...tNeedBracesEmptySingleLineDefaultStmt.java | 2 +-
.../InputNeedBracesLoopBodyTrue.java | 32 +-
.../InputNeedBracesSingleLineStatements.java | 8 +-
.../needbraces/InputNeedBracesTestCycles.java | 6 +-
.../InputNeedBracesTestItWithAllowsOn.java | 10 +-
...utNeedBracesTestSingleLineCaseDefault.java | 22 +-
...tNeedBracesTestSingleLineCaseDefault2.java | 2 +-
.../InputNeedBracesTestSingleLineLambda.java | 4 +-
.../InputRightCurlyLeftTestAlone.java | 24 +-
.../InputRightCurlyLeftTestDefault.java | 42 +-
.../InputRightCurlyLeftTestNewLine.java | 28 +-
.../InputRightCurlyLeftTestSame.java | 36 +-
...putRightCurlyLeftTestShouldStartLine2.java | 38 +-
...tRightCurlyNewTokensAloneOrSingleLine.java | 4 +-
.../InputRightCurlyTestEmptyOnSingleLine.java | 2 +-
...utRightCurlyTestForceLineBreakBefore2.java | 10 +-
.../InputRightCurlyTestInvalidOption.java | 4 +-
.../InputRightCurlyTestIsAloneLambda.java | 8 +-
...ghtCurlyTestIsAloneOrSinglelineLambda.java | 8 +-
.../InputRightCurlyTestIsSameLambda.java | 12 +-
...putRightCurlyTestNullPointerException.java | 2 +-
...estOptAloneOrSingleLineBlocksWithSemi.java | 14 +-
...utRightCurlyTestOptSameBlocksWithSemi.java | 14 +-
.../InputRightCurlyTestOptionAlone.java | 2 +-
...RightCurlyTestOptionAloneOrSingleLine.java | 16 +-
.../rightcurly/InputRightCurlyTestSame.java | 2 +-
.../InputRightCurlyTestSameNewTokens.java | 4 +-
.../InputRightCurlyTestSameOmitOneLiners.java | 2 +-
.../InputRightCurlyTestSingleLineClass.java | 2 +-
.../InputRightCurlyTestSwitchCase.java | 14 +-
.../InputRightCurlyTestSwitchCase2.java | 18 +-
.../InputRightCurlyTestSwitchCase3.java | 2 +-
.../InputRightCurlyTestSwitchCase4.java | 6 +-
.../InputRightCurlyTestSwitchCase5.java | 16 +-
...putRightCurlyTestTryWithResourceAlone.java | 2 +-
...nputRightCurlyTestTryWithResourceSame.java | 8 +-
.../InputRightCurlyTestWithoutFinally.java | 2 +-
...tRightCurlyTryWithResourceAloneSingle.java | 8 +-
.../rightcurly/InputRightCurlyWithEmoji.java | 12 +-
...tRightCurlyWithEmojiAloneOrSingleLine.java | 10 +-
86 files changed, 477 insertions(+), 1423 deletions(-)
diff --git a/config/checkstyle-input-suppressions.xml b/config/checkstyle-input-suppressions.xml
index 9efb98009b0..f112d1035b4 100644
--- a/config/checkstyle-input-suppressions.xml
+++ b/config/checkstyle-input-suppressions.xml
@@ -143,116 +143,6 @@
files="checks[\\/]avoidescapedunicodecharacters[\\/]InputAvoidEscapedUnicodeCharactersEscapedS.java"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {
yield 99;
}
- default -> throw new IllegalStateException("Not a Nums"); // ok
+ default -> throw new IllegalStateException("Not a Nums");
};
}
@@ -96,19 +96,19 @@ int howMany5(Nums k) {
void howMany6(Nums k) {
switch (k) {
- case ONE: System.out.println("case two"); // ok
- case TWO, THREE: System.out.println("case two"); // ok
- case FOUR: System.out.println("case three"); // ok
- default: throw new IllegalStateException("Not a nums"); // ok
+ case ONE: System.out.println("case two");
+ case TWO, THREE: System.out.println("case two");
+ case FOUR: System.out.println("case three");
+ default: throw new IllegalStateException("Not a nums");
}
}
void howMany7(Nums k) {
switch (k) {
- case ONE -> System.out.println("case one"); // ok
- case TWO, THREE -> System.out.println("case two"); // ok
- case FOUR -> System.out.println("case three"); // ok
- default -> throw new IllegalStateException("Not a nums"); // ok
+ case ONE -> System.out.println("case one");
+ case TWO, THREE -> System.out.println("case two");
+ case FOUR -> System.out.println("case three");
+ default -> throw new IllegalStateException("Not a nums");
}
}
}
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestRecordsAndCompactCtors.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestRecordsAndCompactCtors.java
index 156506e0f8f..72459d97389 100644
--- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestRecordsAndCompactCtors.java
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestRecordsAndCompactCtors.java
@@ -42,5 +42,5 @@ record MyTestRecord5() {
// violation above ''}' at column 68 should be alone on a line'
class MyTestClass {
private MyTestRecord mtr =
- new MyTestRecord("my string", new MyTestRecord4());} // ok
+ new MyTestRecord("my string", new MyTestRecord4());}
}
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression.java
index d975706e22a..ef0d31dc8ef 100644
--- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression.java
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression.java
@@ -19,7 +19,7 @@ public void test() {
case 2 -> "Tuesday";
case 3 -> "Wednesday";
default -> "Invalid day";
- }; } // ok
+ }; }
public void test1() {
int day = 3;
@@ -27,7 +27,7 @@ public void test1() {
switch (day) {
case 1 -> "Monday";
default -> "Invalid day";
- }; // ok
+ };
}
public void test2() {
@@ -36,7 +36,7 @@ public void test2() {
switch (day) {
case 1 -> "Monday";
default -> "Invalid day";
- }; System.out.println(check); // ok
+ }; System.out.println(check);
}
public void test3() {
@@ -60,7 +60,7 @@ public void test5() {
switch (num) {
case 1 -> System.out.println("One");
default -> System.out.println("Other");
- } // ok
+ }
}
public void test6() {
@@ -68,7 +68,7 @@ public void test6() {
switch (num) {
//no case or default statement
- } // ok
+ }
}
public void test7() {
@@ -76,7 +76,7 @@ public void test7() {
switch (num) {
//no case or default statement
- } // ok
+ }
}
public void test8() {
@@ -102,17 +102,17 @@ public void test9() {
default -> {
Runnable defaultResult = () -> System.out.println("defaultResult");
}
- } // ok
+ }
}
public void test10() {
int expression = 2;
switch (expression) { case 1 -> { Runnable result1 = () -> System.out.println("r1"); }
- } // ok
+ }
switch (expression) {
case 1 -> {
Runnable result1 = () -> System.out.println("r1");
}
- } // ok
+ }
}
}
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression2.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression2.java
index 9eda6d8a553..390ca7cbbad 100644
--- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression2.java
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression2.java
@@ -17,7 +17,7 @@ public void test() {
switch (day) {
case 1 -> "Monday";
default -> "Invalid day";
- }; } // ok
+ }; }
public void test1() {
int day = 3;
@@ -34,7 +34,7 @@ public void test2() {
switch (day) {
case 1 -> "Monday";
default -> "Invalid day";
- }; System.out.println(check); // ok
+ }; System.out.println(check);
}
public void test3() {
@@ -58,7 +58,7 @@ public void test5() {
switch (num) {
case 1 -> System.out.println("One");
default -> System.out.println("Other");
- } // ok
+ }
}
public void test6() {
@@ -66,7 +66,7 @@ public void test6() {
switch (num) {
//no case or default statement
- } // ok
+ }
}
public void test7() {
@@ -100,19 +100,19 @@ public void test9() {
default -> {
Runnable defaultResult = () -> System.out.println("defaultResult");
}
- } // ok
+ }
}
public void test10() {
int expression = 2;
switch (expression)
- { case 1 -> { Runnable result1 = () -> System.out.println("r1"); } } // ok
+ { case 1 -> { Runnable result1 = () -> System.out.println("r1"); } }
switch (expression)
- { case 1 -> { Runnable result1 = () -> System.out.println("r1"); } } // ok
+ { case 1 -> { Runnable result1 = () -> System.out.println("r1"); } }
switch (expression) {
case 1 -> {
Runnable result1 = () -> System.out.println("r1");
}
- } // ok
+ }
}
}
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression3.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression3.java
index e3bd1d0dfcd..3f998ed1299 100644
--- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression3.java
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression3.java
@@ -25,5 +25,5 @@ int foo2(int yield) {
case 2 -> 3;
case 3 -> 4;
default -> 5;
- }; } // ok
+ }; }
}
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression4.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression4.java
index 05f5f3e86d7..23e821b8911 100644
--- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression4.java
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression4.java
@@ -30,8 +30,8 @@ public InputFinalLocalVariableCheckSwitchAssignment() throws Exception {
throw new Exception();
}
default -> 2;
- }; // ok
- }; // ok
+ };
+ };
}
public void foo() throws Exception {
@@ -47,21 +47,21 @@ public void foo() throws Exception {
throw new Exception();
}
default -> 2;
- }; // ok
+ };
int c = switch (b) {
case 0 -> 1;
default -> 2;
- }; // ok
+ };
c = switch (a) {
case 0 -> switch (b) {
case 0 -> 1;
case 1 -> 2;
default -> 3;
- }; // ok
+ };
default -> 1;
- }; // ok
+ };
}
}
}
@@ -78,11 +78,11 @@ public enum Day {
}
public void foo2(Options option) {
- assert Integer.valueOf(1).equals(switch (option) { // ok
+ assert Integer.valueOf(1).equals(switch (option) {
case ONE -> 1;
case TWO -> 2;
case THREE -> 3;
- }); // ok
+ });
}
}
@@ -102,7 +102,7 @@ private int id(int i) {
yield temp;
}
default -> throw new IllegalStateException();
- }); // ok
+ });
void commentBeforeRightCurly() {
int i = 20;
@@ -110,7 +110,7 @@ void commentBeforeRightCurly() {
switch (i) {
case 0:
i++;
- } // ok
+ }
switch (i) {
case 0:
i++;
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression5.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression5.java
index ee645c7f0da..d213ca7f633 100644
--- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression5.java
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression5.java
@@ -32,7 +32,7 @@ public InputFinalLocalVariableCheckSwitchAssignment() throws Exception {
}
default -> 2;
};
- }; // ok
+ };
}
public void foo() throws Exception {
@@ -57,8 +57,8 @@ public void foo() throws Exception {
case 0 -> switch (b) {
case 0 -> 1;
case 1 -> 2;
- default -> 3; }; // ok
- default -> 1; }; // ok
+ default -> 3; };
+ default -> 1; };
}
}
}
@@ -70,9 +70,9 @@ public enum Day {
public enum Options { THREE }
public void foo2(Options option) {
- assert Integer.valueOf(1).equals(switch (option) { // ok
+ assert Integer.valueOf(1).equals(switch (option) {
case THREE -> 3;
- }); // ok
+ });
}
}
@@ -92,7 +92,7 @@ private int id(int i) {
yield temp;
}
default -> throw new IllegalStateException();
- }); // ok
+ });
public static void method0() throws IOException {
int stValue = 0;
@@ -101,7 +101,7 @@ public static void method0() throws IOException {
switch (stValue) {
case 0:
break;
- } // ok
+ }
} catch (NumberFormatException e) {
throw new IOException(" value ");
}
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression6.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression6.java
index 62267ffc9fc..ff06bccd684 100644
--- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression6.java
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression6.java
@@ -19,7 +19,7 @@ public void foo5() {
case B:
default:
yield false;
- }) && x == 1; // ok
+ }) && x == 1;
{
final T y = T.A;
@@ -32,7 +32,7 @@ public void foo5() {
yield (x = 1) == 1 || true;
default:
yield false;
- }) && x == 1; // ok
+ }) && x == 1;
}
{
@@ -65,7 +65,7 @@ public void foo5() {
x = 1;
yield true;
}
- }) && x == 1; // ok
+ }) && x == 1;
}
}
@@ -74,7 +74,7 @@ public void bar2(Option option) {
case ONE -> 1;
case TWO -> 2;
case THREE -> 3;
- }; // ok
+ };
}
int usedOnBothSidesOfArithmeticExpression(Day day) {
@@ -82,7 +82,7 @@ int usedOnBothSidesOfArithmeticExpression(Day day) {
case MON, TUE -> 0;
case WED -> 1;
default -> 2;
- } * switch (day) { // ok
+ } * switch (day) {
case WED, THU -> 3;
case FRI -> 4;
default -> 5;
@@ -102,7 +102,7 @@ int usedOnBothSidesOfArithmeticExpression(Day day) {
yield (x = 1) == 1 || true;
default
:yield false;
- }) && x == 1; // ok
+ }) && x == 1;
}
}
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression7.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression7.java
index 25d7638bfee..eb5248acaf5 100644
--- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression7.java
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchExpression7.java
@@ -16,7 +16,7 @@ String isDayNameLong(Day day) {
case TUE -> 7;
case THU, SAT -> 8;
case WED -> 9;
- } > 7 ? "long" : "short"; // ok
+ } > 7 ? "long" : "short";
}
int arithmetic(Day day) {
@@ -25,7 +25,7 @@ int arithmetic(Day day) {
case TUE -> 7;
case THU, SAT -> 8;
case WED -> 9;
- } % 2; // ok
+ } % 2;
}
int signArithmetic(Day day) {
@@ -42,11 +42,11 @@ int usedOnBothSidesOfArithmeticExpression(Day day) {
case MON, TUE -> 0;
case WED -> 1;
default -> 2;
- } * switch (day) { // ok
+ } * switch (day) {
case WED, THU -> 3;
case FRI -> 4;
default -> 5;
- }; // ok
+ };
}
static {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/avoidnestedblocks/InputAvoidNestedBlocksAllowInSwitchCase.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/avoidnestedblocks/InputAvoidNestedBlocksAllowInSwitchCase.java
index ac6303af791..e1380c7dda2 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/avoidnestedblocks/InputAvoidNestedBlocksAllowInSwitchCase.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/avoidnestedblocks/InputAvoidNestedBlocksAllowInSwitchCase.java
@@ -10,7 +10,7 @@
class InputAvoidNestedBlocksAllowInSwitchCase
{
static
- { // ok
+ {
}
public void method()
@@ -24,7 +24,7 @@ public void method()
}
if (x == 1)
- { // ok
+ {
x = 2;
}
@@ -35,7 +35,7 @@ public void method()
switch (x)
{
case 0:
- // ok
+
x = 3;
break;
case 1:
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/avoidnestedblocks/InputAvoidNestedBlocksDefault.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/avoidnestedblocks/InputAvoidNestedBlocksDefault.java
index f087c49b21b..52475dad009 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/avoidnestedblocks/InputAvoidNestedBlocksDefault.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/avoidnestedblocks/InputAvoidNestedBlocksDefault.java
@@ -14,7 +14,7 @@
class InputAvoidNestedBlocksDefault
{
static
- { // ok
+ {
}
public void method()
@@ -28,7 +28,7 @@ public void method()
}
if (x == 1)
- { // ok
+ {
x = 2;
}
@@ -39,7 +39,7 @@ public void method()
switch (x)
{
case 0:
- // ok
+
x = 3;
break;
case 1:
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockAnnotationDefaultKeyword.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockAnnotationDefaultKeyword.java
index f1bcc0a15b4..75568f35272 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockAnnotationDefaultKeyword.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockAnnotationDefaultKeyword.java
@@ -9,5 +9,5 @@
package com.puppycrawl.tools.checkstyle.checks.blocks.emptyblock;
public @interface InputEmptyBlockAnnotationDefaultKeyword {
- String name() default ""; // ok
+ String name() default "";
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockCase.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockCase.java
index 68c68432ab3..22f6663bdc5 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockCase.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockCase.java
@@ -12,7 +12,7 @@ class InputEmptyBlockCase
{
void method1(int a) {
switch (a) {}
- switch (a) {case 1: ; } // ok
+ switch (a) {case 1: ; }
switch (a) {case 1:{}} // violation 'Empty case block'
switch (a) {
case 1:
@@ -23,15 +23,15 @@ void method1(int a) {
}
switch (a) {
case 1:
- { // ok
+ { // ok as the block contains a comment
}
}
}
public void method2(char c) {
- switch(c) { case 0: } // ok
+ switch(c) { case 0: }
switch(c) { case 0: {} method1(1); } // violation 'Empty case block'
- switch(c) { case 0: method1(0); {} } // ok
+ switch(c) { case 0: method1(0); {} }
switch(c) { case 0: case 1: {} } // violation 'Empty case block'
switch(c) { case 0: {} case 1: { // violation 'Empty case block'
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockCase2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockCase2.java
index 48cbaa29156..a34c07b9339 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockCase2.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockCase2.java
@@ -12,7 +12,7 @@ class InputEmptyBlockCase2
{
void method1(int a) {
switch (a) {}
- switch (a) {case 1: ; } // ok
+ switch (a) {case 1: ; }
switch (a) {case 1:{}} // violation 'Must have at least one statement'
switch (a) {
case 1:
@@ -29,9 +29,9 @@ void method1(int a) {
}
public void method2(char c) {
- switch(c) { case 0: } // ok
+ switch(c) { case 0: }
switch(c) { case 0: {} method1(1); } // violation 'Must have at least one statement'
- switch(c) { case 0: method1(0); {} } // ok
+ switch(c) { case 0: method1(0); {} }
switch(c) { case 0: case 1: {} } // violation 'Must have at least one statement'
switch(c) { case 0: {} case 1: { // 2 violations
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockDefault.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockDefault.java
index 4ccf5d6b8bd..25933fc76bd 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockDefault.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockDefault.java
@@ -11,7 +11,7 @@
public class InputEmptyBlockDefault {
void method1(int a) {
switch (a) {}
- switch (a) {default: ; } // ok
+ switch (a) {default: ; }
switch (a) {default: {}} // violation 'Empty default block'
switch (a) {
default:
@@ -22,7 +22,7 @@ void method1(int a) {
}
switch (a) {
default:
- { // ok
+ { // ok as the block contains a comment
}
}
}
@@ -31,9 +31,9 @@ void method2(int a) {
switch (a) {
case 1:a++;
case 2:a++;
- default: // ok
+ default:
switch (a) {
- default: { // ok
+ default: { // ok as the block contains a comment
}
}
@@ -48,7 +48,7 @@ void method3(int a, int b) {
switch (b) {
case 2: break;
- default: method2(b); {} // ok
+ default: method2(b); {}
}
switch (a+b) {case 1: break; default: {} ; } // violation 'Empty default block'
@@ -62,17 +62,17 @@ void method4(int a, int b) {
switch (b) {
case 1:
- default: // ok
+ default:
}
switch (a+b) {
- default: // ok
+ default:
case 1: { }
}
switch (a-b) {
case 1:
- default: { // ok
+ default: { // ok as the block contains a comment
} ;
case 2: { }
@@ -90,7 +90,7 @@ void method5(int a, int b) {
}
switch (b) {
- default: // ok
+ default:
case 1:
case 2: { } method2(b);
case 3:
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockDefault2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockDefault2.java
index 606ffb0783d..0f36f47f31f 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockDefault2.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockDefault2.java
@@ -11,7 +11,7 @@
public class InputEmptyBlockDefault2 {
void method1(int a) {
switch (a) {}
- switch (a) {default: ; } // ok
+ switch (a) {default: ; }
switch (a) {default: {}} // violation 'Must have at least one statement'
switch (a) {
default:
@@ -31,7 +31,7 @@ void method2(int a) {
switch (a) {
case 1:a++;
case 2:a++;
- default: // ok
+ default:
switch (a) {
default: { // violation 'Must have at least one statement'
@@ -48,7 +48,7 @@ void method3(int a, int b) {
switch (b) {
case 2: break;
- default: method2(b); {} // ok
+ default: method2(b); {}
}
switch (a+b) {case 1: break; default: {} ; }// violation 'Must have at least one statement'
@@ -62,11 +62,11 @@ void method4(int a, int b) {
switch (b) {
case 1:
- default: // ok
+ default:
}
switch (a+b) {
- default: // ok
+ default:
case 1: { }
}
@@ -90,7 +90,7 @@ void method5(int a, int b) {
}
switch (b) {
- default: // ok
+ default:
case 1:
case 2: { } method2(b);
case 3:
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemantic.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemantic.java
index 0fae0ee7ce2..721f2b9e200 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemantic.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemantic.java
@@ -45,10 +45,10 @@ void exHandlerTest()
finally { // violation 'Must have at least one statement'
// something
}
- try { // ok
+ try {
; // something
}
- finally { // ok
+ finally {
; // statement
}
}
@@ -74,7 +74,7 @@ private class InputBraces {
synchronized void foo() {
synchronized (this) {} // violation 'Must have at least one statement'
- synchronized (Class.class) { // ok
+ synchronized (Class.class) {
synchronized (new Object()) { // violation 'Must have at least one statement'
// text
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemantic2Statement.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemantic2Statement.java
index 26e7359482a..46fefe25432 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemantic2Statement.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemantic2Statement.java
@@ -22,11 +22,11 @@ public void fooMethod()
char[] s = {'1', '2'};
int index = 2;
if (doSideEffect() == 1) {} // violation 'Must have at least one statement'
- while ((a = index - 1) != 0) {} // ok
- for (; index < s.length && s[index] != 'x'; index++) {} // ok
+ while ((a = index - 1) != 0) {}
+ for (; index < s.length && s[index] != 'x'; index++) {}
if (a == 1) {} else {a++;}// violation 'Must have at least one statement'
switch (a) {} // violation 'Must have at least one statement'
- switch (a) { // ok
+ switch (a) {
case 1:
a = 2;
case 2:
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemantic2Text.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemantic2Text.java
index d176e8b6ab8..49d8ea3a463 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemantic2Text.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemantic2Text.java
@@ -27,11 +27,11 @@ public void fooMethod()
char[] s = {'1', '2'};
int index = 2;
if (doSideEffect() == 1) {} // violation 'Empty if block'
- while ((a = index - 1) != 0) {} // ok
- for (; index < s.length && s[index] != 'x'; index++) {} // ok
+ while ((a = index - 1) != 0) {}
+ for (; index < s.length && s[index] != 'x'; index++) {}
if (a == 1) {} else {System.identityHashCode("a");} // violation 'Empty if block'
switch (a) {} // violation 'Empty switch block'
- switch (a) { // ok
+ switch (a) {
case 1:
a = 2;
case 2:
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemanticInvalid.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemanticInvalid.java
index e44f330ec89..0034ed314c2 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemanticInvalid.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemanticInvalid.java
@@ -45,10 +45,10 @@ void exHandlerTest()
finally {
// something
}
- try { // ok
+ try {
; // something
}
- finally { // ok
+ finally {
; // statement
}
}
@@ -74,7 +74,7 @@ private class InputBraces {
synchronized void foo() {
synchronized (this) {}
- synchronized (Class.class) { // ok
+ synchronized (Class.class) {
synchronized (new Object()) {
// text
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemanticStatement.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemanticStatement.java
index aa3892630c7..7fdeb2ef060 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemanticStatement.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemanticStatement.java
@@ -45,10 +45,10 @@ void exHandlerTest()
finally { // violation 'Must have at least one statement'
// something
}
- try { // ok
+ try {
; // something
}
- finally { // ok
+ finally {
; // statement
}
}
@@ -74,7 +74,7 @@ private class InputBraces {
synchronized void foo() {
synchronized (this) {} // violation 'Must have at least one statement'
- synchronized (Class.class) { // ok
+ synchronized (Class.class) {
synchronized (new Object()) { // violation 'Must have at least one statement'
// text
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemanticText.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemanticText.java
index 91eb313372a..9884a7cf3b7 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemanticText.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockSemanticText.java
@@ -39,16 +39,16 @@ void exHandlerTest()
} // violation above 'Empty try block'
finally {
} // violation above 'Empty finally block'
- try { // ok
+ try {
// something
}
- finally { // ok
+ finally {
// something
}
- try { // ok
+ try {
; // something
}
- finally { // ok
+ finally {
; // statement
}
}
@@ -74,8 +74,8 @@ private class InputBraces {
synchronized void foo() {
synchronized (this) {} // violation 'Empty synchronized block'
- synchronized (Class.class) { // ok
- synchronized (new Object()) { // ok
+ synchronized (Class.class) {
+ synchronized (new Object()) {
// text
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockTestUppercaseOptionProperty.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockTestUppercaseOptionProperty.java
index 1250b9733f3..446a0c72122 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockTestUppercaseOptionProperty.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockTestUppercaseOptionProperty.java
@@ -12,7 +12,7 @@ public class InputEmptyBlockTestUppercaseOptionProperty {
void method1(int a) {
switch (a) {}
- switch (a) {default: ; } // ok
+ switch (a) {default: ; }
switch (a) {default: {}} // violation 'Empty default block'
switch (a) {
default:
@@ -23,7 +23,7 @@ void method1(int a) {
}
switch (a) {
default:
- { // ok
+ { // ok as the block contains a comment
}
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockWithEmoji.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockWithEmoji.java
index d91da15d9bb..adcc2952b30 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockWithEmoji.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock/InputEmptyBlockWithEmoji.java
@@ -26,14 +26,14 @@ public void fooMethod()
char[] s = {'1', '2'};
int index = 2;
if (doSideEffect() == 1) { } // violation 'Empty if block'
- while ((a = "12") != "🧐") {return;} // ok
+ while ((a = "12") != "🧐") {return;}
for (; index < s.length && s[index] != 'x'; index++) {} // violation 'Empty for block'
if (a == "12🤣") {} else {System.identityHashCode("a");} // violation 'Empty if block'
// violation below 'Empty switch block'
switch("😆😆😆😆😆") {
}
- switch (a) { // ok
+ switch (a) {
case "🎄": {
a = "🤣🤣";
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptycatchblock/InputEmptyCatchBlockDefault.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptycatchblock/InputEmptyCatchBlockDefault.java
index dcce00874fc..bb6e12e2c2e 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptycatchblock/InputEmptyCatchBlockDefault.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/emptycatchblock/InputEmptyCatchBlockDefault.java
@@ -84,7 +84,7 @@ public void testTryCatch2()
{
try {
}
- catch (Exception e) { //OK
+ catch (Exception e) {
//This is expected
/* This is expected */
/**This is expected */
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyCommentBeforeLeftCurly.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyCommentBeforeLeftCurly.java
index 7862fc8f8f4..67bf88bbc9a 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyCommentBeforeLeftCurly.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyCommentBeforeLeftCurly.java
@@ -36,7 +36,7 @@ void method1 ()
private void some() throws Exception {
try {
throw new IOException();
- } catch (IOException | NullPointerException | ArithmeticException ex) //ok
+ } catch (IOException | NullPointerException | ArithmeticException ex)
/* warn */ { // ok until #11410
}
}
@@ -50,7 +50,7 @@ private class Node {
Node next;
public
- /**** comment **********/ Node(int value) /*comment*/ { // ok
+ /**** comment **********/ Node(int value) /*comment*/ {
this.value=value;
}
@@ -63,7 +63,7 @@ public Node(int value, Node next)
public void array() {
Integer[] array = null;
- /*50*/ for/*51*/ (/*52*/Integer/*53*/ i/*54*/:/*55*/ array/*56*/)/*57*/ {/*58*/ // ok
+ /*50*/ for/*51*/ (/*52*/Integer/*53*/ i/*54*/:/*55*/ array/*56*/)/*57*/ {/*58*/
/*59*/
}/*60*/
}
@@ -90,12 +90,12 @@ void method2 ()
/* 🥳🥳🥳🥳 */ /* 🥳🥳🥳🥳🥳 */ { } // ok until #11410
}
- private void method() { // ok
+ private void method() {
String b = "🧐🧐🧐ccvb";
- if (b.equals("🧐🧐")) { // ok
+ if (b.equals("🧐🧐")) {
}
- if (b.equals("s🧐d🧐a")) { // ok
+ if (b.equals("s🧐d🧐a")) {
}
while (b == "😂🥳") { /* ok */ }
@@ -105,7 +105,7 @@ private void method() { // ok
interface check {
}
-/*15*/ class /*16*/InputAstTreeStringPrinterFullOfBlockComments /*49*/{/*17*/ // ok
+/*15*/ class /*16*/InputAstTreeStringPrinterFullOfBlockComments /*49*/{/*17*/
/*1*/public/*2*/ static/**/ String/*2*/ main/*2*/(/*4*/String/*2*/[/*2*/]/*2*/ args/*2*/)/**/ {
/*31*/String /*32*/line /*33*/= /*34*/"/*I'm NOT comment*/blabla"/*35*/;/*36*/
/*3*/String/*8*/.CASE_INSENSITIVE_ORDER/*0*/./*1*/equals/*2*/(/*3*/line/*4*/)/*4*/;/*6*/
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyCommentBeforeLeftCurly2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyCommentBeforeLeftCurly2.java
index f202b68f64a..34732c86454 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyCommentBeforeLeftCurly2.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyCommentBeforeLeftCurly2.java
@@ -29,9 +29,9 @@ void method1() /* comment
}
void method2() /********
- comment */ { // ok
+ comment */ {
if (!Arrays.equals(this.countList, countList)
- /* || !Arrays.equals(this.whereCreated, other.whereCreated) */ ) { // ok
+ /* || !Arrays.equals(this.whereCreated, other.whereCreated) */ ) {
}
}
@@ -39,7 +39,7 @@ void method3() /*****
********/ { } // ok until #11410
- InputLeftCurlyCommentBeforeLeftCurly2() /**************/ { } // ok
+ InputLeftCurlyCommentBeforeLeftCurly2() /**************/ { }
InputLeftCurlyCommentBeforeLeftCurly2(int data) /*
****** comment *********/ { } // ok until #11410
@@ -58,14 +58,14 @@ class Node /************/{
String s = "🧐 🧐";
private void foo3(String s) {
- /*🧐 🧐 🧐*/ /* comment */ if ("🧐".isEmpty()) { // ok
+ /*🧐 🧐 🧐*/ /* comment */ if ("🧐".isEmpty()) {
}
}
List> targets = List.of(
/* 0 */ (a) -> {Socket s = new Socket();},
// violation above ''{' at column 29 should have line break after'
- /* 0 */ (b) -> { // ok
+ /* 0 */ (b) -> {
Socket s = new Socket();
}
);
@@ -75,11 +75,11 @@ class Nothing {
void method() {
int a = 9;int b = 9;
if(a == 0 && b == 0
- /* || a==3 */) {} //ok
+ /* || a==3 */) {}
}
public void test2(String
- /* CHECKSTYLE */ ...para) { // ok
+ /* CHECKSTYLE */ ...para) {
}
public void test3(String line) {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyDefaultTestNl.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyDefaultTestNl.java
index 5ee31848794..8b0ac9842cc 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyDefaultTestNl.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyDefaultTestNl.java
@@ -14,21 +14,21 @@
package com.puppycrawl.tools.checkstyle.checks.blocks.leftcurly;
public class InputLeftCurlyDefaultTestNl
-{ // ok
+{
private interface PrivateInterface
- { // ok
+ {
}
interface PackageInnerInterface
- { // ok
+ {
}
protected interface ProtectedInnerInterface
- { // ok
+ {
}
public interface PublicInnerInterface
- { // ok
+ {
}
private
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyDefaultTestNlow.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyDefaultTestNlow.java
index e94b087ea40..60315a9675e 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyDefaultTestNlow.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyDefaultTestNlow.java
@@ -64,9 +64,9 @@ public interface PublicInnerInterface
class MyClass3 { // violation ''{' at column 20 should be on a new line'
}
- public class MyClass4 { // ok
- void method() { // ok
- while(true) {/*foo*/} // ok
+ public class MyClass4 {
+ void method() {
+ while(true) {/*foo*/}
}
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyIgnoreEnumsOptTrue.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyIgnoreEnumsOptTrue.java
index 54387a97900..3a06667ff39 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyIgnoreEnumsOptTrue.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyIgnoreEnumsOptTrue.java
@@ -14,7 +14,7 @@
package com.puppycrawl.tools.checkstyle.checks.blocks.leftcurly;
public class InputLeftCurlyIgnoreEnumsOptTrue {
- enum Colors {RED, // ok
+ enum Colors {RED,
BLUE,
GREEN;
// violation below ''{' at column 44 should have line break after'
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyMethod.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyMethod.java
index 889bf0e7358..efdc1ae29a3 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyMethod.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyMethod.java
@@ -16,14 +16,14 @@
class InputLeftCurlyMethod
{ // violation ''{' at column 1 should be on the previous line'
InputLeftCurlyMethod() {}
- InputLeftCurlyMethod(String aOne) { // ok
+ InputLeftCurlyMethod(String aOne) {
}
InputLeftCurlyMethod(int aOne)
{ // violation ''{' at column 5 should be on the previous line'
}
void method1() {}
- void method2() { // ok
+ void method2() {
}
void method3()
{ // violation ''{' at column 5 should be on the previous line'
@@ -36,7 +36,7 @@ void method5(String aOne,
{ // violation ''{' at column 5 should be on the previous line'
}
void method6(String aOne,
- String aTwo) { // ok
+ String aTwo) {
}
}
@@ -45,7 +45,7 @@ enum InputLeftCurlyMethodEnum
CONSTANT1("hello")
{ // violation ''{' at column 5 should be on the previous line'
void method1() {}
- void method2() { // ok
+ void method2() {
}
void method3()
{ // violation ''{' at column 9 should be on the previous line'
@@ -58,11 +58,11 @@ void method5(String aOne,
{ // violation ''{' at column 9 should be on the previous line'
}
void method6(String aOne,
- String aTwo) { // ok
+ String aTwo) {
}
},
- CONSTANT2("hello") { // ok
+ CONSTANT2("hello") {
},
@@ -76,7 +76,7 @@ private InputLeftCurlyMethodEnum(String value)
}
void method1() {}
- void method2() { // ok
+ void method2() {
}
void method3()
{ // violation ''{' at column 5 should be on the previous line'
@@ -89,7 +89,7 @@ void method5(String aOne,
{ // violation ''{' at column 5 should be on the previous line'
}
void method6(String aOne,
- String aTwo) { // ok
+ String aTwo) {
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyMethodTestNewLine2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyMethodTestNewLine2.java
index 0d8142e8ac0..7e26fc323b1 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyMethodTestNewLine2.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyMethodTestNewLine2.java
@@ -14,26 +14,26 @@
package com.puppycrawl.tools.checkstyle.checks.blocks.leftcurly;
class InputLeftCurlyMethodTestNewLine2
-{ // ok
+{
void InputLeftCurlyMethod() {}
void InputLeftCurlyMethod(String aOne) { // violation ''{' at column 44 should be on a new line'
}
void InputLeftCurlyMethod(int aOne)
- { // ok
+ {
}
void method1() {}
void method2() { // violation ''{' at column 20 should be on a new line'
}
void method3()
- { // ok
+ {
}
void method4()
- { // ok
+ {
}
void method5(String aOne,
String aTwo)
- { // ok
+ {
}
void method6(String aOne,
String aTwo) { // violation ''{' at column 31 should be on a new line'
@@ -41,21 +41,21 @@ void method6(String aOne,
}
enum InputLeftCurlyMethodEnumTestNewLine2
-{ // ok
+{
CONSTANT1()
- { // ok
+ {
void method1() {}
void method2() { // violation ''{' at column 24 should be on a new line'
}
void method3()
- { // ok
+ {
}
void method4()
- { // ok
+ {
}
void method5(String aOne,
String aTwo)
- { // ok
+ {
}
void method6(String aOne,
String aTwo) { // violation ''{' at column 35 should be on a new line'
@@ -67,11 +67,11 @@ void method6(String aOne,
},
CONSTANT3()
- { // ok
+ {
};
private void InputLeftCurlyMethodEnum(String value)
- { // ok
+ {
}
@@ -79,14 +79,14 @@ void method1() {}
void method2() { // violation ''{' at column 20 should be on a new line'
}
void method3()
- { // ok
+ {
}
void method4()
- { // ok
+ {
}
void method5(String aOne,
String aTwo)
- { // ok
+ {
}
void method6(String aOne,
String aTwo) { // violation ''{' at column 31 should be on a new line'
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefault.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefault.java
index 76ae4136b2b..75485381e3e 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefault.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefault.java
@@ -33,40 +33,40 @@ public interface PublicInnerInterface
private
class
- MyClass1 { // ok
+ MyClass1 {
}
class
- MyClass2 { // ok
+ MyClass2 {
}
private
interface
- MyInterface1 { // ok
+ MyInterface1 {
}
interface
- MyInterface2 { // ok
+ MyInterface2 {
}
protected
enum
- MyEnum { // ok
+ MyEnum {
}
private
@interface
- MyAnnotation { // ok
+ MyAnnotation {
}
@Deprecated
public
- class MyClass3 { // ok
+ class MyClass3 {
}
- public class MyClass4 { // ok
- void method() { // ok
- while(true) {/*foo*/} // ok
+ public class MyClass4 {
+ void method() {
+ while(true) {/*foo*/}
}
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefault3.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefault3.java
index df4ab6c6c7e..d59c1d6fa9a 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefault3.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefault3.java
@@ -28,7 +28,7 @@ int foo() throws InterruptedException
{ // violation ''{' at column 17 should be on the previous line'
break;
}
- else if (x < 0) { // ok
+ else if (x < 0) {
;
}
else
@@ -93,7 +93,7 @@ public enum GreetingsEnum
void method2()
{ // violation ''{' at column 5 should be on the previous line'
boolean flag = true;
- if (flag) { // ok
+ if (flag) {
System.identityHashCode("heh");
flag = !flag; } String.CASE_INSENSITIVE_ORDER.
equals("Xe-xe");
@@ -144,7 +144,7 @@ public void fooInnerMethod ()
* False positive
*
*/
-class Absent_CustomFieldSerializer3 { // ok
+class Absent_CustomFieldSerializer3 {
public static void serialize() {} // Expected nothing but was "'}' should be alone on a line."
}
@@ -160,14 +160,14 @@ interface EmptyInterface3 {}
class ClassWithStaticInitializers
{ // violation ''{' at column 1 should be on the previous line'
- static { // ok
+ static {
}
static
{}
static class Inner
{ // violation ''{' at column 5 should be on the previous line'
- static { // ok
+ static {
int i = 1;
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefaultLambda.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefaultLambda.java
index 822ae535611..f8da92ccccd 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefaultLambda.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefaultLambda.java
@@ -15,7 +15,7 @@
public class InputLeftCurlyTestDefaultLambda
{ // violation ''{' at column 1 should be on the previous line'
- static Runnable r1 = () -> { // ok
+ static Runnable r1 = () -> {
String.valueOf("Hello world one!");
};
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefaultWithAnnotations.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefaultWithAnnotations.java
index 8378cf7ec6d..1eede4ea3c6 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefaultWithAnnotations.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestDefaultWithAnnotations.java
@@ -45,16 +45,16 @@ public int hashCode()
}
@TestClassAnnotation
-class InputLeftCurlyAnnotations2 { // ok
+ class InputLeftCurlyAnnotations2 {
private static final int X = 10;
@Override
- public boolean equals(Object other) { // ok
+ public boolean equals(Object other) {
return false;
}
@Override
@SuppressWarnings("unused")
- public int hashCode() { // ok
+ public int hashCode() {
int a = 10;
return 1;
}
@@ -76,5 +76,5 @@ public int hashCode() { // ok
}
@Target(ElementType.TYPE)
-@interface TestClassAnnotation { // ok
+@interface TestClassAnnotation {
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestFirstLine.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestFirstLine.java
index 4e665a90964..eb220b4f566 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestFirstLine.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestFirstLine.java
@@ -18,6 +18,6 @@
import java.util.ArrayList;
import java.util.List;
-class InputLeftCurlyTestFirstLine { // ok
+class InputLeftCurlyTestFirstLine {
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestInvalidOption.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestInvalidOption.java
index c1e72c4cc8e..a60c8ecf1d5 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestInvalidOption.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestInvalidOption.java
@@ -14,59 +14,59 @@
package com.puppycrawl.tools.checkstyle.checks.blocks.leftcurly;
public class InputLeftCurlyTestInvalidOption
-{ // ok
+{
private interface PrivateInterface
- { // ok
+ {
}
interface PackageInnerInterface
- { // ok
+ {
}
protected interface ProtectedInnerInterface
- { // ok
+ {
}
public interface PublicInnerInterface
- { // ok
+ {
}
private
class
- MyClass1 { // ok
+ MyClass1 {
}
class
- MyClass2 { // ok
+ MyClass2 {
}
private
interface
- MyInterface1 { // ok
+ MyInterface1 {
}
interface
- MyInterface2 { // ok
+ MyInterface2 {
}
protected
enum
- MyEnum { // ok
+ MyEnum {
}
private
@interface
- MyAnnotation { // ok
+ MyAnnotation {
}
@Deprecated
public
- class MyClass3 { // ok
+ class MyClass3 {
}
- public class MyClass4 { // ok
- void method() { // ok
- while(true) {/*foo*/} // ok
+ public class MyClass4 {
+ void method() {
+ while(true) {/*foo*/}
}
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNewLine3.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNewLine3.java
index 1f4c75fa66d..0dc32bafc98 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNewLine3.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNewLine3.java
@@ -14,29 +14,29 @@
package com.puppycrawl.tools.checkstyle.checks.blocks.leftcurly;
class InputLeftCurlyTestNewLine3
-{ // ok
+{
/** @see test method **/
int foo() throws InterruptedException
- { // ok
+ {
int x = 1;
int a = 2;
while (true)
- { // ok
+ {
try
- { // ok
+ {
if (x > 0)
- { // ok
+ {
break;
}
else if (x < 0) { // violation ''{' at column 33 should be on a new line'
;
}
else
- { // ok
+ {
break;
}
switch (a)
- { // ok
+ {
case 0:
break;
default:
@@ -44,19 +44,19 @@ else if (x < 0) { // violation ''{' at column 33 should be on a new line'
}
}
catch (Exception e)
- { // ok
+ {
break;
}
finally
- { // ok
+ {
break;
}
}
synchronized (this)
- { // ok
+ {
do
- { // ok
+ {
x = 2;
} while (x == 2);
}
@@ -65,7 +65,7 @@ else if (x < 0) { // violation ''{' at column 33 should be on a new line'
); // Bizarre, but legal
for (int k = 0; k < 1; k++)
- { // ok
+ {
String innerBlockVariable = "";
}
@@ -78,20 +78,20 @@ else if (x < 0) { // violation ''{' at column 33 should be on a new line'
// Test static initialiser
static
- { // ok
+ {
int x = 1; // should not require any javadoc
}
public enum GreetingsEnum
- { // ok
+ {
HELLO,
GOODBYE
};
void method2()
- { // ok
+ {
boolean flag = true;
if (flag) { // violation ''{' at column 19 should be on a new line'
System.identityHashCode("heh");
@@ -108,10 +108,10 @@ void method2()
* a statement or the body of a constructor.
*/
class FooCtorTestNewLine3
-{ // ok
+{
int i;
public void FooCtor()
- { // ok
+ {
i = 1;
}}
@@ -120,9 +120,9 @@ public void FooCtor()
* a statement or the body of a method.
*/
class FooMethodTestNewLine3
-{ // ok
+{
public void fooMethod()
- { // ok
+ {
int i = 1;
}}
@@ -131,11 +131,11 @@ public void fooMethod()
* a statement or the body of a named class.
*/
class FooInnerTestNewLine3
-{ // ok
+{
class InnerFoo
- { // ok
+ {
public void fooInnerMethod ()
- { // ok
+ {
}
}}
@@ -150,7 +150,7 @@ public static void serialize() {} // Expected nothing but was "'}' should be alo
}
class Absent_CustomFieldSerializer4TestNewLine3
-{ // ok
+{
public void Absent_CustomFieldSerializer4() {}
}
@@ -159,14 +159,14 @@ class EmptyClass2TestNewLine3 {}
interface EmptyInterface3TestNewLine3 {}
class ClassWithStaticInitializersTestNewLine3
-{ // ok
+{
static { // violation ''{' at column 12 should be on a new line'
}
static
{}
static class Inner
- { // ok
+ {
static { // violation ''{' at column 16 should be on a new line'
int i = 1;
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNewLineOptionWithLambda.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNewLineOptionWithLambda.java
index b51ffe8b0ac..d06c0aa5f89 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNewLineOptionWithLambda.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNewLineOptionWithLambda.java
@@ -14,7 +14,7 @@
package com.puppycrawl.tools.checkstyle.checks.blocks.leftcurly;
public class InputLeftCurlyTestNewLineOptionWithLambda
-{ // ok
+{
static Runnable r1 = () -> { // violation ''{' at column 32 should be on a new line'
String.valueOf("Hello world one!");
};
@@ -24,7 +24,7 @@ public class InputLeftCurlyTestNewLineOptionWithLambda
static Runnable r3 = () -> {String.valueOf("ok");};
static Runnable r4 = () ->
- { // ok
+ {
String.valueOf("Hello world one!");
};
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNlWithAnnotations.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNlWithAnnotations.java
index 54ea01908fd..0b27808cd6a 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNlWithAnnotations.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNlWithAnnotations.java
@@ -20,24 +20,24 @@
@TestClassAnnotation
class InputLeftCurlyTestNlWithAnnotations
-{ // ok
+{
private static final int X = 10;
@Override
public boolean equals(Object other)
- { // ok
+ {
return false;
}
@Override
@SuppressWarnings("unused")
public int hashCode()
- { // ok
+ {
int a = 10;
return 1;
}
@Override @SuppressWarnings({"unused", "unchecked", "static-access"}) public String toString()
- { // ok
+ {
Integer i = this.X;
List l = new ArrayList();
return "SomeString";
@@ -60,7 +60,7 @@ public int hashCode() { // violation ''{' at column 27 should be on a new line'
}
@Override @SuppressWarnings({"unused", "unchecked", "static-access"}) public String toString()
- { // ok
+ {
Integer i = this.X;
List l = new ArrayList();
return "SomeString";
@@ -68,7 +68,7 @@ public int hashCode() { // violation ''{' at column 27 should be on a new line'
@Deprecated
@SuppressWarnings({"unused", "unchecked", "static-access"}) public String toString2()
- { // ok
+ {
Integer i = this.X;
List l = new ArrayList();
return "SomeString";
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNlowWithAnnotations.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNlowWithAnnotations.java
index 504f2d1db46..47dc9bca771 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNlowWithAnnotations.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyTestNlowWithAnnotations.java
@@ -45,16 +45,16 @@ public int hashCode()
}
@TestClassAnnotation
-class InputLeftCurlyAnnotations2TestNlowWithAnnotations { // ok
+class InputLeftCurlyAnnotations2TestNlowWithAnnotations {
private static final int X = 10;
@Override
- public boolean equals(Object other) { // ok
+ public boolean equals(Object other) {
return false;
}
@Override
@SuppressWarnings("unused")
- public int hashCode() { // ok
+ public int hashCode() {
int a = 10;
return 1;
}
@@ -76,5 +76,5 @@ public int hashCode() { // ok
}
@Target(ElementType.TYPE)
-@interface TestClassTestNlowWithAnnotation { // ok
+@interface TestClassTestNlowWithAnnotation {
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyWithEmoji.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyWithEmoji.java
index 6090fac20a3..9d59ab23e35 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyWithEmoji.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyWithEmoji.java
@@ -16,21 +16,21 @@
public class InputLeftCurlyWithEmoji {
static Runnable r1 = () -> {String.valueOf("🥳 🎄!");};
// violation above ''{' at column 32 should have line break after.'
- private void method() { // ok
+ private void method() {
String a = "🧐🧐🧐";
String b = "🧐🧐🧐ccvb";
- if (b.equals("🧐🧐")) { // ok
+ if (b.equals("🧐🧐")) {
}
- if (b.equals("s🧐d🧐a")) { // ok
+ if (b.equals("s🧐d🧐a")) {
}
while (b == "😂🥳") { /* ok */ }
}
- private void method2() { // ok
+ private void method2() {
String x = "🎄🤣";
try
@@ -39,7 +39,7 @@ private void method2() { // ok
{ // violation ''{' at column 13 should be on the previous line'
}
- else if (!x.equals("🎄🤣")) { // ok
+ else if (!x.equals("🎄🤣")) {
;
}
else
@@ -71,8 +71,8 @@ else if (!x.equals("🎄🤣")) { // ok
enum InputLeftCurlyMethodEnumWithEmoji
{ // violation ''{' at column 5 should be on the previous line'
CONSTANT1("🧐🧐dsds🧐") {
- void method1() {}//ok
- void method2() { //ok
+ void method1() {}
+ void method2() {
}
void method3()
{ // violation ''{' at column 13 should be on the previous line'
@@ -82,6 +82,6 @@ void method3()
}
};
- private InputLeftCurlyMethodEnumWithEmoji (String s) { // ok
+ private InputLeftCurlyMethodEnumWithEmoji (String s) {
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyWithEmojiNl.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyWithEmojiNl.java
index e66b8f677f3..05b585449e4 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyWithEmojiNl.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyWithEmojiNl.java
@@ -14,7 +14,7 @@
package com.puppycrawl.tools.checkstyle.checks.blocks.leftcurly;
public class InputLeftCurlyWithEmojiNl
-{ // OK
+{
static Runnable r1 = () -> {String.valueOf("🥳🎄!");};
// violation above ''{' at column 32 should be on a new line.'
private void method() { // violation ''{' at column 27 should be on a new line.'
@@ -35,24 +35,24 @@ private void method2() { // violation ''{' at column 28 should be on a new line.
String x = "🎄🤣";
try
- { // OK
+ {
if (x.equals("🎄🤣"))
- { // OK
+ {
}
else if (!x.equals("🎄🤣")) { // violation ''{' at column 39 should be on a new line.'
;
}
else
- { // OK
+ {
}
switch (x)
- { // OK
+ {
case "🤣🤣🤣":
break;
default:
- { // OK
+ {
break;
}
}
@@ -66,22 +66,22 @@ else if (!x.equals("🎄🤣")) { // violation ''{' at column 39 should be on a
}
}
catch (Exception e)
- { // OK
+ {
}
}
}
enum InputLeftCurlyMethodEnumWithEmojiNl
-{ // OK
+{
CONSTANT1("🧐🧐dsds🧐") { // violation ''{' at column 26 should be on a new line.'
String method1() { return "sds🧐"; } // violation ''{' at column 26 should be on a new line.'
void method2() { // violation ''{' at column 24 should be on a new line.'
}
String method3()
- { // OK
+ {
return "sds🧐";
}
boolean method4()
- { // OK
+ {
return "sds🧐".equals("🧐🧐dsds🧐");
}
};
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyWithTrimOptionProperty.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyWithTrimOptionProperty.java
index 883215d321b..c60a5752408 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyWithTrimOptionProperty.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/InputLeftCurlyWithTrimOptionProperty.java
@@ -16,7 +16,7 @@ public class InputLeftCurlyWithTrimOptionProperty {
{}
static class Inner
- { // ok
+ {
static { // violation ''{' at column 16 should be on a new line'
int i = 1;
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesEmptySingleLineDefaultStmt.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesEmptySingleLineDefaultStmt.java
index dc311173628..5f4ff2be38d 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesEmptySingleLineDefaultStmt.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesEmptySingleLineDefaultStmt.java
@@ -24,7 +24,7 @@ private void main1() {
}
@interface ExampleEmptySingleLineDefaultStmt {
- String priority() default "value"; // ok
+ String priority() default "value";
}
interface IntefaceWithDefaultMethodEmptySingleLineDefaultStmt {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesLoopBodyTrue.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesLoopBodyTrue.java
index e81dbecdb36..43cf98d10b4 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesLoopBodyTrue.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesLoopBodyTrue.java
@@ -16,64 +16,64 @@ public class InputNeedBracesLoopBodyTrue {
{
value = 0;
- while(incrementValue() < 5);; // ok
+ while(incrementValue() < 5);;
}
public void foo() {
- while(incrementValue() < 5); // ok
+ while(incrementValue() < 5);
}
public void foo2() {
- for(int i = 0; i < 10; incrementValue()); // ok
- for(int i = 0; incrementValue() < 8; i++); // ok
+ for(int i = 0; i < 10; incrementValue());
+ for(int i = 0; incrementValue() < 8; i++);
}
public void foo3() {
- while(incrementValue() // ok
+ while(incrementValue()
< 5);
}
public void foo4() {
- while(incrementValue() < 5) // ok
+ while(incrementValue() < 5)
;
}
public void foo5() {
- while(incrementValue() // ok
+ while(incrementValue()
< 5)
;
}
public void foo6() {
- while( // ok
+ while(
incrementValue() < 5
);
}
public void foo7() {
- while( // ok
+ while(
incrementValue() < 5);
}
public void foo8() {
- for(int i = 0; incrementValue() < 8; i++); // ok
+ for(int i = 0; incrementValue() < 8; i++);
}
public void foo9() {
- for(int i = 0; // ok
+ for(int i = 0;
incrementValue() < 8;
i++);
}
public void foo10() {
- for( // ok
+ for(
int i = 0;
incrementValue() < 8;
i++);
}
public void foo11() {
- for // ok
+ for
(
int i = 0;
incrementValue() < 8;
@@ -95,11 +95,11 @@ public void foo14() {
}
public void foo15() {
- while (true); // ok
+ while (true);
}
public void foo16() {
- for (;;); // ok
+ for (;;);
}
public void foo17() {
@@ -114,7 +114,7 @@ public void foo18() {
@Override
public String toString(){
- while(fco.removeAssignedRole(this)); // ok
+ while(fco.removeAssignedRole(this));
return "";
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesSingleLineStatements.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesSingleLineStatements.java
index b95ba4c6a19..4dedccd5ef9 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesSingleLineStatements.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesSingleLineStatements.java
@@ -78,10 +78,10 @@ private int getSmth(int num)
int counter = 0;
switch (num) {
case 1: counter++; break;
- case 2: // ok
+ case 2:
counter += 2;
break;
- case 3: // ok
+ case 3:
counter += 3;
break;
case 6: counter += 10; break;
@@ -128,9 +128,9 @@ private void forEachLoop() {
private void method(){
if(false) {
switch (0) {
- case -1: // ok
+ case -1:
return;
- default: // ok
+ default:
return;
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestCycles.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestCycles.java
index 75b9cf8ef95..1f8cc9775c7 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestCycles.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestCycles.java
@@ -47,10 +47,10 @@ public void method() {
case 3: {
break;}
- case 4: // ok
+ case 4:
break;
- case 5: System.lineSeparator(); // ok
+ case 5: System.lineSeparator();
break;
}
@@ -62,7 +62,7 @@ public void method() {
}
switch(1) {
- default: // ok
+ default:
break;
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestItWithAllowsOn.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestItWithAllowsOn.java
index 41d26b95f2c..0661fd7eb62 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestItWithAllowsOn.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestItWithAllowsOn.java
@@ -28,7 +28,7 @@ void testDoWhile()
while (condition());
// Invalid
- do testDoWhile(); while (condition()); // ok
+ do testDoWhile(); while (condition());
}
/** Test while loops **/
@@ -40,10 +40,10 @@ void testWhile()
}
// Invalid
- while(condition()); // ok
+ while(condition());
while (condition()) // violation
testWhile();
- while (condition()) // ok
+ while (condition())
if (condition()) // violation
testWhile();
}
@@ -57,7 +57,7 @@ void testFor()
}
// Invalid
- for(int i = 1;i < 5;i++); // ok
+ for(int i = 1;i < 5;i++);
for (int i = 1; i < 5; i++) // violation
testFor();
for (int i = 1; i < 5; // violation
@@ -81,7 +81,7 @@ else if (condition()) {
}
// Invalid
- if (condition()); // ok
+ if (condition());
if (condition()) // violation
testIf();
if (condition()) // violation
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestSingleLineCaseDefault.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestSingleLineCaseDefault.java
index 6a64b36e73e..f554c6a54cf 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestSingleLineCaseDefault.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestSingleLineCaseDefault.java
@@ -29,13 +29,13 @@ private int foo1() {
}
private int foo2() {
- if (SomeClass.test(true) == true) // ok
+ if (SomeClass.test(true) == true)
return 4;
return 0;
}
private int foo3() {
- if (SomeClass.test(true) == true) if (true) return 4; // ok
+ if (SomeClass.test(true) == true) if (true) return 4;
return 0;
}
@@ -44,7 +44,7 @@ private void foo(Object o) {
}
private void foo2(Object o) {
- if (o != null) // ok
+ if (o != null)
this.notify();
}
@@ -52,23 +52,23 @@ private void loopTest(Object o) {
while (o != null) {
this.notify();
}
- while (o != null) // ok
+ while (o != null)
this.notify();
while (o != null) this.notify();
do {
this.notify();
} while (o != null);
do this.notify(); while (o != null);
- do // ok
+ do
this.notify();
while (o != null);
- for (;;) // ok
+ for (;;)
break;
for (;;) break;
for (int i = 0; i < 10; i++) {
this.notify();
}
- for (int i = 0; i < 10; i++) // ok
+ for (int i = 0; i < 10; i++)
this.notify();
for (int i = 0; ; ) this.notify();
}
@@ -97,11 +97,11 @@ private void testElse(int k) {
}
private int testMissingWarnings() {
- if (true) // ok
+ if (true)
throw new RuntimeException();
if (true) {
return 1;
- } else // ok
+ } else
return 2;
}
@@ -113,14 +113,14 @@ void enhancedForLoop(int[] array) {
private class StateInfo {
public boolean isInitial() {
- for (int locator: sourceLocators) if (locator != 0) return false; // ok
+ for (int locator: sourceLocators) if (locator != 0) return false;
return true;
}
}
private void forEachLoop() {
for (String s: new String[]{""}) break;
- for (String s: new String[]{""}) // ok
+ for (String s: new String[]{""})
break;
for (;;)
;
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestSingleLineCaseDefault2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestSingleLineCaseDefault2.java
index 046be46b4f9..84b0849270e 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestSingleLineCaseDefault2.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestSingleLineCaseDefault2.java
@@ -24,7 +24,7 @@ private void main1() {
}
@interface Example {
- String priority() default "value"; // ok
+ String priority() default "value";
}
interface IntefaceWithDefaultMethod {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestSingleLineLambda.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestSingleLineLambda.java
index ac979b20dfa..d812b67eb30 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestSingleLineLambda.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/needbraces/InputNeedBracesTestSingleLineLambda.java
@@ -11,8 +11,8 @@
public class InputNeedBracesTestSingleLineLambda {
- static Runnable r1 = ()->String.CASE_INSENSITIVE_ORDER.equals("Hello world one!"); // ok
- static Runnable r2 = () -> String.CASE_INSENSITIVE_ORDER.equals("Hello world two!"); // ok
+ static Runnable r1 = ()->String.CASE_INSENSITIVE_ORDER.equals("Hello world one!");
+ static Runnable r2 = () -> String.CASE_INSENSITIVE_ORDER.equals("Hello world two!");
static Runnable r3 = () -> // violation
String.CASE_INSENSITIVE_ORDER.equals("Hello world two!");
static Runnable r4 = () -> {String.CASE_INSENSITIVE_ORDER.equals("Hello world two!");};
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestAlone.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestAlone.java
index 89393095fcf..7fc531e6b02 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestAlone.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestAlone.java
@@ -84,7 +84,7 @@ public enum GreetingsEnum
{
HELLO,
GOODBYE
- }; // ok
+ };
void method2()
{
@@ -109,7 +109,7 @@ class FooCtorTestAlone
public void FooCtor()
{
i = 1;
- }} // ok
+ }}
/**
* Test input for closing brace if that brace terminates
@@ -120,7 +120,7 @@ class FooMethodTestAlone
public void fooMethod()
{
int i = 1;
- }} // ok
+ }}
/**
* Test input for closing brace if that brace terminates
@@ -134,7 +134,7 @@ public void fooInnerMethod ()
{
}
- }} // ok
+ }}
/**
* False positive
@@ -142,17 +142,17 @@ public void fooInnerMethod ()
*/
class Absent_CustomFieldSerializer3TestAlone {
- public static void serialize() {} // ok
+ public static void serialize() {}
}
class Absent_CustomFieldSerializer4TestAlone
{
- public void Absent_CustomFieldSerializer4() {} // ok
+ public void Absent_CustomFieldSerializer4() {}
}
-class EmptyClass2TestAlone {} // ok
+class EmptyClass2TestAlone {}
-interface EmptyInterface3TestAlone {} // ok
+interface EmptyInterface3TestAlone {}
class ClassWithStaticInitializersTestAlone
{
@@ -196,19 +196,19 @@ public void codeAfterLastRightCurly() {
@Override
public Thread newThread(final Runnable r) {
return new Thread(r);
- }}; // ok
+ }};
interface Interface1
{
int i = 1;
- public void meth1(); } // ok
+ public void meth1(); }
interface Interface2
- { int i = 1; public void meth1(); } // ok
+ { int i = 1; public void meth1(); }
interface Interface3 {
void display();
interface Interface4 {
void myMethod();
- }} // ok
+ }}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestDefault.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestDefault.java
index ca8f2433fcd..6d1913e228e 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestDefault.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestDefault.java
@@ -53,7 +53,7 @@ else if (x < 0) {
do
{
x = 2;
- } while (x == 2); // ok
+ } while (x == 2);
}
this.wait(666
@@ -83,7 +83,7 @@ public enum GreetingsEnum
{
HELLO,
GOODBYE
- }; // ok
+ };
void method2()
{
@@ -94,7 +94,7 @@ void method2()
CASE_INSENSITIVE_ORDER.equals("Xe-xe");
// it is ok to have rcurly on the same line as previous
// statement if lcurly on the same line.
- if (flag) { String.CASE_INSENSITIVE_ORDER.equals("it is ok."); } // ok
+ if (flag) { String.CASE_INSENSITIVE_ORDER.equals("it is ok."); }
}
}
@@ -108,7 +108,7 @@ class FooCtor
public FooCtor()
{
i = 1;
- }} // ok
+ }}
/**
* Test input for closing brace if that brace terminates
@@ -119,7 +119,7 @@ class FooMethod
public void fooMethod()
{
int i = 1;
- }} // ok
+ }}
/**
* Test input for closing brace if that brace terminates
@@ -133,7 +133,7 @@ public void fooInnerMethod ()
{
}
- }} // ok
+ }}
/**
* False positive
@@ -141,17 +141,17 @@ public void fooInnerMethod ()
*/
class Absent_CustomFieldSerializer3 {
- public static void serialize() {} // ok
+ public static void serialize() {}
}
class Absent_CustomFieldSerializer4
{
- public Absent_CustomFieldSerializer4() {} // ok
+ public Absent_CustomFieldSerializer4() {}
}
-class EmptyClass2 {} // ok
+class EmptyClass2 {}
-interface EmptyInterface3 {} // ok
+interface EmptyInterface3 {}
class ClassWithStaticInitializers
{
@@ -170,23 +170,23 @@ static class Inner
public void emptyBlocks() {
try {
// comment
- } catch (RuntimeException e) { // ok
+ } catch (RuntimeException e) {
new Object();
- } catch (Exception e) { // ok
+ } catch (Exception e) {
// comment
- } catch (Throwable e) { // ok
- } finally { // ok
+ } catch (Throwable e) {
+ } finally {
// comment
}
do {
- } while (true); // ok
+ } while (true);
}
public void codeAfterLastRightCurly() {
while (new Object().equals(new Object())) {
- }; // ok
- for (int i = 0; i < 1; i++) { new Object(); }; // ok
+ };
+ for (int i = 0; i < 1; i++) { new Object(); };
}
static final java.util.concurrent.ThreadFactory threadFactory
@@ -194,19 +194,19 @@ public void codeAfterLastRightCurly() {
@Override
public Thread newThread(final Runnable r) {
return new Thread(r);
- }}; // ok
+ }};
interface Interface1
{
int i = 1;
- public void meth1(); } // ok
+ public void meth1(); }
interface Interface2
- { int i = 1; public void meth1(); } // ok
+ { int i = 1; public void meth1(); }
interface Interface3 {
void display();
interface Interface4 {
void myMethod();
- }} // ok
+ }}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestNewLine.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestNewLine.java
index b15e13a3174..d920fff2fac 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestNewLine.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestNewLine.java
@@ -22,10 +22,10 @@ int foo() throws InterruptedException
if (x > 0)
{
break;
- } // ok
+ }
else if (x < 0) {
;
- } // ok
+ }
else
{
break;
@@ -37,11 +37,11 @@ else if (x < 0) {
default:
break;
}
- } // ok
+ }
catch (Exception e)
{
break;
- } // ok
+ }
finally
{
break;
@@ -53,7 +53,7 @@ else if (x < 0) {
do
{
x = 2;
- } while (x == 2); // ok
+ } while (x == 2);
}
this.wait(666
@@ -90,11 +90,11 @@ void method2()
boolean flag = true;
if (flag) {
System.identityHashCode("heh");
- flag = !flag; } String.CASE_INSENSITIVE_ORDER. // ok
+ flag = !flag; } String.CASE_INSENSITIVE_ORDER.
equals("Xe-xe");
// it is ok to have rcurly on the same line as previous
// statement if lcurly on the same line.
- if (flag) { String.CASE_INSENSITIVE_ORDER.equals("it is ok."); } // ok
+ if (flag) { String.CASE_INSENSITIVE_ORDER.equals("it is ok."); }
}
}
@@ -170,23 +170,23 @@ static class Inner
public void emptyBlocks() {
try {
// comment
- } catch (RuntimeException e) { // ok
+ } catch (RuntimeException e) {
new Object();
- } catch (Exception e) { // ok
+ } catch (Exception e) {
// comment
- } catch (Throwable e) { // ok
- } finally { // ok
+ } catch (Throwable e) {
+ } finally {
// comment
}
do {
- } while (true); // ok
+ } while (true);
}
public void codeAfterLastRightCurly() {
while (new Object().equals(new Object())) {
- }; // ok
- for (int i = 0; i < 1; i++) { new Object(); }; // ok
+ };
+ for (int i = 0; i < 1; i++) { new Object(); };
}
static final java.util.concurrent.ThreadFactory threadFactory
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestSame.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestSame.java
index 403715a75ed..1a07243b81f 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestSame.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestSame.java
@@ -54,7 +54,7 @@ else if (x < 0) {
do
{
x = 2;
- } while (x == 2); // ok
+ } while (x == 2);
}
this.wait(666
@@ -95,7 +95,7 @@ void method2()
CASE_INSENSITIVE_ORDER.equals("Xe-xe");
// it is ok to have rcurly on the same line as previous
// statement if lcurly on the same line.
- if (flag) { String.CASE_INSENSITIVE_ORDER.equals("it is ok."); } // ok
+ if (flag) { String.CASE_INSENSITIVE_ORDER.equals("it is ok."); }
}
}
@@ -109,7 +109,7 @@ class FooCtorTestSame
public void FooCtor()
{
i = 1;
- }} // ok
+ }}
/**
* Test input for closing brace if that brace terminates
@@ -120,7 +120,7 @@ class FooMethodTestSame
public void fooMethod()
{
int i = 1;
- }} // ok
+ }}
/**
* Test input for closing brace if that brace terminates
@@ -134,7 +134,7 @@ public void fooInnerMethod ()
{
}
- }} // ok
+ }}
/**
* False positive
@@ -142,17 +142,17 @@ public void fooInnerMethod ()
*/
class Absent_CustomFieldSerializer3TestSame {
- public static void serialize() {} // ok
+ public static void serialize() {}
}
class Absent_CustomFieldSerializer4TestSame
{
- public void Absent_CustomFieldSerializer4() {} // ok
+ public void Absent_CustomFieldSerializer4() {}
}
-class EmptyClass2TestSame {} // ok
+class EmptyClass2TestSame {}
-interface EmptyInterface3TestSame {} // ok
+interface EmptyInterface3TestSame {}
class ClassWithStaticInitializersTestSame
{
@@ -171,17 +171,17 @@ static class Inner
public void emptyBlocks() {
try {
// comment
- } catch (RuntimeException e) { // ok
+ } catch (RuntimeException e) {
new Object();
- } catch (Exception e) { // ok
+ } catch (Exception e) {
// comment
- } catch (Throwable e) { // ok
- } finally { // ok
+ } catch (Throwable e) {
+ } finally {
// comment
}
do {
- } while (true); // ok
+ } while (true);
}
public void codeAfterLastRightCurly() {
@@ -195,19 +195,19 @@ public void codeAfterLastRightCurly() {
@Override
public Thread newThread(final Runnable r) {
return new Thread(r);
- }}; // ok
+ }};
interface Interface1
{
int i = 1;
- public void meth1(); } // ok
+ public void meth1(); }
interface Interface2
- { int i = 1; public void meth1(); } // ok
+ { int i = 1; public void meth1(); }
interface Interface3 {
void display();
interface Interface4 {
void myMethod();
- }} // ok
+ }}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestShouldStartLine2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestShouldStartLine2.java
index 0dd17538815..61cd340a9ab 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestShouldStartLine2.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyLeftTestShouldStartLine2.java
@@ -22,10 +22,10 @@ int foo() throws InterruptedException
if (x > 0)
{
break;
- } // ok
+ }
else if (x < 0) {
;
- } // ok
+ }
else
{
break;
@@ -37,11 +37,11 @@ else if (x < 0) {
default:
break;
}
- } // ok
+ }
catch (Exception e)
{
break;
- } // ok
+ }
finally
{
break;
@@ -53,7 +53,7 @@ else if (x < 0) {
do
{
x = 2;
- } while (x == 2); // ok
+ } while (x == 2);
}
this.wait(666
@@ -90,11 +90,11 @@ void method2()
boolean flag = true;
if (flag) {
System.identityHashCode("heh");
- flag = !flag; } String.CASE_INSENSITIVE_ORDER. // ok
+ flag = !flag; } String.CASE_INSENSITIVE_ORDER.
equals("Xe-xe");
// it is ok to have rcurly on the same line as previous
// statement if lcurly on the same line.
- if (flag) { String.CASE_INSENSITIVE_ORDER.equals("it is ok."); } // ok
+ if (flag) { String.CASE_INSENSITIVE_ORDER.equals("it is ok."); }
}
}
@@ -141,17 +141,17 @@ public void fooInnerMethod ()
*/
class Absent_CustomFieldSerializer3TestShouldStartLine2 {
- public static void serialize() {} // ok
+ public static void serialize() {}
}
class Absent_CustomFieldSerializer4TestShouldStartLine2
{
- public void Absent_CustomFieldSerializer4() {} // ok
+ public void Absent_CustomFieldSerializer4() {}
}
-class EmptyClass2TestShouldStartLine2 {} // ok
+class EmptyClass2TestShouldStartLine2 {}
-interface EmptyInterface3TestShouldStartLine2 {} // ok
+interface EmptyInterface3TestShouldStartLine2 {}
class ClassWithStaticInitializersTestShouldStartLine2
{
@@ -170,23 +170,23 @@ static class Inner
public void emptyBlocks() {
try {
// comment
- } catch (RuntimeException e) { // ok
+ } catch (RuntimeException e) {
new Object();
- } catch (Exception e) { // ok
+ } catch (Exception e) {
// comment
- } catch (Throwable e) { // ok
- } finally { // ok
+ } catch (Throwable e) {
+ } finally {
// comment
}
do {
- } while (true); // ok
+ } while (true);
}
public void codeAfterLastRightCurly() {
while (new Object().equals(new Object())) {
- }; // ok
- for (int i = 0; i < 1; i++) { new Object(); }; // ok
+ };
+ for (int i = 0; i < 1; i++) { new Object(); };
}
static final java.util.concurrent.ThreadFactory threadFactory
@@ -202,7 +202,7 @@ interface Interface1
public void meth1(); } // violation ''}' at column 30 should be alone on a line'
interface Interface2
- { int i = 1; public void meth1(); } // ok
+ { int i = 1; public void meth1(); }
interface Interface3 {
void display();
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyNewTokensAloneOrSingleLine.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyNewTokensAloneOrSingleLine.java
index e0cd9370a0c..2a3baa0ca07 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyNewTokensAloneOrSingleLine.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyNewTokensAloneOrSingleLine.java
@@ -10,12 +10,12 @@
public class InputRightCurlyNewTokensAloneOrSingleLine {
- enum TestEnum{} // ok
+ enum TestEnum{}
enum TestEnum1{
SOME_VALUE;} // violation ''}' at column 20 should be alone on a line'
- enum TestEnum2 { SOME_VALUE; } // ok
+ enum TestEnum2 { SOME_VALUE; }
enum TestEnum3{
SOME_VALUE;
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestEmptyOnSingleLine.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestEmptyOnSingleLine.java
index 4989b529f6d..78cf675815c 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestEmptyOnSingleLine.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestEmptyOnSingleLine.java
@@ -9,4 +9,4 @@
package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly;
-public class InputRightCurlyTestEmptyOnSingleLine {} // ok
+public class InputRightCurlyTestEmptyOnSingleLine {}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestForceLineBreakBefore2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestForceLineBreakBefore2.java
index 8c423d7f12d..eaa204750ba 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestForceLineBreakBefore2.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestForceLineBreakBefore2.java
@@ -35,19 +35,19 @@ int foo() throws InterruptedException
} catch (Exception e) { break; } finally { break; }
}
- synchronized (this) { do { x = 2; } while (x == 2); } // ok
+ synchronized (this) { do { x = 2; } while (x == 2); }
synchronized (this) {
- do {} while (x == 2); // ok
+ do {} while (x == 2);
}
- for (int k = 0; k < 1; k++) { String innerBlockVariable = ""; } // ok
+ for (int k = 0; k < 1; k++) { String innerBlockVariable = ""; }
- for (int k = 0; k < 1; k++) {} // ok
+ for (int k = 0; k < 1; k++) {}
return a;
}
- static { int x = 1; } // ok
+ static { int x = 1; }
void method2()
{
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestInvalidOption.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestInvalidOption.java
index c2fce344378..f34edd56548 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestInvalidOption.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestInvalidOption.java
@@ -16,7 +16,7 @@ void foo() throws InterruptedException
try
{
- } // ok
+ }
catch (Exception e)
{
return;
@@ -26,4 +26,4 @@ void foo() throws InterruptedException
}
-class UniqEmptyClassTestInvalidOption {private int a;} // ok
+class UniqEmptyClassTestInvalidOption {private int a;}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestIsAloneLambda.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestIsAloneLambda.java
index 205c345001d..e16d82feae3 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestIsAloneLambda.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestIsAloneLambda.java
@@ -19,10 +19,10 @@ public class InputRightCurlyTestIsAloneLambda {
static Runnable r2 = () -> String.valueOf("Test rightCurly two!");
- static Runnable r3 = () -> {String.valueOf("Test rightCurly three!");}; // ok
+ static Runnable r3 = () -> {String.valueOf("Test rightCurly three!");};
static Runnable r4 = () -> {
- String.valueOf("Test rightCurly four!");}; // ok
+ String.valueOf("Test rightCurly four!");};
static Runnable r5 = () ->
{
@@ -40,7 +40,7 @@ public class InputRightCurlyTestIsAloneLambda {
static Runnable r9 = () -> {
String.valueOf("Test rightCurly nine!");
- }; int i; // ok
+ }; int i;
void foo1() {
Stream.of("Hello").filter(s -> {
@@ -50,6 +50,6 @@ void foo1() {
Stream.of("Hello").filter(s -> {
return s != null;
- }).collect(Collectors.toList()); // ok
+ }).collect(Collectors.toList());
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestIsAloneOrSinglelineLambda.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestIsAloneOrSinglelineLambda.java
index d0007d24962..431838f844a 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestIsAloneOrSinglelineLambda.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestIsAloneOrSinglelineLambda.java
@@ -22,7 +22,7 @@ public class InputRightCurlyTestIsAloneOrSinglelineLambda {
static Runnable r3 = () -> {String.valueOf("Test rightCurly three!");};
static Runnable r4 = () -> {
- String.valueOf("Test rightCurly four!");}; // ok
+ String.valueOf("Test rightCurly four!");};
static Runnable r5 = () ->
{
@@ -40,7 +40,7 @@ public class InputRightCurlyTestIsAloneOrSinglelineLambda {
static Runnable r9 = () -> {
String.valueOf("Test rightCurly nine!");
- }; int i; // ok
+ }; int i;
void foo1() {
Stream.of("Hello").filter(s -> {
@@ -50,8 +50,8 @@ void foo1() {
Stream.of("Hello").filter(s -> {
return s != null;
- }).collect(Collectors.toList()); // ok
+ }).collect(Collectors.toList());
- Stream.of("H").filter(s -> {return s != null;}).collect(Collectors.toList()); // ok
+ Stream.of("H").filter(s -> {return s != null;}).collect(Collectors.toList());
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestIsSameLambda.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestIsSameLambda.java
index 68c46c83bd5..f4e91ace0a2 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestIsSameLambda.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestIsSameLambda.java
@@ -22,7 +22,7 @@ public class InputRightCurlyTestIsSameLambda {
static Runnable r3 = () -> {String.valueOf("Test rightCurly three!");};
static Runnable r4 = () -> {
- String.valueOf("Test rightCurly four!");}; // ok
+ String.valueOf("Test rightCurly four!");};
static Runnable r5 = () ->
{
@@ -40,12 +40,12 @@ public class InputRightCurlyTestIsSameLambda {
static Runnable r9 = () -> {
String.valueOf("Test rightCurly nine!");
- }; int i; // ok
+ }; int i;
void foo1() {
Stream.of("Hello").filter(s -> {
return s != null;
- } // ok
+ }
).collect(Collectors.toList());
Stream.of("Hello").filter(s -> {
@@ -58,7 +58,7 @@ void foo1() {
Stream.of("Hello").filter(s -> {return s != null;}).collect(Collectors.toList());
Stream.of("Hello").filter(s -> {
- return s != null;}).collect(Collectors.toList()); // ok
+ return s != null;}).collect(Collectors.toList());
bar(() -> {return;}, () -> {return;});
@@ -73,12 +73,12 @@ void foo1() {
});
bar(() -> {
- return;}, () -> {return;}); // ok
+ return;}, () -> {return;});
bar(() -> {
return;
}, () -> {
- return;}); // ok
+ return;});
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestNullPointerException.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestNullPointerException.java
index aa083b9941b..dcd82676f33 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestNullPointerException.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestNullPointerException.java
@@ -16,4 +16,4 @@ abstract class InputRightCurlyTestNullPointerException {
void foo() {
while (true);
}
-} // ok
+}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptAloneOrSingleLineBlocksWithSemi.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptAloneOrSingleLineBlocksWithSemi.java
index 8a2a3df155e..bdcea95c833 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptAloneOrSingleLineBlocksWithSemi.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptAloneOrSingleLineBlocksWithSemi.java
@@ -10,18 +10,18 @@
public class InputRightCurlyTestOptAloneOrSingleLineBlocksWithSemi {
- public void testMethod() {}; // ok
+ public void testMethod() {};
public void testMethod1() {
}; // violation ''}' at column 5 should be alone on a line'
- public class TestClass {}; // ok
+ public class TestClass {};
public class TestClass1 {
}; // violation ''}' at column 5 should be alone on a line'
public class TestClass2 {
- public TestClass2() {}; // ok
+ public TestClass2() {};
public TestClass2(String someValue) {
}; // violation ''}' at column 9 should be alone on a line'
@@ -34,7 +34,7 @@ public void testMethod11() {
public @interface TestAnnnotation5 {
String someValue(); }; // violation ''}' at column 29 should be alone on a line'
- public @interface TestAnnotation6 {}; // ok
+ public @interface TestAnnotation6 {};
public @interface TestAnnotation7 {
String someValue();
@@ -43,14 +43,14 @@ public void testMethod11() {
public @interface TestAnnotation8 { String someValue();
}; // violation ''}' at column 5 should be alone on a line'
- public @interface TestAnnotation9 { String someValue(); }; // ok
+ public @interface TestAnnotation9 { String someValue(); };
- enum TestEnum{}; // ok
+ enum TestEnum{};
enum TestEnum1{
SOME_VALUE;}; // violation ''}' at column 20 should be alone on a line'
- enum TestEnum2 { SOME_VALUE; }; // ok
+ enum TestEnum2 { SOME_VALUE; };
enum TestEnum3{
SOME_VALUE;
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptSameBlocksWithSemi.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptSameBlocksWithSemi.java
index a129356a609..6f532cdfc1a 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptSameBlocksWithSemi.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptSameBlocksWithSemi.java
@@ -10,18 +10,18 @@
public class InputRightCurlyTestOptSameBlocksWithSemi {
- public void testMethod() {}; // ok
+ public void testMethod() {};
public void testMethod1() {
}; // violation ''}' at column 5 should be alone on a line'
- public class TestClass {}; // ok
+ public class TestClass {};
public class TestClass1 {
}; // violation ''}' at column 5 should be alone on a line'
public class TestClass2 {
- public TestClass2() {}; // ok
+ public TestClass2() {};
public TestClass2(String someValue) {
}; // violation ''}' at column 9 should be alone on a line'
@@ -34,7 +34,7 @@ public void testMethod11() {
public @interface TestAnnnotation5 {
String someValue(); }; // violation ''}' at column 29 should have line break before'
- public @interface TestAnnotation6 {}; // ok
+ public @interface TestAnnotation6 {};
public @interface TestAnnotation7 {
String someValue();
@@ -43,14 +43,14 @@ public void testMethod11() {
public @interface TestAnnotation8 { String someValue();
}; // violation ''}' at column 5 should be alone on a line'
- public @interface TestAnnotation9 { String someValue(); }; // ok
+ public @interface TestAnnotation9 { String someValue(); };
- enum TestEnum{}; // ok
+ enum TestEnum{};
enum TestEnum1{
SOME_VALUE;}; // violation ''}' at column 20 should have line break before'
- enum TestEnum2 { SOME_VALUE; }; // ok
+ enum TestEnum2 { SOME_VALUE; };
enum TestEnum3{
SOME_VALUE;
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptionAlone.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptionAlone.java
index c3cba245a68..ff8774faf76 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptionAlone.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptionAlone.java
@@ -35,7 +35,7 @@ void method2(java.util.HashSet set) {
put("first", "second");
put("polygene", "lubricants");
put("alpha", "betical");
- }}; // ok
+ }};
}
void method3() {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptionAloneOrSingleLine.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptionAloneOrSingleLine.java
index 236e6fb045f..5ce8b941355 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptionAloneOrSingleLine.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestOptionAloneOrSingleLine.java
@@ -13,8 +13,8 @@ public class InputRightCurlyTestOptionAloneOrSingleLine {
private int a;
private static int b;
- { a = 2; } // ok
- static { b = 3; } // ok
+ { a = 2; }
+ static { b = 3; }
void method1() {
Thread t = new Thread() {@Override public void run() {
@@ -51,15 +51,15 @@ int method4(int a) {
if (a>2) a*=10; return ++a; } // violation ''}' at column 37 should be alone on a line'
void method5(int a) {
- while (a > 5) { a--; } // ok
+ while (a > 5) { a--; }
- if (a > 4) { a++; } // ok
+ if (a > 4) { a++; }
- do {a--;} while (a > 3); // ok
+ do {a--;} while (a > 3);
- for (int i = 1; i < 10; i++) { byte b = 10; } // ok
+ for (int i = 1; i < 10; i++) { byte b = 10; }
- if (a < 2) { --a; } else if (a > 3) { a++; } // ok
+ if (a < 2) { --a; } else if (a > 3) { a++; }
java.util.List list = new java.util.ArrayList<>();
list.stream()
@@ -77,7 +77,7 @@ interface Interface1
public void meth1(); } // violation ''}' at column 30 should be alone on a line'
interface Interface2
- { int i = 1; public void meth1(); } // ok
+ { int i = 1; public void meth1(); }
interface Interface3 {
void display();
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSame.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSame.java
index cab68438e44..1c6928a159b 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSame.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSame.java
@@ -21,7 +21,7 @@ public InputRightCurlyTestSame() {
@Override
public void run() {
}
- }); // ok
+ });
}
public void doLoop() {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSameNewTokens.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSameNewTokens.java
index 6db8041619b..1691fc8bd3f 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSameNewTokens.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSameNewTokens.java
@@ -10,12 +10,12 @@
public class InputRightCurlyTestSameNewTokens {
- enum TestEnum{} // ok
+ enum TestEnum{}
enum TestEnum1{
SOME_VALUE;} // violation ''}' at column 20 should have line break before'
- enum TestEnum2 { SOME_VALUE; } // ok
+ enum TestEnum2 { SOME_VALUE; }
enum TestEnum3{
SOME_VALUE;
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSameOmitOneLiners.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSameOmitOneLiners.java
index f6460e85a58..dae5bfce327 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSameOmitOneLiners.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSameOmitOneLiners.java
@@ -16,6 +16,6 @@ public class InputRightCurlyTestSameOmitOneLiners {
public static void main(String[] args) {
boolean after = false;
try {
- } finally { after = true; } // ok
+ } finally { after = true; }
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSingleLineClass.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSingleLineClass.java
index 7851c524649..158732a570e 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSingleLineClass.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSingleLineClass.java
@@ -16,7 +16,7 @@ void foo() throws InterruptedException
try
{
- } // ok
+ }
catch (Exception e)
{
return;
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase.java
index 585f4f63a30..58c2430a421 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase.java
@@ -35,7 +35,7 @@ public static void method2() {
break;
default:
x = 0;
- } // ok
+ }
}
public static void method3() {
@@ -43,7 +43,7 @@ public static void method3() {
switch (mode) {
default :
int x = 0;
- } // ok
+ }
}
public static void method4() {
@@ -55,13 +55,13 @@ public static void method4() {
public static void method5() {
int mode = 0;
switch (mode) { default : int x = 0;
- } // ok
+ }
}
public static void method6() {
int mode = 0;
switch (mode) { case 0: int x = 1; break; default : x = 5;
- } // ok
+ }
}
public static void method7() {
@@ -79,13 +79,13 @@ public static void method8() {
public static void method9() {
int mode = 0;
switch (mode) { case 0: int x = 1; break; default : x = 5;
- } // ok
+ }
}
public static void method10() {
int mode = 0;
switch (mode) { case 0: int x = 1; break; case 80: x = 1; break;
- } // ok
+ }
}
public static void method11() {
@@ -115,6 +115,6 @@ public static void method12() {
}
switch (x) {}; // violation ''}' at column 21 should be alone on a line'
switch (x) {
- } // ok
+ }
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase2.java
index 9d332138035..534497db1f9 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase2.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase2.java
@@ -35,7 +35,7 @@ public static void method2() {
break;
default:
x = 0;
- } // ok
+ }
}
public static void method3() {
@@ -43,46 +43,46 @@ public static void method3() {
switch (mode) {
default :
int x = 0;
- } // ok
+ }
}
public static void method4() {
int mode = 0;
- switch (mode) { default : int x = 0; } // ok
+ switch (mode) { default : int x = 0; }
}
public static void method5() {
int mode = 0;
switch (mode) { default : int x = 0;
- } // ok
+ }
}
public static void method6() {
int mode = 0;
switch (mode) { case 0: int x = 1; break; default : x = 5;
- } // ok
+ }
}
public static void method7() {
int mode = 0;
- switch (mode) { case 0: int x = 1; break; default : x = 5; } // ok
+ switch (mode) { case 0: int x = 1; break; default : x = 5; }
}
public static void method8() {
int mode = 0;
- switch (mode) { case 0: int x = 1; break; case 80: x = 1; break; } // ok
+ switch (mode) { case 0: int x = 1; break; case 80: x = 1; break; }
}
public static void method9() {
int mode = 0;
switch (mode) { case 0: int x = 1; break; default : x = 5;
- } // ok
+ }
}
public static void method10() {
int mode = 0;
switch (mode) { case 0: int x = 1; break; case 80: x = 1; break;
- } // ok
+ }
}
public static void method11() {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase3.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase3.java
index 0c056eec3b7..3e92bab391c 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase3.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase3.java
@@ -19,7 +19,7 @@ public void method() {
case(1): x = 0; break; } // violation ''}' at column 36 should be alone on a line'
switch (x)
{
- } // ok
+ }
switch (x)
{case(1): x=1;break;
} int b; // violation ''}' at column 9 should be alone on a line'
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase4.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase4.java
index b3ccf2f5932..fd22508a003 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase4.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase4.java
@@ -12,21 +12,21 @@ public class InputRightCurlyTestSwitchCase4 {
public void method() {
int x = 0;
- switch (x) { } // ok
+ switch (x) { }
switch (x) {
} int a; // violation ''}' at column 9 should be alone on a line'
switch (x) {
case(1): x = 0; break; } // violation ''}' at column 36 should be alone on a line'
switch (x)
{
- } // ok
+ }
switch (x)
{case(1): x=1;break;
} int b; // violation ''}' at column 9 should be alone on a line'
switch (x) {case(2): break; } int c;
// violation above ''}' at column 37 should be alone on a line'
switch (x) { } int d; // violation ''}' at column 22 should be alone on a line'
- switch (x) { } // ok
+ switch (x) { }
}
public void someMethod2() {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase5.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase5.java
index 945376d5c3e..b42bf65bd58 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase5.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestSwitchCase5.java
@@ -12,21 +12,21 @@ public class InputRightCurlyTestSwitchCase5 {
public void method() {
int x = 0;
- switch (x) { } // ok
+ switch (x) { }
switch (x) {
} int a; // violation ''}' at column 9 should be alone on a line'
switch (x) {
case(1): x = 0; break; } // violation ''}' at column 36 should have line break before'
switch (x)
{
- } // ok
+ }
switch (x)
{case(1): x=1;break;
} int b; // violation ''}' at column 9 should be alone on a line'
switch (x) {case(2): break; } int c;
// violation above ''}' at column 37 should be alone on a line'
switch (x) { } int d; // violation ''}' at column 22 should be alone on a line'
- switch (x) { } // ok
+ switch (x) { }
}
public void someMethod2() {
@@ -46,18 +46,18 @@ public void someMethod3() {
class NoViolationOnInputRightCurlyTestSwitchCase5 {
public void method() {
int x = 0;
- switch (x) { } // ok
- switch (x) { default: } // ok
- switch (x) { case(1): x = 0; break; } // ok
+ switch (x) { }
+ switch (x) { default: }
+ switch (x) { case(1): x = 0; break; }
switch (x)
{
- } // ok
+ }
switch (x)
{case(1): x=1;break;
}
int b;
switch (x) {case(2): break; }
- switch (x) { } // ok
+ switch (x) { }
}
public void someMethod2() {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestTryWithResourceAlone.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestTryWithResourceAlone.java
index 5dee15cb524..aab7e3399bd 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestTryWithResourceAlone.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestTryWithResourceAlone.java
@@ -16,7 +16,7 @@ void test() throws IOException {
try (BufferedReader br1 = new BufferedReader(null);
BufferedReader br2 = new BufferedReader(br1)) {
;
- } // ok
+ }
catch (IOException e) {
;
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestTryWithResourceSame.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestTryWithResourceSame.java
index 56975fd501d..969bc0a4d0f 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestTryWithResourceSame.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestTryWithResourceSame.java
@@ -24,22 +24,22 @@ void test() throws IOException {
BufferedReader br2 = new BufferedReader(br1))
{
;
- } catch (IOException e) // ok
+ } catch (IOException e)
{
;
}
try (BufferedReader br1 = new BufferedReader(null);
// violation below ''}' at column 67 should be on the same line as .*/catch'
BufferedReader br2 = new BufferedReader(br1)) { ; }
- catch (IOException e) { ; } // ok
+ catch (IOException e) { ; }
try (BufferedReader br1 = new BufferedReader(null);
- BufferedReader br2 = new BufferedReader(br1)) {} catch (IOException e) { ; } // ok
+ BufferedReader br2 = new BufferedReader(br1)) {} catch (IOException e) { ; }
try (BufferedReader br1 = new BufferedReader(null);
BufferedReader br2 = new BufferedReader(br1)) {
;
}
try (BufferedReader br1 = new BufferedReader(null);
- BufferedReader br2 = new BufferedReader(br1)) { ; } // ok
+ BufferedReader br2 = new BufferedReader(br1)) { ; }
try (BufferedReader br1 = new BufferedReader(null)) {
; } // violation ''}' at column 15 should have line break before'
try (BufferedReader br1 = new BufferedReader(null)) {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestWithoutFinally.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestWithoutFinally.java
index f4a2238e811..9699536fe4a 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestWithoutFinally.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestWithoutFinally.java
@@ -26,4 +26,4 @@ void foo() throws InterruptedException
}
-class UniqEmptyClassTestWithoutFinally {private int a;} // ok
+class UniqEmptyClassTestWithoutFinally {private int a;}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTryWithResourceAloneSingle.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTryWithResourceAloneSingle.java
index 2a08121851d..9baf82518c6 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTryWithResourceAloneSingle.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyTryWithResourceAloneSingle.java
@@ -16,7 +16,7 @@ void test() throws IOException {
try (BufferedReader br1 = new BufferedReader(null);
BufferedReader br2 = new BufferedReader(br1)) {
;
- } // ok
+ }
catch (IOException e) {
;
}
@@ -29,8 +29,8 @@ void test() throws IOException {
;
}
try (BufferedReader br1 = new BufferedReader(null);
- BufferedReader br2 = new BufferedReader(br1)) { ; } // ok
- catch (IOException e) { ; } // ok
+ BufferedReader br2 = new BufferedReader(br1)) { ; }
+ catch (IOException e) { ; }
try (BufferedReader br1 = new BufferedReader(null);
// violation below ''}' at column 64 should be alone on a line'
BufferedReader br2 = new BufferedReader(br1)) {} catch (IOException e) { ; }
@@ -39,7 +39,7 @@ void test() throws IOException {
;
}
try (BufferedReader br1 = new BufferedReader(null);
- BufferedReader br2 = new BufferedReader(br1)) { ; } // ok
+ BufferedReader br2 = new BufferedReader(br1)) { ; }
try (BufferedReader br1 = new BufferedReader(null)) {
; } // violation ''}' at column 15 should be alone on a line'
try (BufferedReader br1 = new BufferedReader(null)) {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyWithEmoji.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyWithEmoji.java
index 951c628275f..330662e5232 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyWithEmoji.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyWithEmoji.java
@@ -13,11 +13,11 @@ public class InputRightCurlyWithEmoji {
static Runnable r = () -> {
String.valueOf("Hello world 🥳 🎄 !!");
- }; // ok
+ };
private void method2() {
String x = "🎄🤣";
- { String y = "🎄🤣🎄🤣";} // ok
+ { String y = "🎄🤣🎄🤣";}
try {
if (x.equals("🎄🤣")) {
@@ -29,7 +29,7 @@ else if (!x.equals("🎄🤣")) {
else {
x = "🎄🤣";
- } // ok
+ }
switch (x) {
case "\uD83C\uDF84\uD83E\uDD23":
break;
@@ -41,7 +41,7 @@ else if (!x.equals("🎄🤣")) {
switch ("🤣") {
case "qw": {
return;
- } // ok
+ }
default: {
return;
}
@@ -62,14 +62,14 @@ public void foo3() {
do {
i++;
String.CASE_INSENSITIVE_ORDER.equals(i + " ");
- } while (a.equals("🧐")); // ok
+ } while (a.equals("🧐"));
}
String method4(String a) {
if (a.equals("🎄")) a = "😆"; return "😆🤩"; }
// violation above ''}' at column 50 should have line break before.'
- public void foo4() {String a = "😆🤩";} // ok
+ public void foo4() {String a = "😆🤩";}
interface Interface3 {
void display();
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyWithEmojiAloneOrSingleLine.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyWithEmojiAloneOrSingleLine.java
index 27dedde584d..5efec54bf33 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyWithEmojiAloneOrSingleLine.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/InputRightCurlyWithEmojiAloneOrSingleLine.java
@@ -12,8 +12,8 @@
public class InputRightCurlyWithEmojiAloneOrSingleLine {
private String a;
private static String b;
- { a = "🧐😏"; } // ok
- static { b = "😧🤩"; } // ok
+ { a = "🧐😏"; }
+ static { b = "😧🤩"; }
void method2(java.util.HashSet set) {
@@ -30,11 +30,11 @@ String method4(String a) {
if (a.equals("🎄")) ; return "😆🤩"; }
// violation above ''}' at column 43 should be alone on a line.'
void method5(String a, int b) {
- while ("👈🏻🧐".length() > 5) { ; } // ok
+ while ("👈🏻🧐".length() > 5) { ; }
- if ("👉🏻👉🏼".isEmpty()) { ; } // ok
+ if ("👉🏻👉🏼".isEmpty()) { ; }
- do {b--;} while (a.equals("🤩")); // ok
+ do {b--;} while (a.equals("🤩"));
for (int i = 1; i < 10; i++) {
if("🎄🎄🎄".charAt(i) == 's') i++; }
From 89daee5701a4a9d3106ada95615d4c32ba8661ba Mon Sep 17 00:00:00 2001
From: Kevin222004
Date: Wed, 2 Aug 2023 23:28:01 +0530
Subject: [PATCH 064/833] Issue #13501: Kill mutation for ImportOrderCheck-2
---
.../pitest-imports-suppressions.xml | 37 -------------------
.../checks/imports/ImportOrderCheckTest.java | 8 ++++
.../importorder/InputImportOrder6.java | 28 ++++++++++++++
3 files changed, 36 insertions(+), 37 deletions(-)
create mode 100644 src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrder6.java
diff --git a/config/pitest-suppressions/pitest-imports-suppressions.xml b/config/pitest-suppressions/pitest-imports-suppressions.xml
index a0613f147de..44f97a2795d 100644
--- a/config/pitest-suppressions/pitest-imports-suppressions.xml
+++ b/config/pitest-suppressions/pitest-imports-suppressions.xml
@@ -36,42 +36,6 @@
final boolean regex = containsRegexAttribute(attributes);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ImportOrderCheck.java
- com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck
- getGroupNumber
- org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator
- removed call to java/util/regex/Matcher::end
- bestEnd = matcher.end();
-
-
-
- ImportOrderCheck.java
- com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck
- getGroupNumber
- org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator
- removed call to java/util/regex/Matcher::start
- if (matcher.start() < bestPos) {
-
-
PkgImportControl.javacom.puppycrawl.tools.checkstyle.checks.imports.PkgImportControl
@@ -98,5 +62,4 @@
Removed assignment to member variable regexthis.regex = false;
-
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java
index 54d8631ba35..181c4845962 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java
@@ -47,6 +47,14 @@ protected String getPackageLocation() {
return "com/puppycrawl/tools/checkstyle/checks/imports/importorder";
}
+ @Test
+ public void testVeryPreciseGrouping() throws Exception {
+ final String[] expected = {};
+
+ verifyWithInlineConfigParser(
+ getNonCompilablePath("InputImportOrder6.java"), expected);
+ }
+
@Test
public void testGetTokens() {
final ImportOrderCheck checkObj = new ImportOrderCheck();
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrder6.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrder6.java
new file mode 100644
index 00000000000..2b3ab1e15a5
--- /dev/null
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrder6.java
@@ -0,0 +1,28 @@
+/*
+ImportOrder
+option = (default)under
+groups = /awt/, /jar/, /jar.*.JarInputStream/, /jar.*.JarInput/
+ordered = (default)true
+separated = true
+separatedStaticGroups = (default)false
+caseSensitive = (default)true
+staticGroups = (default)
+sortStaticImportsAlphabetically = (default)false
+useContainerOrderingForStatic = (default)false
+
+
+*/
+
+//non-compiled with javac: contains specially crafted set of imports for testing
+package com.puppycrawl.tools.checkstyle.checks.imports.importorder;
+
+import java.awt.Button;
+
+import java.util.jar.Some;
+
+import java.util.jar.JarInputStream;
+
+import java.util.jar.JarInputMy;
+
+public class InputImportOrder6 {
+}
From a2ccbc795388af808d291e7b138d79250216931d Mon Sep 17 00:00:00 2001
From: Vyom-Yadav
Date: Wed, 9 Aug 2023 18:28:33 +0530
Subject: [PATCH 065/833] Pull #13492: Fix Pitest script to recognize unstable
mutations
---
.ci/pitest-survival-check-xml.groovy | 10 +++++-----
.../pitest-suppressions/pitest-xpath-suppressions.xml | 9 ---------
2 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/.ci/pitest-survival-check-xml.groovy b/.ci/pitest-survival-check-xml.groovy
index fa58dd33c25..d015cd9bb37 100644
--- a/.ci/pitest-survival-check-xml.groovy
+++ b/.ci/pitest-survival-check-xml.groovy
@@ -267,7 +267,7 @@ private static int printComparisonToConsole(Set survivingMutations,
println 'No new surviving mutation(s) found.'
}
else if (survivingUnsuppressedMutations.isEmpty()
- && !hasOnlyStableMutations(extraSuppressions)) {
+ && hasOnlyUnstableMutations(extraSuppressions)) {
exitCode = 0
println 'No new surviving mutation(s) found.'
}
@@ -293,13 +293,13 @@ private static int printComparisonToConsole(Set survivingMutations,
}
/**
- * Whether a set has only stable mutations.
+ * Whether a set has only unstable mutations.
*
* @param mutations A set of mutations
- * @return {@code true} if a set has only stable mutations
+ * @return {@code true} if a set has only unstable mutations
*/
-private static boolean hasOnlyStableMutations(Set mutations) {
- return mutations.every { !it.isUnstable() }
+private static boolean hasOnlyUnstableMutations(Set mutations) {
+ return mutations.every { it.isUnstable() }
}
/**
diff --git a/config/pitest-suppressions/pitest-xpath-suppressions.xml b/config/pitest-suppressions/pitest-xpath-suppressions.xml
index c488fb43ded..6773b471dba 100644
--- a/config/pitest-suppressions/pitest-xpath-suppressions.xml
+++ b/config/pitest-suppressions/pitest-xpath-suppressions.xml
@@ -9,15 +9,6 @@
return Collections.unmodifiableList(siblings.subList(0, indexAmongSiblings));
-
- AbstractElementNode.java
- com.puppycrawl.tools.checkstyle.xpath.AbstractElementNode
- iterateAxis
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_8
- RemoveSwitch 8 (case value 8)
- switch (axisNumber) {
-
-
AbstractRootNode.javacom.puppycrawl.tools.checkstyle.xpath.AbstractRootNode
From 2965db1421b927bc4e14d8f383b7d0f1678d3d53 Mon Sep 17 00:00:00 2001
From: Clint-Mathews
Date: Thu, 14 Sep 2023 09:14:10 +0530
Subject: [PATCH 066/833] Issue #13735: Fixed typo in files
invalidjavadocposition.xml and Example1.txt
---
.../checks/javadoc/invalidjavadocposition/Example1.txt | 2 +-
src/xdocs/checks/javadoc/invalidjavadocposition.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition/Example1.txt
index 764620dd8e2..cb5cd3368ad 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition/Example1.txt
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition/Example1.txt
@@ -9,7 +9,7 @@
// xdoc section -- start
@SuppressWarnings("serial")
/**
- * This comment looks like javadoc but it at an invalid location.
+ * This comment looks like Javadoc but it is at an invalid location.
* Therefore, the text will not get into TestClass.html and the check will produce a violation.
*/
public class TestClass {
diff --git a/src/xdocs/checks/javadoc/invalidjavadocposition.xml b/src/xdocs/checks/javadoc/invalidjavadocposition.xml
index da5968549c7..bbd0a9b7b88 100644
--- a/src/xdocs/checks/javadoc/invalidjavadocposition.xml
+++ b/src/xdocs/checks/javadoc/invalidjavadocposition.xml
@@ -39,7 +39,7 @@
@SuppressWarnings("serial")
/**
- * This comment looks like javadoc but it at an invalid location.
+ * This comment looks like Javadoc but it is at an invalid location.
* Therefore, the text will not get into TestClass.html and the check will produce a violation.
*/
public class TestClass {
From 90974261a22f04f4186d69bee7e3c49cc1044fe1 Mon Sep 17 00:00:00 2001
From: piyush kumar sadangi
Date: Mon, 11 Sep 2023 16:06:02 +0530
Subject: [PATCH 067/833] Issue #13345: Enable examples tests
(SuppressWarningsCheckExamplesTest)
---
.../SuppressWarningsCheckExamplesTest.java | 14 ++-
.../annotation/suppresswarnings/Example1.java | 37 +++++++
.../annotation/suppresswarnings/Example1.txt | 30 ------
.../annotation/suppresswarnings/Example2.java | 51 +++++++++
.../annotation/suppresswarnings/Example2.txt | 39 -------
.../checks/annotation/suppresswarnings.xml | 100 +++++++++++-------
.../annotation/suppresswarnings.xml.template | 90 +++++-----------
7 files changed, 185 insertions(+), 176 deletions(-)
create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example1.java
delete mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example1.txt
create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example2.java
delete mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example2.txt
diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheckExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheckExamplesTest.java
index 8cebd767b8b..dd71c0d9919 100644
--- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheckExamplesTest.java
+++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheckExamplesTest.java
@@ -19,12 +19,12 @@
package com.puppycrawl.tools.checkstyle.checks.annotation;
-import org.junit.jupiter.api.Disabled;
+import static com.puppycrawl.tools.checkstyle.checks.annotation.SuppressWarningsCheck.MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED;
+
import org.junit.jupiter.api.Test;
import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
-@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345")
public class SuppressWarningsCheckExamplesTest extends AbstractExamplesModuleTestSupport {
@Override
protected String getPackageLocation() {
@@ -35,17 +35,21 @@ protected String getPackageLocation() {
public void testExample1() throws Exception {
final String[] expected = {
+ "13:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""),
+ "16:21: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""),
};
- verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example1.java"), expected);
}
@Test
public void testExample2() throws Exception {
final String[] expected = {
-
+ "40:21: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"),
+ "44:32: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"),
+ "49:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"),
};
- verifyWithInlineConfigParser(getPath("Example2.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example2.java"), expected);
}
}
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example1.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example1.java
new file mode 100644
index 00000000000..fdcf6e65b27
--- /dev/null
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example1.java
@@ -0,0 +1,37 @@
+/*xml
+
+
+
+
+
+*/
+
+package com.puppycrawl.tools.checkstyle.checks.annotation.suppresswarnings;
+
+// xdoc section -- start
+// violation below 'The warning '' cannot be suppressed at this location'
+@SuppressWarnings("")
+class Example1 {
+ // violation below 'The warning '' cannot be suppressed at this location'
+ @SuppressWarnings("")
+ final int num1 = 1;
+ // ok below as default format only checks for a blank or empty string
+ @SuppressWarnings("all")
+ final int num2 = 2;
+ // ok below as default format only checks for a blank or empty string
+ @SuppressWarnings("unused")
+ final int num3 = 3;
+
+ void foo1(@SuppressWarnings("unused") int param) {}
+
+ @SuppressWarnings("all")
+ void foo2(int param) {}
+ @SuppressWarnings("unused")
+ void foo3(int param) {}
+ @SuppressWarnings(true?"all":"unused")
+ void foo4(int param) {}
+}
+// ok below as default format only checks for a blank or empty string
+@SuppressWarnings("unchecked")
+class Test1 {}
+// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example1.txt
deleted file mode 100644
index 2ddd5266141..00000000000
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example1.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-/*xml
-
-
-
-
-
-*/
-
-// xdoc section -- start
-@SuppressWarnings("") // violation
-class TestA {
- @SuppressWarnings("") // violation
- final int num1 = 1;
- @SuppressWarnings("all") // ok
- final int num2 = 2;
- @SuppressWarnings("unused") // ok
- final int num3 = 3;
-
- void foo1(@SuppressWarnings("unused") int param) {} // ok
-
- @SuppressWarnings("all") // ok
- void foo2(int param) {}
- @SuppressWarnings("unused") // ok
- void foo3(int param) {}
- @SuppressWarnings(true?"all":"unused") // ok
- void foo4(int param) {}
-}
-@SuppressWarnings("unchecked") // ok
-class TestB {}
-// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example2.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example2.java
new file mode 100644
index 00000000000..a94b0ed2450
--- /dev/null
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example2.java
@@ -0,0 +1,51 @@
+/*xml
+
+
+
+
+
+
+
+
+*/
+
+package com.puppycrawl.tools.checkstyle.checks.annotation.suppresswarnings;
+
+// xdoc section -- start
+// ok below, since we are only checking for '^unchecked$|^unused$'
+@SuppressWarnings("")
+class Example2 {
+ // ok below as VARIABLE_DEF is not configured in tokens to check
+ @SuppressWarnings("")
+ final int num1 = 1;
+ @SuppressWarnings("all")
+ final int num2 = 2;
+ @SuppressWarnings("unused")
+ final int num3 = 3;
+
+ // ok below as PARAMETER_DEF is not configured in tokens to check
+ void foo1(@SuppressWarnings("unused") int param) {}
+
+ // ok below, since we are only checking for '^unchecked$|^unused$'
+ @SuppressWarnings("all")
+ void foo2(int param) {}
+
+ // violation below, 'The warning 'unused' cannot be suppressed at this location'
+ @SuppressWarnings("unused")
+ void foo3(int param) {}
+
+ // violation below, 'The warning 'unused' cannot be suppressed at this location'
+ @SuppressWarnings(true?"all":"unused")
+ void foo4(int param) {}
+}
+
+// violation below, 'The warning 'unchecked' cannot be suppressed at this location'
+@SuppressWarnings("unchecked")
+class Test2 {}
+// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example2.txt
deleted file mode 100644
index 95373ba21f3..00000000000
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings/Example2.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-/*xml
-
-
-
-
-
-
-
-
-*/
-
-// xdoc section -- start
-@SuppressWarnings("") // ok
-class TestA {
- @SuppressWarnings("") // ok
- final int num1 = 1;
- @SuppressWarnings("all") // ok
- final int num2 = 2;
- @SuppressWarnings("unused") // ok
- final int num3 = 3;
-
- void foo1(@SuppressWarnings("unused") int param) {} // ok
-
- @SuppressWarnings("all") // ok
- void foo2(int param) {}
- @SuppressWarnings("unused") // violation
- void foo3(int param) {}
- @SuppressWarnings(true?"all":"unused") // violation
- void foo4(int param) {}
-}
-@SuppressWarnings("unchecked") // violation
-class TestB {}
-// xdoc section -- end
diff --git a/src/xdocs/checks/annotation/suppresswarnings.xml b/src/xdocs/checks/annotation/suppresswarnings.xml
index 4ca126a52d9..fb56eefa4be 100644
--- a/src/xdocs/checks/annotation/suppresswarnings.xml
+++ b/src/xdocs/checks/annotation/suppresswarnings.xml
@@ -139,74 +139,98 @@
-
-@SuppressWarnings("") // violation
-class TestA {
- @SuppressWarnings("") // violation
+// violation below 'The warning '' cannot be suppressed at this location'
+@SuppressWarnings("")
+class Example1 {
+ // violation below 'The warning '' cannot be suppressed at this location'
+ @SuppressWarnings("")
final int num1 = 1;
- @SuppressWarnings("all") // ok
+ // ok below as default format only checks for a blank or empty string
+ @SuppressWarnings("all")
final int num2 = 2;
- @SuppressWarnings("unused") // ok
+ // ok below as default format only checks for a blank or empty string
+ @SuppressWarnings("unused")
final int num3 = 3;
- void foo1(@SuppressWarnings("unused") int param) {} // ok
+ void foo1(@SuppressWarnings("unused") int param) {}
- @SuppressWarnings("all") // ok
+ @SuppressWarnings("all")
void foo2(int param) {}
- @SuppressWarnings("unused") // ok
+ @SuppressWarnings("unused")
void foo3(int param) {}
- @SuppressWarnings(true?"all":"unused") // ok
+ @SuppressWarnings(true?"all":"unused")
void foo4(int param) {}
}
-@SuppressWarnings("unchecked") // ok
-class TestB {}
+// ok below as default format only checks for a blank or empty string
+@SuppressWarnings("unchecked")
+class Test1 {}
-
+
To configure the check so that the "unchecked" and "unused"
warnings cannot be suppressed on anything
but variable and parameter declarations.
-@SuppressWarnings("") // ok
-class TestA {
- @SuppressWarnings("") // ok
+// ok below, since we are only checking for '^unchecked$|^unused$'
+@SuppressWarnings("")
+class Example2 {
+ // ok below as VARIABLE_DEF is not configured in tokens to check
+ @SuppressWarnings("")
final int num1 = 1;
- @SuppressWarnings("all") // ok
+ @SuppressWarnings("all")
final int num2 = 2;
- @SuppressWarnings("unused") // ok
+ @SuppressWarnings("unused")
final int num3 = 3;
- void foo1(@SuppressWarnings("unused") int param) {} // ok
+ // ok below as PARAMETER_DEF is not configured in tokens to check
+ void foo1(@SuppressWarnings("unused") int param) {}
- @SuppressWarnings("all") // ok
+ // ok below, since we are only checking for '^unchecked$|^unused$'
+ @SuppressWarnings("all")
void foo2(int param) {}
- @SuppressWarnings("unused") // violation
+
+ // violation below, 'The warning 'unused' cannot be suppressed at this location'
+ @SuppressWarnings("unused")
void foo3(int param) {}
- @SuppressWarnings(true?"all":"unused") // violation
+
+ // violation below, 'The warning 'unused' cannot be suppressed at this location'
+ @SuppressWarnings(true?"all":"unused")
void foo4(int param) {}
}
-@SuppressWarnings("unchecked") // violation
-class TestB {}
+
+// violation below, 'The warning 'unchecked' cannot be suppressed at this location'
+@SuppressWarnings("unchecked")
+class Test2 {}
diff --git a/src/xdocs/checks/annotation/suppresswarnings.xml.template b/src/xdocs/checks/annotation/suppresswarnings.xml.template
index 02c46903bb5..49106ff915d 100644
--- a/src/xdocs/checks/annotation/suppresswarnings.xml.template
+++ b/src/xdocs/checks/annotation/suppresswarnings.xml.template
@@ -139,75 +139,37 @@
-
To configure the check:
- <module name="SuppressWarnings"/>
-
-
-
Example:
-
-@SuppressWarnings("") // violation
-class TestA {
- @SuppressWarnings("") // violation
- final int num1 = 1;
- @SuppressWarnings("all") // ok
- final int num2 = 2;
- @SuppressWarnings("unused") // ok
- final int num3 = 3;
-
- void foo1(@SuppressWarnings("unused") int param) {} // ok
-
- @SuppressWarnings("all") // ok
- void foo2(int param) {}
- @SuppressWarnings("unused") // ok
- void foo3(int param) {}
- @SuppressWarnings(true?"all":"unused") // ok
- void foo4(int param) {}
-}
-@SuppressWarnings("unchecked") // ok
-class TestB {}
-
+
+ To configure the check:
+
+
+
+
+
+
Example:
+
+
+
+
-
+
To configure the check so that the "unchecked" and "unused"
warnings cannot be suppressed on anything
but variable and parameter declarations.
- * Property {@code ignoreOverriddenMethods} - allow to ignore checking overridden methods
+ * Property {@code ignoreOverriddenMethods} - Allow to ignore checking overridden methods
* (marked with {@code Override} or {@code java.lang.Override} annotation).
* Type is {@code boolean}.
* Default value is {@code true}.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/IllegalThrowsCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/IllegalThrowsCheck.xml
index 883f3098afc..524c9aadc10 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/IllegalThrowsCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/IllegalThrowsCheck.xml
@@ -21,7 +21,7 @@
Specify names of methods to ignore.
- allow to ignore checking overridden methods
+ Allow to ignore checking overridden methods
(marked with {@code Override} or {@code java.lang.Override} annotation).
diff --git a/src/xdocs/checks/coding/illegalthrows.xml b/src/xdocs/checks/coding/illegalthrows.xml
index ea68b1abca6..a8037bd3e51 100644
--- a/src/xdocs/checks/coding/illegalthrows.xml
+++ b/src/xdocs/checks/coding/illegalthrows.xml
@@ -45,7 +45,7 @@
ignoreOverriddenMethods
- allow to ignore checking overridden methods (marked with Override
+ Allow to ignore checking overridden methods (marked with Override
or java.lang.Override annotation).
- allow to ignore checking overridden methods (marked with Override
+ Allow to ignore checking overridden methods (marked with Override
or java.lang.Override annotation).
-@SuppressWarnings("unchecked") // OK
-@Deprecated // OK
-@SomeArrays({"unchecked","unused"}) // OK
-public class TestOne
+@SuppressWarnings("unchecked") // ok as it's in implied style
+@Deprecated // ok as it matches closingParens default property
+@SomeArrays({"unchecked","unused"}) // ok as it's in implied style
+public class Example1
{
}
-@SuppressWarnings(value={"unchecked"}) // Violation - parameter 'value' shouldn't be used
-@Deprecated() // Violation - cannot have a closing parenthesis
-@SomeArrays(value={"unchecked","unused",}) // Violation - cannot have a trailing array comma
-class TestTwo {
+// violation below 'Annotation style must be 'COMPACT_NO_ARRAY''
+@SuppressWarnings(value={"unchecked"})
+@Deprecated() // violation 'Annotation cannot have closing parenthesis'
+// violation below 'Annotation array values cannot contain trailing comma'
+@SomeArrays(value={"unchecked","unused",})
+class TestStyle1
+{
}
-
+
+
To configure the check to enforce an expanded style,
- with a closing parenthesis and a trailing array comma set to never.
+ with a closing parenthesis and a trailing array comma set to never.
-@SuppressWarnings("unchecked") // Violation - parameters should be referenced
-@Deprecated // OK
-@SomeArrays({"unchecked","unused"}) // Violation - parameters should be referenced
-public class TestOne
+@SuppressWarnings("unchecked") // violation 'Annotation style must be 'EXPANDED''
+@Deprecated // ok as closingParens property set to never
+// violation below 'Annotation style must be 'EXPANDED''
+@SomeArrays({"unchecked","unused"})
+public class Example2
{
}
-@SuppressWarnings(value={"unchecked"}) // OK
-@Deprecated() // Violation - cannot have a closing parenthesis
-@SomeArrays(value={"unchecked","unused",}) // Violation - cannot have a trailing array comma
-class TestTwo {
+@SuppressWarnings(value={"unchecked"}) // ok as elementStyle set to expanded
+@Deprecated() // violation 'Annotation cannot have closing parenthesis'
+// violation below 'Annotation array values cannot contain trailing comma'
+@SomeArrays(value={"unchecked","unused",})
+class TestStyle2 {
}
-
- To configure the check to enforce a compact style,
- with always including a closing parenthesis and ignoring a trailing array comma.
+
+
+ To configure the check to enforce an expanded style,
+ with a closing parenthesis and a trailing array comma set to never.
-@SuppressWarnings("unchecked") // OK
-@Deprecated // Violation - must have a closing parenthesis
-@SomeArrays({"unchecked","unused"}) // OK
-public class TestOne
+@SuppressWarnings("unchecked") // ok as element style set to compact
+@Deprecated // violation 'Annotation must have closing parenthesis'
+@SomeArrays({"unchecked","unused"}) // ok as it's in compact style
+public class Example3
{
}
-@SuppressWarnings(value={"unchecked"}) // Violation - parameter 'value' shouldn't be used
-@Deprecated() // OK
-@SomeArrays(value={"unchecked","unused",}) // Violation - parameter 'value' shouldn't be used
-class TestTwo {
+// violation below 'Annotation style must be 'COMPACT''
+@SuppressWarnings(value={"unchecked"})
+@Deprecated() // ok as closingParens set to always
+// violation below 'Annotation style must be 'COMPACT''
+@SomeArrays(value={"unchecked","unused",})
+class TestStyle3 {
}
-
+
+
To configure the check to enforce a trailing array comma,
- with ignoring the elementStyle and a closing parenthesis.
+ with ignoring the elementStyle and a closing parenthesis.
-@SuppressWarnings("unchecked") // OK
-@Deprecated // OK
-@SomeArrays({"unchecked","unused"}) // Violation - must have a trailing array comma
-public class TestOne
+@SuppressWarnings("unchecked") // ok as element style set to 'ignore'
+@Deprecated // ok as 'closingParens' is set to 'ignore
+// violation below 'Annotation array values must contain trailing comma'
+@SomeArrays({"unchecked","unused"})
+public class Example4
{
}
-@SuppressWarnings(value={"unchecked"}) // Violation - must have a trailing array comma
-@Deprecated() // OK
-@SomeArrays(value={"unchecked","unused",}) // OK
-class TestTwo {
+// violation below 'Annotation array values must contain trailing comma'
+@SuppressWarnings(value={"unchecked"})
+@Deprecated() // ok as 'closingParens' is set to 'ignore
+// ok below as it has a trailing array comma
+@SomeArrays(value={"unchecked","unused",})
+class TestStyle4 {
}
diff --git a/src/xdocs/checks/annotation/annotationusestyle.xml.template b/src/xdocs/checks/annotation/annotationusestyle.xml.template
index c99a8ca6bb1..adc64272437 100644
--- a/src/xdocs/checks/annotation/annotationusestyle.xml.template
+++ b/src/xdocs/checks/annotation/annotationusestyle.xml.template
@@ -130,119 +130,68 @@
-
To configure the check:
-
-<module name="AnnotationUseStyle"/>
-
-
- Example:
+
+ To configure the check:
-
-@SuppressWarnings("unchecked") // OK
-@Deprecated // OK
-@SomeArrays({"unchecked","unused"}) // OK
-public class TestOne
-{
-
-}
-
-@SuppressWarnings(value={"unchecked"}) // Violation - parameter 'value' shouldn't be used
-@Deprecated() // Violation - cannot have a closing parenthesis
-@SomeArrays(value={"unchecked","unused",}) // Violation - cannot have a trailing array comma
-class TestTwo {
+
+
+
+
+
Example:
+
+
+
+
-}
-
-
+
To configure the check to enforce an expanded style,
- with a closing parenthesis and a trailing array comma set to never.
-
+ To configure the check to enforce an expanded style,
+ with a closing parenthesis and a trailing array comma set to never.
-
-@SuppressWarnings("unchecked") // OK
-@Deprecated // Violation - must have a closing parenthesis
-@SomeArrays({"unchecked","unused"}) // OK
-public class TestOne
-{
-
-}
-
-@SuppressWarnings(value={"unchecked"}) // Violation - parameter 'value' shouldn't be used
-@Deprecated() // OK
-@SomeArrays(value={"unchecked","unused",}) // Violation - parameter 'value' shouldn't be used
-class TestTwo {
+
+
+
+
+
Example:
+
+
+
+
-}
-
-
+
To configure the check to enforce a trailing array comma,
- with ignoring the elementStyle and a closing parenthesis.
+ with ignoring the elementStyle and a closing parenthesis.
-
-@SuppressWarnings("unchecked") // OK
-@Deprecated // OK
-@SomeArrays({"unchecked","unused"}) // Violation - must have a trailing array comma
-public class TestOne
-{
-
-}
-
-@SuppressWarnings(value={"unchecked"}) // Violation - must have a trailing array comma
-@Deprecated() // OK
-@SomeArrays(value={"unchecked","unused",}) // OK
-class TestTwo {
-
-}
-
+
+
+
+
+
Example:
+
+
+
+
From 01826a2a08d62f3500419a1d4187f98fd4d8c6e6 Mon Sep 17 00:00:00 2001
From: Guneetsinghtuli
Date: Wed, 13 Sep 2023 04:18:56 +0530
Subject: [PATCH 071/833] Issue #13345: Enable LeftCurlyCheckExamplesTest
---
.../blocks/LeftCurlyCheckExamplesTest.java | 26 ++--
.../leftcurly/{Example1.txt => Example1.java} | 12 +-
.../leftcurly/{Example2.txt => Example2.java} | 8 +-
.../leftcurly/{Example3.txt => Example3.java} | 10 +-
.../checks/blocks/leftcurly/Example4.java | 30 ++++
.../checks/blocks/leftcurly/Example4.txt | 28 ----
src/xdocs/checks/blocks/leftcurly.xml | 87 +++++++-----
.../checks/blocks/leftcurly.xml.template | 134 ++++++------------
8 files changed, 158 insertions(+), 177 deletions(-)
rename src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/{Example1.txt => Example1.java} (52%)
rename src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/{Example2.txt => Example2.java} (71%)
rename src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/{Example3.txt => Example3.java} (63%)
create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example4.java
delete mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example4.txt
diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheckExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheckExamplesTest.java
index f139a8ca3a5..bde00a146d9 100644
--- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheckExamplesTest.java
+++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheckExamplesTest.java
@@ -19,12 +19,14 @@
package com.puppycrawl.tools.checkstyle.checks.blocks;
-import org.junit.jupiter.api.Disabled;
+import static com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck.MSG_KEY_LINE_BREAK_AFTER;
+import static com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck.MSG_KEY_LINE_NEW;
+import static com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck.MSG_KEY_LINE_PREVIOUS;
+
import org.junit.jupiter.api.Test;
import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
-@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345")
public class LeftCurlyCheckExamplesTest extends AbstractExamplesModuleTestSupport {
@Override
protected String getPackageLocation() {
@@ -34,36 +36,40 @@ protected String getPackageLocation() {
@Test
public void testExample1() throws Exception {
final String[] expected = {
-
+ "13:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", "1"),
+ "15:3: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", "3"),
};
- verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example1.java"), expected);
}
@Test
public void testExample2() throws Exception {
final String[] expected = {
-
+ "23:13: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", "13"),
};
- verifyWithInlineConfigParser(getPath("Example2.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example2.java"), expected);
}
@Test
public void testExample3() throws Exception {
final String[] expected = {
-
+ "16:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", "1"),
+ "22:13: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", "13"),
};
- verifyWithInlineConfigParser(getPath("Example3.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example3.java"), expected);
}
@Test
public void testExample4() throws Exception {
final String[] expected = {
-
+ "15:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", "1"),
+ "17:3: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", "3"),
+ "25:15: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", "15"),
};
- verifyWithInlineConfigParser(getPath("Example4.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example4.java"), expected);
}
}
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example1.java
similarity index 52%
rename from src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example1.txt
rename to src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example1.java
index efc769b8f36..2e6c4508a83 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example1.txt
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example1.java
@@ -6,16 +6,18 @@
*/
+package com.puppycrawl.tools.checkstyle.checks.blocks.leftcurly;
+
// xdoc section -- start
-class Test
-{ // Violation - '{' should be on the previous line
+class Example1
+{ // violation, ''{' at column 1 should be on the previous line.'
private interface TestInterface
- { // Violation - '{' should be on the previous line
+ { // violation, ''{' at column 3 should be on the previous line.'
}
private
- class
- MyClass { // OK
+ class
+ MyClass { // OK
}
enum Colors {RED, // OK
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example2.java
similarity index 71%
rename from src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example2.txt
rename to src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example2.java
index 6816c10341c..9128dc28627 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example2.txt
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example2.java
@@ -9,16 +9,18 @@
*/
+package com.puppycrawl.tools.checkstyle.checks.blocks.leftcurly;
+
// xdoc section -- start
-class Test
+class Example2
{ // OK
private interface TestInterface
{ // OK
}
private
- class
- MyClass { // Violation - '{' should be on a new line
+ class
+ MyClass { // violation, ''{' at column 13 should be on a new line.'
}
enum Colors {RED, // OK
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example3.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example3.java
similarity index 63%
rename from src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example3.txt
rename to src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example3.java
index b0689733e32..346a41c8e21 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example3.txt
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example3.java
@@ -9,15 +9,17 @@
*/
+package com.puppycrawl.tools.checkstyle.checks.blocks.leftcurly;
+
// xdoc section -- start
-class Test
-{ // Violation - '{' should be on the previous line
+class Example3
+{ // violation, ''{' at column 1 should be on the previous line.'
private interface TestInterface { // OK
}
private
- class
- MyClass { // Violation - '{' should be on a new line
+ class
+ MyClass { // violation, ''{' at column 13 should be on a new line.'
}
enum Colors {RED, // OK
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example4.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example4.java
new file mode 100644
index 00000000000..12326c4abbc
--- /dev/null
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example4.java
@@ -0,0 +1,30 @@
+/*xml
+
+
+
+
+
+
+
+*/
+
+package com.puppycrawl.tools.checkstyle.checks.blocks.leftcurly;
+
+// xdoc section -- start
+class Example4
+{ // violation, ''{' at column 1 should be on the previous line.'
+ private interface TestInterface
+ { // violation, ''{' at column 3 should be on the previous line.'
+ }
+
+ private
+ class
+ MyClass { // OK
+ }
+
+ enum Colors {RED, // violation, ''{' at column 15 should have line break after.'
+ BLUE,
+ GREEN;
+ }
+}
+// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example4.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example4.txt
deleted file mode 100644
index 2f79f62ff96..00000000000
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly/Example4.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-/*xml
-
-
-
-
-
-
-
-*/
-
-// xdoc section -- start
-class Test
-{ // Violation - '{' should be on the previous line
- private interface TestInterface
- { // Violation - '{' should be on the previous line
- }
-
- private
- class
- MyClass { // OK
- }
-
- enum Colors {RED, // Violation - '{' should have line break after
- BLUE,
- GREEN;
- }
-}
-// xdoc section -- end
diff --git a/src/xdocs/checks/blocks/leftcurly.xml b/src/xdocs/checks/blocks/leftcurly.xml
index 851e3c0e995..f2aa3aebf0b 100644
--- a/src/xdocs/checks/blocks/leftcurly.xml
+++ b/src/xdocs/checks/blocks/leftcurly.xml
@@ -152,20 +152,26 @@
-
-class Test
-{ // Violation - '{' should be on the previous line
+class Example1
+{ // violation, ''{' at column 1 should be on the previous line.'
private interface TestInterface
- { // Violation - '{' should be on the previous line
+ { // violation, ''{' at column 3 should be on the previous line.'
}
private
- class
- MyClass { // OK
+ class
+ MyClass { // OK
}
enum Colors {RED, // OK
@@ -174,26 +180,31 @@ class Test
}
}
-
+
To configure the check to apply the nl policy to
type blocks:
-class Test
+class Example2
{ // OK
private interface TestInterface
{ // OK
}
private
- class
- MyClass { // Violation - '{' should be on a new line
+ class
+ MyClass { // violation, ''{' at column 13 should be on a new line.'
}
enum Colors {RED, // OK
@@ -202,25 +213,30 @@ class Test
}
}
-
+
To configure the check to apply the nlow policy to
type blocks:
-class Test
-{ // Violation - '{' should be on the previous line
+class Example3
+{ // violation, ''{' at column 1 should be on the previous line.'
private interface TestInterface { // OK
}
private
- class
- MyClass { // Violation - '{' should be on a new line
+ class
+ MyClass { // violation, ''{' at column 13 should be on a new line.'
}
enum Colors {RED, // OK
@@ -229,29 +245,34 @@ class Test
}
}
-
+
An example of how to configure the check to validate enum definitions:
-class Test
-{ // Violation - '{' should be on the previous line
+class Example4
+{ // violation, ''{' at column 1 should be on the previous line.'
private interface TestInterface
- { // Violation - '{' should be on the previous line
+ { // violation, ''{' at column 3 should be on the previous line.'
}
private
- class
- MyClass { // OK
+ class
+ MyClass { // OK
}
- enum Colors {RED, // Violation - '{' should have line break after
- BLUE,
- GREEN;
+ enum Colors {RED, // violation, ''{' at column 15 should have line break after.'
+ BLUE,
+ GREEN;
}
}
diff --git a/src/xdocs/checks/blocks/leftcurly.xml.template b/src/xdocs/checks/blocks/leftcurly.xml.template
index b4d7ffc7db4..55f42079dc7 100644
--- a/src/xdocs/checks/blocks/leftcurly.xml.template
+++ b/src/xdocs/checks/blocks/leftcurly.xml.template
@@ -152,109 +152,55 @@
-
To configure the check:
-
-<module name="LeftCurly"/>
-
-
-class Test
-{ // Violation - '{' should be on the previous line
- private interface TestInterface
- { // Violation - '{' should be on the previous line
- }
-
- private
- class
- MyClass { // OK
- }
+
To configure the check to apply the nl policy to
type blocks:
-
-<module name="LeftCurly">
- <property name="option" value="nl"/>
- <property name="tokens" value="CLASS_DEF,INTERFACE_DEF"/>
-</module>
-
-
-class Test
-{ // OK
- private interface TestInterface
- { // OK
- }
-
- private
- class
- MyClass { // Violation - '{' should be on a new line
- }
-
- enum Colors {RED, // OK
- BLUE,
- GREEN;
- }
-}
-
-
+
+
+
+
+
Example:
+
+
+
+
+
To configure the check to apply the nlow policy to
type blocks:
-
-<module name="LeftCurly">
- <property name="option" value="nlow"/>
- <property name="tokens" value="CLASS_DEF,INTERFACE_DEF"/>
-</module>
-
-
-class Test
-{ // Violation - '{' should be on the previous line
- private interface TestInterface { // OK
- }
-
- private
- class
- MyClass { // Violation - '{' should be on a new line
- }
-
- enum Colors {RED, // OK
- BLUE,
- GREEN;
- }
-}
-
-
+
+
+
+
+
Example:
+
+
+
+
+
An example of how to configure the check to validate enum definitions:
-
-<module name="LeftCurly">
- <property name="ignoreEnums" value="false"/>
-</module>
-
-
-class Test
-{ // Violation - '{' should be on the previous line
- private interface TestInterface
- { // Violation - '{' should be on the previous line
- }
-
- private
- class
- MyClass { // OK
- }
-
- enum Colors {RED, // Violation - '{' should have line break after
- BLUE,
- GREEN;
- }
-}
-
+
+
+
+
+
Example:
+
+
+
+
From a95d8ef412c8709242beff68b5441279b1bc9081 Mon Sep 17 00:00:00 2001
From: piyush kumar sadangi
Date: Thu, 14 Sep 2023 13:35:41 +0530
Subject: [PATCH 072/833] Issue #13345: Enable examples tests
(ArrayTypeStyleCheckExamplesTest)
---
.../ArrayTypeStyleCheckExamplesTest.java | 14 ++++++-----
.../checks/arraytypestyle/Example1.java | 24 +++++++++++++++++++
.../checks/arraytypestyle/Example1.txt | 22 -----------------
.../{Example2.txt => Example2.java} | 10 ++++----
src/xdocs/checks/misc/arraytypestyle.xml | 18 +++++++-------
.../checks/misc/arraytypestyle.xml.template | 8 +++----
6 files changed, 51 insertions(+), 45 deletions(-)
create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example1.java
delete mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example1.txt
rename src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/{Example2.txt => Example2.java} (50%)
diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/ArrayTypeStyleCheckExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/ArrayTypeStyleCheckExamplesTest.java
index be3f5a2eced..079f90ce1fa 100644
--- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/ArrayTypeStyleCheckExamplesTest.java
+++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/ArrayTypeStyleCheckExamplesTest.java
@@ -19,12 +19,12 @@
package com.puppycrawl.tools.checkstyle.checks;
-import org.junit.jupiter.api.Disabled;
+import static com.puppycrawl.tools.checkstyle.checks.ArrayTypeStyleCheck.MSG_KEY;
+
import org.junit.jupiter.api.Test;
import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
-@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345")
public class ArrayTypeStyleCheckExamplesTest extends AbstractExamplesModuleTestSupport {
@Override
protected String getPackageLocation() {
@@ -34,18 +34,20 @@ protected String getPackageLocation() {
@Test
public void testExample1() throws Exception {
final String[] expected = {
-
+ "14:17: " + getCheckMessage(MSG_KEY),
+ "20:17: " + getCheckMessage(MSG_KEY),
};
- verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example1.java"), expected);
}
@Test
public void testExample2() throws Exception {
final String[] expected = {
-
+ "15:6: " + getCheckMessage(MSG_KEY),
+ "22:17: " + getCheckMessage(MSG_KEY),
};
- verifyWithInlineConfigParser(getPath("Example2.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example2.java"), expected);
}
}
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example1.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example1.java
new file mode 100644
index 00000000000..721b622b045
--- /dev/null
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example1.java
@@ -0,0 +1,24 @@
+/*xml
+
+
+
+
+
+*/
+
+package com.puppycrawl.tools.checkstyle.checks.arraytypestyle;
+
+// xdoc section -- start
+public class Example1 {
+ int[] nums; // ok since default format checks for Java style
+ String strings[]; // violation, 'Array brackets at illegal position'
+
+ char[] toCharArray() {
+ return null;
+ }
+
+ byte getData()[] { // violation, 'Array brackets at illegal position'
+ return null;
+ }
+}
+// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example1.txt
deleted file mode 100644
index c055d76588e..00000000000
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example1.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-/*xml
-
-
-
-
-
-*/
-
-// xdoc section -- start
-public class MyClass {
- int[] nums; // OK
- String strings[]; // violation
-
- char[] toCharArray() { // OK
- return null;
- }
-
- byte getData()[] { // violation
- return null;
- }
-}
-// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example2.java
similarity index 50%
rename from src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example2.txt
rename to src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example2.java
index f6a607099f0..a0f44d71fe8 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example2.txt
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example2.java
@@ -8,16 +8,18 @@
*/
+package com.puppycrawl.tools.checkstyle.checks.arraytypestyle;
+
// xdoc section -- start
-public class MyClass {
- int[] nums; // violation
- String strings[]; // OK
+public class Example2 {
+ int[] nums; // violation, 'Array brackets at illegal position'
+ String strings[]; // OK as follows C style since 'javaStyle' set to false
char[] toCharArray() { // OK
return null;
}
- byte getData()[] { // violation
+ byte getData()[] { // violation, 'Array brackets at illegal position'
return null;
}
}
diff --git a/src/xdocs/checks/misc/arraytypestyle.xml b/src/xdocs/checks/misc/arraytypestyle.xml
index ba52cb28cb5..971e53018e7 100644
--- a/src/xdocs/checks/misc/arraytypestyle.xml
+++ b/src/xdocs/checks/misc/arraytypestyle.xml
@@ -62,15 +62,15 @@
Example:
-public class MyClass {
- int[] nums; // OK
- String strings[]; // violation
+public class Example1 {
+ int[] nums; // ok since default format checks for Java style
+ String strings[]; // violation, 'Array brackets at illegal position'
- char[] toCharArray() { // OK
+ char[] toCharArray() {
return null;
}
- byte getData()[] { // violation
+ byte getData()[] { // violation, 'Array brackets at illegal position'
return null;
}
}
@@ -91,15 +91,15 @@ public class MyClass {
Example:
-public class MyClass {
- int[] nums; // violation
- String strings[]; // OK
+public class Example2 {
+ int[] nums; // violation, 'Array brackets at illegal position'
+ String strings[]; // OK as follows C style since 'javaStyle' set to false
char[] toCharArray() { // OK
return null;
}
- byte getData()[] { // violation
+ byte getData()[] { // violation, 'Array brackets at illegal position'
return null;
}
}
diff --git a/src/xdocs/checks/misc/arraytypestyle.xml.template b/src/xdocs/checks/misc/arraytypestyle.xml.template
index 49c8a8b1310..9b4d6932bc5 100644
--- a/src/xdocs/checks/misc/arraytypestyle.xml.template
+++ b/src/xdocs/checks/misc/arraytypestyle.xml.template
@@ -53,7 +53,7 @@
+ value="resources/com/puppycrawl/tools/checkstyle/checks/arraytypestyle/Example1.java"/>
- * Property {@code illegalClassNames} - Specify throw class names to reject.
- * Type is {@code java.lang.String[]}.
- * Default value is {@code Error, RuntimeException, Throwable, java.lang.Error,
- * java.lang.RuntimeException, java.lang.Throwable}.
+ * Property {@code ignoreOverriddenMethods} - Allow to ignore checking overridden methods
+ * (marked with {@code Override} or {@code java.lang.Override} annotation).
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
*
*
* Property {@code ignoredMethodNames} - Specify names of methods to ignore.
@@ -52,10 +52,10 @@
* Default value is {@code finalize}.
*
*
- * Property {@code ignoreOverriddenMethods} - Allow to ignore checking overridden methods
- * (marked with {@code Override} or {@code java.lang.Override} annotation).
- * Type is {@code boolean}.
- * Default value is {@code true}.
+ * Property {@code illegalClassNames} - Specify throw class names to reject.
+ * Type is {@code java.lang.String[]}.
+ * Default value is {@code Error, RuntimeException, Throwable, java.lang.Error,
+ * java.lang.RuntimeException, java.lang.Throwable}.
*
*
*
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheck.java
index fa01f9034e0..9b9e023ba75 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheck.java
@@ -47,6 +47,11 @@
* Default value is {@code 3}.
*
*
+ * Property {@code ignoreFinal} - Allow to ignore variables with a 'final' modifier.
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
+ *
+ *
* Property {@code ignoreVariablePattern} - Define RegExp to ignore distance calculation
* for variables listed in this pattern.
* Type is {@code java.util.regex.Pattern}.
@@ -58,11 +63,6 @@
* Type is {@code boolean}.
* Default value is {@code false}.
*
- *
- * Property {@code ignoreFinal} - Allow to ignore variables with a 'final' modifier.
- * Type is {@code boolean}.
- * Default value is {@code true}.
- *
*
*
* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker}
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/IllegalThrowsCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/IllegalThrowsCheck.xml
index 524c9aadc10..c35d9194f9d 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/IllegalThrowsCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/IllegalThrowsCheck.xml
@@ -10,19 +10,19 @@
{@code java.lang.RuntimeException} is almost never acceptable.
</p>
-
- Specify throw class names to reject.
+
+ Allow to ignore checking overridden methods
+ (marked with {@code Override} or {@code java.lang.Override} annotation).Specify names of methods to ignore.
-
- Allow to ignore checking overridden methods
- (marked with {@code Override} or {@code java.lang.Override} annotation).
+
+ Specify throw class names to reject.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/VariableDeclarationUsageDistanceCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/VariableDeclarationUsageDistanceCheck.xml
index 3f717aafa8f..6222b03d4f4 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/VariableDeclarationUsageDistanceCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/VariableDeclarationUsageDistanceCheck.xml
@@ -13,6 +13,9 @@
Specify distance between declaration
of variable and its first usage. Values should be greater than 0.
+
+ Allow to ignore variables with a 'final' modifier.
+
@@ -23,9 +26,6 @@
Allow to calculate the distance between
declaration of variable and its first usage in the different scopes.
-
- Allow to ignore variables with a 'final' modifier.
-
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index dc3b6abaa90..8eea691ea6b 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -230,7 +230,6 @@ public class XdocsPagesTest {
private static final Set MODULES_WITH_UNORDERED_PROPERTIES = Set.of(
"Checker",
"MissingJavadocMethod",
- "VariableDeclarationUsageDistance",
"LocalVariableName",
"JavadocTagContinuationIndentation",
"ClassFanOutComplexity",
@@ -259,7 +258,6 @@ public class XdocsPagesTest {
"JavaNCSS",
"EmptyCatchBlock",
"ParameterName",
- "IllegalThrows",
"HiddenField",
"SuppressionXpathSingleFilter",
"WhitespaceAround",
diff --git a/src/xdocs/checks/coding/illegalthrows.xml b/src/xdocs/checks/coding/illegalthrows.xml
index a8037bd3e51..5357e190880 100644
--- a/src/xdocs/checks/coding/illegalthrows.xml
+++ b/src/xdocs/checks/coding/illegalthrows.xml
@@ -27,13 +27,14 @@
@Deprecated
public static final int MY_CONST = 13; // ok
@@ -95,18 +99,20 @@ public static final int NUM = 123456; // ok
@Deprecated
public static final int CONST = 12; // ok
-
+
To configure the check such that it prints violation
messages if tight HTML rules are not obeyed
try {
throw new RuntimeException();
@@ -161,20 +169,23 @@ try {
// This is expected
} // ok
-
+
+
To configure the check to suppress empty catch block if single-line comment inside
is "//This is expected" or exception's
variable name is "myException" (any option is matching):
+
+
+
+
-try {
- throw new RuntimeException();
-} catch (RuntimeException ex) {
- // This is expected
-} // ok
-
-
+
To configure the check to suppress empty catch block if single-line comment inside
is "//This is expected" or exception's
variable name is "myException" (any option is matching):
if (obj.isValid()) return true; // violation, single-line statements not allowed without braces
if (true) { // OK
@@ -105,16 +109,20 @@ switch (num) {
case 1: counter++; break; // OK
}
-
if (obj.isValid()) return true; // violation, single-line statements not allowed without braces
if (true) { // OK
@@ -136,21 +144,22 @@ switch (num) {
case 1: counter++; break; // OK
}
-
+
To configure the check to allow single-line statements
(if, while, do-while, for) without braces:
if (obj.isValid()) return true; // OK
if (true) { // OK
@@ -175,20 +184,22 @@ while (obj.isValid()) return true; // OK
do this.notify(); while (o != null); // OK
for (int i = 0; ; ) this.notify(); // OK
-
-
+
To configure the check to allow case, default single-line statements
without braces:
class Test {
diff --git a/src/xdocs/checks/blocks/rightcurly.xml.template b/src/xdocs/checks/blocks/rightcurly.xml.template
index 7291080df2b..725da66164f 100644
--- a/src/xdocs/checks/blocks/rightcurly.xml.template
+++ b/src/xdocs/checks/blocks/rightcurly.xml.template
@@ -103,223 +103,87 @@
-
To configure the check:
-
-<module name="RightCurly"/>
-
-
-
Example:
-
-public class Test {
-
- public void test() {
-
- if (foo) {
- bar();
- } // violation, right curly must be in the same line as the 'else' keyword
- else {
- bar();
- }
-
- if (foo) {
- bar();
- } else { // OK
- bar();
- }
-
- if (foo) { bar(); } int i = 0; // violation
- // ^^^ statement is not allowed on same line after curly right brace
-
- if (foo) { bar(); } // OK
- int i = 0;
-
- try {
- bar();
- } // violation, rightCurly must be in the same line as 'catch' keyword
- catch (Exception e) {
- bar();
- }
-
- try {
- bar();
- } catch (Exception e) { // OK
- bar();
- }
-
- } // OK
-
- public void testSingleLine() { bar(); } // OK, because singleline is allowed
-}
-
-
-
+
To configure the check:
+
+
+
+
+
Example:
+
+
+
+
+
To configure the check with policy alone for else and
METHOD_DEF
tokens:
-
-public class Test {
-
- public void test() {
-
- if (foo) {
- bar();
- } else { bar(); } // violation, right curly must be alone on line
-
- if (foo) {
- bar();
- } else {
- bar();
- } // OK
-
- try {
- bar();
- } catch (Exception e) { // OK because config is set to token METHOD_DEF and LITERAL_ELSE
- bar();
- }
-
- } // OK
-
- public void violate() { bar; } // violation, singleline is not allowed here
-
- public void ok() {
- bar();
- } // OK
-}
-
-
+
+
+
+
+
Example:
+
+
+
+
+
To configure the check with policy alone for
Switch
Statements:
-
-<module name="RightCurly">
- <property name="option" value="alone"/>
- <property name="tokens" value="LITERAL_SWITCH"/>
-</module>
-
-
-
-class Test {
-
- public void method0() {
- int mode = 0;
- switch (mode) {
- case 1:
- int x = 1;
- break;
- default:
- x = 0;
- } // ok, RightCurly is alone
- }
-
- public void method0() {
- int mode = 0;
- switch (mode) {
- case 1:
- int x = 1;
- break;
- default:
- x = 0; } // violation, RightCurly should be alone on a line
- }
-
-}
-
-
+
+
+
+
+
Example:
+
+
+
+
+
To configure the check with policy alone_or_singleline for if
and
METHOD_DEF
tokens:
-
-public class Test {
-
- public void test() {
-
- if (foo) {
- bar();
- } else { // violation, right curly must be alone on line
- bar();
- }
-
- if (foo) {
- bar();
- } // OK
- else {
- bar();
- }
-
- try {
- bar();
- } catch (Exception e) { // OK because config did not set token LITERAL_TRY
- bar();
- }
-
- } // OK
-
- public void violate() { bar(); } // OK , because singleline
-}
-
-
+
+
+
+
+
Example:
+
+
+
+
+
To configure the check with policy alone_or_singleline for
Switch
Statements:
-
-<module name="RightCurly">
- <property name="option" value="alone_or_singleline"/>
- <property name="tokens" value="LITERAL_SWITCH"/>
-</module>
-
-
-class Test {
-
- public void method0() {
- int mode = 0;
- switch (mode) {
- case 1:
- int x = 1;
- break;
- default:
- x = 0;
- } // ok
- }
-
- public static void method7() {
- int mode = 0;
- int x;
- switch (mode) { case 1: x = 5; } // ok, RightCurly is on the same line as LeftCurly
- }
-
- public void method() {
- int mode = 0;
- int x;
- switch (mode) {
- case 1:
- x = 1; } // violation, right curly should be alone on line
- }
-}
-
+
+
+
+
+
Example:
+
+
+
+
diff --git a/src/xdocs/checks/design/designforextension.xml b/src/xdocs/checks/design/designforextension.xml
index f4dd1ee1134..161b2e7ba47 100644
--- a/src/xdocs/checks/design/designforextension.xml
+++ b/src/xdocs/checks/design/designforextension.xml
@@ -159,14 +159,19 @@ public abstract class Plant {
+
-
public abstract class Foo {
private int bar;
@@ -297,17 +313,22 @@ public abstract class Foo {
}
}
-
+
+
To configure the check to allow methods which contain a specified comment text pattern in
their javadoc which can span multiple lines to be designed for extension.
public abstract class Foo {
private int bar;
diff --git a/src/xdocs/checks/design/designforextension.xml.template b/src/xdocs/checks/design/designforextension.xml.template
index 6300cc4b320..44049f01966 100644
--- a/src/xdocs/checks/design/designforextension.xml.template
+++ b/src/xdocs/checks/design/designforextension.xml.template
@@ -159,192 +159,70 @@ public abstract class Plant {
+
-
+
To configure the check:
-
-<module name="DesignForExtension"/>
-
-
Example:
-
-public abstract class Foo {
- private int bar;
-
- public int m1() {return 2;} // Violation. No javadoc.
-
- public int m2() {return 8;} // Violation. No javadoc.
-
- private void m3() {m4();} // OK. Private method.
-
- protected void m4() { } // OK. No implementation.
-
- public abstract void m5(); // OK. Abstract method.
-
- /**
- * This implementation ...
- @return some int value.
- */
- public int m6() {return 1;} // OK. Have javadoc on overridable method.
-
- /**
- * Some comments ...
- */
- public int m7() {return 1;} // OK. Have javadoc on overridable method.
-
- /**
- * This
- * implementation ...
- */
- public int m8() {return 2;} // OK. Have javadoc on overridable method.
+
+
+
+
+
Example:
+
+
+
+
- @Override
- public String toString() { // Violation. No javadoc for @Override method.
- return "";
- }
-}
-
-
+
To configure the check to allow methods which have @Override annotations to be
designed for extension.
-
-public abstract class Foo {
- private int bar;
-
- public int m1() {return 2;} // Violation. No javadoc.
-
- public int m2() {return 8;} // Violation. No javadoc.
-
- private void m3() {m4();} // OK. Private method.
-
- protected void m4() { } // OK. No implementation.
-
- public abstract void m5(); // OK. Abstract method.
-
- /**
- * This implementation ...
- @return some int value.
- */
- public int m6() {return 1;} // OK. Have javadoc on overridable method.
-
- /**
- * Some comments ...
- */
- public int m7() {return 1;} // OK. Have javadoc on overridable method.
-
- /**
- * This
- * implementation ...
- */
- public int m8() {return 2;} // OK. Have javadoc on overridable method.
+
+
+
+
+
Example:
+
+
+
+
- @Override
- public String toString() { // OK. Have javadoc on overridable method.
- return "";
- }
-}
-
-
To configure the check to allow methods which contain a specified comment text pattern in
+
+ To configure the check to allow methods which contain a specified comment text pattern in
their javadoc to be designed for extension.
-
-public abstract class Foo {
- private int bar;
-
- public int m1() {return 2;} // Violation. No javadoc.
-
- public int m2() {return 8;} // Violation. No javadoc.
-
- private void m3() {m4();} // OK. Private method.
-
- protected void m4() { } // OK. No implementation.
-
- public abstract void m5(); // OK. Abstract method.
-
- /**
- * This implementation ...
- @return some int value.
- */
- public int m6() {return 1;} // OK. Have required javadoc.
-
- /**
- * Some comments ...
- */
- public int m7() {return 1;} // Violation. No required javadoc.
-
- /**
- * This
- * implementation ...
- */
- public int m8() {return 2;} // Violation. No required javadoc.
+
+
+
+
+
To configure the check to allow methods which contain a specified comment text pattern in
their javadoc which can span multiple lines to be designed for extension.
-final class MyClass { // OK
- private MyClass() { }
-}
-
-class MyClass { // violation, class should be declared final
- private MyClass() { }
-}
+public class Example1 { // ok, since it has a public constructor
-class MyClass { // OK, since it has a public constructor
- int field1;
- String field2;
- private MyClass(int value) {
- this.field1 = value;
- this.field2 = " ";
+ final class A {
+ private A() {
+ }
}
- public MyClass(String value) {
- this.field2 = value;
- this.field1 = 0;
+
+ class B { // violation, 'Class B should be declared as final.'
+ private B() {
+ }
}
-}
-class TestAnonymousInnerClasses { // OK, class has an anonymous inner class.
- public static final TestAnonymousInnerClasses ONE = new TestAnonymousInnerClasses() {
+ class C { // ok, since it has a public constructor
+ int field1;
+ String field2;
- };
+ private C(int value) {
+ this.field1 = value;
+ this.field2 = " ";
+ }
- private TestAnonymousInnerClasses() {
+ public C(String value) {
+ this.field2 = value;
+ this.field1 = 0;
}
-}
+ }
-class Class1 {
+ class AnonymousInner { // ok, class has an anonymous inner class.
+ public final AnonymousInner ONE
+ = new AnonymousInner() {
+ };
- private class Class2 { // violation, class should be declared final
+ private AnonymousInner() {
}
+ }
+
+ class Class1 {
- public class Class3 { // ok
+ private class Class2 { // violation, 'Class Class2 should be declared as final'
}
-}
+ public class Class3 {
+ }
+ }
+}
diff --git a/src/xdocs/checks/design/finalclass.xml.template b/src/xdocs/checks/design/finalclass.xml.template
index c010c3bddc0..ccb1e9c6654 100644
--- a/src/xdocs/checks/design/finalclass.xml.template
+++ b/src/xdocs/checks/design/finalclass.xml.template
@@ -35,57 +35,20 @@
-
+
To configure the check:
-
-<module name="FinalClass"/>
-
-
- Example:
-
-
-final class MyClass { // OK
- private MyClass() { }
-}
-
-class MyClass { // violation, class should be declared final
- private MyClass() { }
-}
-
-class MyClass { // OK, since it has a public constructor
- int field1;
- String field2;
- private MyClass(int value) {
- this.field1 = value;
- this.field2 = " ";
- }
- public MyClass(String value) {
- this.field2 = value;
- this.field1 = 0;
- }
-}
-
-class TestAnonymousInnerClasses { // OK, class has an anonymous inner class.
- public static final TestAnonymousInnerClasses ONE = new TestAnonymousInnerClasses() {
-
- };
-
- private TestAnonymousInnerClasses() {
- }
-}
-
-class Class1 {
-
- private class Class2 { // violation, class should be declared final
- }
-
- public class Class3 { // ok
- }
-
-}
-
-
+
+
+
+
+
Example:
+
+
+
+
diff --git a/src/xdocs/checks/design/hideutilityclassconstructor.xml b/src/xdocs/checks/design/hideutilityclassconstructor.xml
index 541a77233ab..74bf4fa3ac2 100644
--- a/src/xdocs/checks/design/hideutilityclassconstructor.xml
+++ b/src/xdocs/checks/design/hideutilityclassconstructor.xml
@@ -43,15 +43,17 @@ public class StringUtils // not final to allow subclassing
-
class Test { // violation, class only has a static method and a constructor
diff --git a/src/xdocs/checks/design/hideutilityclassconstructor.xml.template b/src/xdocs/checks/design/hideutilityclassconstructor.xml.template
index e93be91cb48..5094c4d680e 100644
--- a/src/xdocs/checks/design/hideutilityclassconstructor.xml.template
+++ b/src/xdocs/checks/design/hideutilityclassconstructor.xml.template
@@ -43,46 +43,20 @@ public class StringUtils // not final to allow subclassing
-
-
-class Test { // violation, class only has a static method and a constructor
-
- public Test() {
- }
-
- public static void fun() {
- }
-}
-
-class Foo { // OK
-
- private Foo() {
- }
-
- static int n;
-}
-
-class Bar { // OK
-
- protected Bar() {
- // prevents calls from subclass
- throw new UnsupportedOperationException();
- }
-}
-
-class UtilityClass { // violation, class only has a static field
-
- static float f;
-}
-
+
+
+
+
+
- * Property {@code option} - specify the policy on block contents.
+ * Property {@code option} - Specify the policy on block contents.
* Type is {@code com.puppycrawl.tools.checkstyle.checks.blocks.BlockOption}.
* Default value is {@code statement}.
*
- * Property {@code option} - specify policy on the relative order between type imports and static
+ * Property {@code option} - Specify policy on the relative order between type imports and static
* imports.
* Type is {@code com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderOption}.
* Default value is {@code under}.
*
*
- * Property {@code groups} - specify list of type import groups. Every group identified
+ * Property {@code groups} - Specify list of type import groups. Every group identified
* either by a common prefix string, or by a regular expression enclosed in forward slashes
* (e.g. {@code /regexp/}). All type imports, which does not match any group, falls into an
* additional group, located at the end.
@@ -76,21 +76,21 @@
* Default value is {@code ""}.
*
*
- * Property {@code ordered} - control whether type imports within each group should be
+ * Property {@code ordered} - Control whether type imports within each group should be
* sorted.
* It doesn't affect sorting for static imports.
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
- * Property {@code separated} - control whether type import groups should be separated
+ * Property {@code separated} - Control whether type import groups should be separated
* by, at least, one blank line or comment and aren't separated internally.
* It doesn't affect separations for static imports.
* Type is {@code boolean}.
* Default value is {@code false}.
*
*
- * Property {@code separatedStaticGroups} - control whether static import groups should
+ * Property {@code separatedStaticGroups} - Control whether static import groups should
* be separated by, at least, one blank line or comment and aren't separated internally.
* This property has effect only when the property {@code option} is set to {@code top}
* or {@code bottom} and when property {@code staticGroups} is enabled.
@@ -98,7 +98,7 @@
* Default value is {@code false}.
*
*
- * Property {@code caseSensitive} - control whether string comparison should be
+ * Property {@code caseSensitive} - Control whether string comparison should be
* case-sensitive or not. Case-sensitive sorting is in
* ASCII sort order.
* It affects both type imports and static imports.
@@ -106,7 +106,7 @@
* Default value is {@code true}.
*
*
- * Property {@code staticGroups} - specify list of static import groups. Every group
+ * Property {@code staticGroups} - Specify list of static import groups. Every group
* identified either by a common prefix string, or by a regular expression enclosed in forward
* slashes (e.g. {@code /regexp/}). All static imports, which does not match any group, fall into
* an additional group, located at the end. Thus, the empty list of static groups (the default
@@ -116,13 +116,13 @@
* Default value is {@code ""}.
*
*
- * Property {@code sortStaticImportsAlphabetically} - control whether
+ * Property {@code sortStaticImportsAlphabetically} - Control whether
* static imports located at top or bottom are sorted within the group.
* Type is {@code boolean}.
* Default value is {@code false}.
*
*
- * Property {@code useContainerOrderingForStatic} - control whether to use container
+ * Property {@code useContainerOrderingForStatic} - Control whether to use container
* ordering (Eclipse IDE term) for static imports or not.
* Type is {@code boolean}.
* Default value is {@code false}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck.java
index 1523da9541b..64d6a0f4110 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck.java
@@ -98,7 +98,7 @@
* Default value is {@code false}.
*
*
- * Property {@code ignoreMethodNamesRegex} - ignore method whose names are matching specified
+ * Property {@code ignoreMethodNamesRegex} - Ignore method whose names are matching specified
* regex.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code null}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck.java
index 6fae53c4600..64f86b541da 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck.java
@@ -41,18 +41,18 @@
*
*
*
- * Property {@code scope} - specify the visibility scope where Javadoc comments are checked.
+ * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked.
* Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
* Default value is {@code public}.
*
*
- * Property {@code excludeScope} - specify the visibility scope where Javadoc comments are not
+ * Property {@code excludeScope} - Specify the visibility scope where Javadoc comments are not
* checked.
* Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
* Default value is {@code null}.
*
*
- * Property {@code skipAnnotations} - specify annotations that allow missed
+ * Property {@code skipAnnotations} - Specify annotations that allow missed
* documentation. If annotation is present in target sources in multiple forms of qualified
* name, all forms should be listed in this property.
* Type is {@code java.lang.String[]}.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/EmptyBlockCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/EmptyBlockCheck.xml
index bca8b931f7c..285795a6f2b 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/EmptyBlockCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/EmptyBlockCheck.xml
@@ -26,7 +26,7 @@
- specify the policy on block contents.
+ Specify the policy on block contents.
- allow single-line statements without braces.
+ Allow single-line statements without braces.
- allow loops with empty bodies.
+ Allow loops with empty bodies.
- specify policy on the relative order between type imports and static
+ Specify policy on the relative order between type imports and static
imports.
- specify list of <b>type import</b> groups. Every group identified
+ Specify list of <b>type import</b> groups. Every group identified
either by a common prefix string, or by a regular expression enclosed in forward slashes
(e.g. {@code /regexp/}). All type imports, which does not match any group, falls into an
additional group, located at the end.
Thus, the empty list of type groups (the default value) means one group for all type imports.
- control whether type imports within each group should be
+ Control whether type imports within each group should be
sorted.
It doesn't affect sorting for static imports.
- control whether type import groups should be separated
+ Control whether type import groups should be separated
by, at least, one blank line or comment and aren't separated internally.
It doesn't affect separations for static imports.
- control whether static import groups should
+ Control whether static import groups should
be separated by, at least, one blank line or comment and aren't separated internally.
This property has effect only when the property {@code option} is set to {@code top}
or {@code bottom} and when property {@code staticGroups} is enabled.
- control whether string comparison should be
+ Control whether string comparison should be
case-sensitive or not. Case-sensitive sorting is in
<a href="https://en.wikipedia.org/wiki/ASCII#Order">ASCII sort order</a>.
It affects both type imports and static imports.
@@ -72,7 +72,7 @@
- specify list of <b>static</b> import groups. Every group
+ Specify list of <b>static</b> import groups. Every group
identified either by a common prefix string, or by a regular expression enclosed in forward
slashes (e.g. {@code /regexp/}). All static imports, which does not match any group, fall into
an additional group, located at the end. Thus, the empty list of static groups (the default
@@ -82,13 +82,13 @@
- control whether
+ Control whether
<b>static imports</b> located at <b>top</b> or <b>bottom</b> are sorted within the group.
- control whether to use container
+ Control whether to use container
ordering (Eclipse IDE term) for static imports or not.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocMethodCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocMethodCheck.xml
index 008d3bc840b..068bc58e4ab 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocMethodCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocMethodCheck.xml
@@ -63,7 +63,7 @@
accessor methods for properties (setters and getters).
- ignore method whose names are matching specified
+ Ignore method whose names are matching specified
regex.
- specify the visibility scope where Javadoc comments are checked.
+ Specify the visibility scope where Javadoc comments are checked.
- specify the visibility scope where Javadoc comments are not
+ Specify the visibility scope where Javadoc comments are not
checked.
- specify annotations that allow missed
+ Specify annotations that allow missed
documentation. If annotation is present in target sources in multiple forms of qualified
name, all forms should be listed in this property.
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index 8eea691ea6b..7efe8b2d44f 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -1067,6 +1067,11 @@ private static void validatePropertySectionPropertyEx(String fileName, String se
fileName, sectionName, propertyName)
.that(columns.get(1).getTextContent().trim())
.isNotEmpty();
+ assertWithMessage("%s section '%s' should have a description for %s"
+ + " that starts with uppercase character",
+ fileName, sectionName, propertyName)
+ .that(Character.isUpperCase(columns.get(1).getTextContent().trim().charAt(0)))
+ .isTrue();
final String actualTypeName = columns.get(2).getTextContent().replace("\n", "")
.replace("\r", "").replaceAll(" +", " ").trim();
diff --git a/src/xdocs/checks/blocks/emptyblock.xml b/src/xdocs/checks/blocks/emptyblock.xml
index 0bb490818d5..39a807f5bee 100644
--- a/src/xdocs/checks/blocks/emptyblock.xml
+++ b/src/xdocs/checks/blocks/emptyblock.xml
@@ -39,7 +39,7 @@ switch (a) {
- specify list of type import groups. Every group identified either by a
+ Specify list of type import groups. Every group identified either by a
common prefix string, or by a regular expression enclosed
in forward slashes (e.g. /regexp/). All type imports,
which does not match any group, falls into an additional group, located at the end.
@@ -66,7 +66,7 @@
ordered
-
control whether type imports within each group should be sorted.
+
Control whether type imports within each group should be sorted.
It doesn't affect sorting for static imports.
- control whether type import groups should be separated by, at least, one
+ Control whether type import groups should be separated by, at least, one
blank line or comment and aren't separated internally.
It doesn't affect separations for static imports.
@@ -86,7 +86,7 @@
separatedStaticGroups
- control whether static import groups should be separated by, at least, one
+ Control whether static import groups should be separated by, at least, one
blank line or comment and aren't separated internally.
This property has effect only when the property option
is set to top or bottom and when property
@@ -98,7 +98,7 @@
caseSensitive
-
control whether string comparison should be case-sensitive or not.
+
Control whether string comparison should be case-sensitive or not.
Case-sensitive sorting is in
ASCII sort order.
It affects both type imports and static imports.
@@ -110,7 +110,7 @@
staticGroups
- specify list of static import groups. Every group identified either by a
+ Specify list of static import groups. Every group identified either by a
common prefix string, or by a regular expression enclosed
in forward slashes (e.g. /regexp/). All static imports,
which does not match any group, fall into an additional group, located at the
@@ -126,7 +126,7 @@
sortStaticImportsAlphabetically
- control whether static imports located at top or
+ Control whether static imports located at top or
bottom are sorted within the group.
- control whether to use container ordering (Eclipse IDE term) for static
+ Control whether to use container ordering (Eclipse IDE term) for static
imports or not.
- specify list of type import groups. Every group identified either by a
+ Specify list of type import groups. Every group identified either by a
common prefix string, or by a regular expression enclosed
in forward slashes (e.g. /regexp/). All type imports,
which does not match any group, falls into an additional group, located at the end.
@@ -66,7 +66,7 @@
ordered
-
control whether type imports within each group should be sorted.
+
Control whether type imports within each group should be sorted.
It doesn't affect sorting for static imports.
- control whether type import groups should be separated by, at least, one
+ Control whether type import groups should be separated by, at least, one
blank line or comment and aren't separated internally.
It doesn't affect separations for static imports.
@@ -86,7 +86,7 @@
separatedStaticGroups
- control whether static import groups should be separated by, at least, one
+ Control whether static import groups should be separated by, at least, one
blank line or comment and aren't separated internally.
This property has effect only when the property option
is set to top or bottom and when property
@@ -98,7 +98,7 @@
caseSensitive
-
control whether string comparison should be case-sensitive or not.
+
Control whether string comparison should be case-sensitive or not.
Case-sensitive sorting is in
ASCII sort order.
It affects both type imports and static imports.
@@ -110,7 +110,7 @@
staticGroups
- specify list of static import groups. Every group identified either by a
+ Specify list of static import groups. Every group identified either by a
common prefix string, or by a regular expression enclosed
in forward slashes (e.g. /regexp/). All static imports,
which does not match any group, fall into an additional group, located at the
@@ -126,7 +126,7 @@
sortStaticImportsAlphabetically
- control whether static imports located at top or
+ Control whether static imports located at top or
bottom are sorted within the group.
- control whether to use container ordering (Eclipse IDE term) for static
+ Control whether to use container ordering (Eclipse IDE term) for static
imports or not.
- specify annotations that allow missed documentation.
+ Specify annotations that allow missed documentation.
If annotation is present in target sources in multiple forms of qualified
name, all forms should be listed in this property.
- specify annotations that allow missed documentation.
+ Specify annotations that allow missed documentation.
If annotation is present in target sources in multiple forms of qualified
name, all forms should be listed in this property.
file type extension to identify Java files. Setting this
+
File type extension to identify Java files. Setting this
property is typically only required if your Java source code
is preprocessed before compilation and the original files do
not have the extension .java
-@Deprecated
-public static final int MY_CONST = 13; // ok
+class Example1 {
+ @Deprecated
+ public static final int MY_CONST = 13; // ok
-/** This javadoc is missing deprecated tag. */
-@Deprecated
-public static final int COUNTER = 10; // violation
+ /** This javadoc is missing deprecated tag. */
+ // violation below '@deprecated Javadoc tag with description.'
+ @Deprecated
+ public static final int COUNTER = 10;
-/**
- * @deprecated
- * <p></p>
- */
-@Deprecated
-public static final int NUM = 123456; // ok
+ /**
+ * @deprecated
+ * <p></p>
+ */
+ @Deprecated
+ public static final int NUM = 123456; // ok
-/**
- * @deprecated
- * <p>
- */
-@Deprecated
-public static final int CONST = 12; // ok
+ /**
+ * @deprecated
+ * <p>
+ */
+ @Deprecated
+ public static final int CONST = 12; // ok
+}
+
To configure the check such that it prints violation
messages if tight HTML rules are not obeyed
@@ -114,26 +120,29 @@ public static final int CONST = 12; // ok
Example:
-@Deprecated
-public static final int MY_CONST = 13; // ok
+class Example2 {
+ @Deprecated
+ public static final int MY_CONST = 13; // ok
-/** This javadoc is missing deprecated tag. */
-@Deprecated
-public static final int COUNTER = 10; // violation
+ /** This javadoc is missing deprecated tag. */
+ // violation below '@deprecated Javadoc tag with description.'
+ @Deprecated
+ public static final int COUNTER = 10;
-/**
- * @deprecated
- * <p></p>
- */
-@Deprecated
-public static final int NUM = 123456; // ok
+ /**
+ * @deprecated
+ * <p></p>
+ */
+ @Deprecated
+ public static final int NUM = 123456; // ok
-/**
- * @deprecated
- * <p>
- */
-@Deprecated
-public static final int CONST = 12; // violation, tight HTML rules not obeyed
+ /**
+ * @deprecated
+ * <p> // violation, 'javadoc.unclosedHtml'
+ */
+ @Deprecated
+ public static final int CONST = 12;
+}
diff --git a/src/xdocs/checks/annotation/missingdeprecated.xml.template b/src/xdocs/checks/annotation/missingdeprecated.xml.template
index 169be2e385c..8ea2b6e227e 100644
--- a/src/xdocs/checks/annotation/missingdeprecated.xml.template
+++ b/src/xdocs/checks/annotation/missingdeprecated.xml.template
@@ -55,31 +55,34 @@
-
To configure the check:
+
+ To configure the check:
+
-
-
+
+
Example:
-
+
+
To configure the check such that it prints violation
messages if tight HTML rules are not obeyed
- * Property {@code packageAllowed} - Control whether package visible members are allowed.
- * Type is {@code boolean}.
- * Default value is {@code false}.
- *
- *
- * Property {@code protectedAllowed} - Control whether protected members are allowed.
- * Type is {@code boolean}.
- * Default value is {@code false}.
- *
- *
- * Property {@code publicMemberPattern} - Specify pattern for public members that should be ignored.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "^serialVersionUID$"}.
- *
- *
* Property {@code allowPublicFinalFields} - Allow final fields to be declared as public.
* Type is {@code boolean}.
* Default value is {@code false}.
@@ -131,6 +116,13 @@
* Default value is {@code false}.
*
*
+ * Property {@code ignoreAnnotationCanonicalNames} - Specify annotations canonical
+ * names which ignore variables in consideration.
+ * Type is {@code java.lang.String[]}.
+ * Default value is {@code com.google.common.annotations.VisibleForTesting,
+ * org.junit.ClassRule, org.junit.Rule}.
+ *
+ *
* Property {@code immutableClassCanonicalNames} - Specify immutable classes canonical names.
* Type is {@code java.lang.String[]}.
* Default value is {@code java.io.File, java.lang.Boolean, java.lang.Byte,
@@ -140,11 +132,19 @@
* java.net.InetSocketAddress, java.net.URI, java.net.URL, java.util.Locale, java.util.UUID}.
*
*
- * Property {@code ignoreAnnotationCanonicalNames} - Specify annotations canonical
- * names which ignore variables in consideration.
- * Type is {@code java.lang.String[]}.
- * Default value is {@code com.google.common.annotations.VisibleForTesting,
- * org.junit.ClassRule, org.junit.Rule}.
+ * Property {@code packageAllowed} - Control whether package visible members are allowed.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
+ *
+ *
+ * Property {@code protectedAllowed} - Control whether protected members are allowed.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
+ *
+ *
+ * Property {@code publicMemberPattern} - Specify pattern for public members that should be ignored.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "^serialVersionUID$"}.
*
- * Property {@code allowedAnnotations} - Specify annotations that allow missed documentation.
- * Type is {@code java.lang.String[]}.
- * Default value is {@code Override}.
- *
- *
- * Property {@code validateThrows} - Control whether to validate {@code throws} tags.
- * Type is {@code boolean}.
- * Default value is {@code false}.
- *
- *
* Property {@code accessModifiers} - Specify the access modifiers where Javadoc comments are
* checked.
* Type is {@code com.puppycrawl.tools.checkstyle.checks.naming.AccessModifierOption[]}.
@@ -130,6 +120,16 @@
* Default value is {@code false}.
*
*
+ * Property {@code allowedAnnotations} - Specify annotations that allow missed documentation.
+ * Type is {@code java.lang.String[]}.
+ * Default value is {@code Override}.
+ *
+ *
+ * Property {@code validateThrows} - Control whether to validate {@code throws} tags.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
+ *
+ *
* Property {@code tokens} - tokens to check
* Type is {@code java.lang.String[]}.
* Validation type is {@code tokenSet}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck.java
index aaf3b82766e..26761c661de 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck.java
@@ -43,13 +43,6 @@
*
*
*
- * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations
- * if the Javadoc being examined by this check violates the tight html rules defined at
- * Tight-HTML Rules.
- * Type is {@code boolean}.
- * Default value is {@code false}.
- *
- *
* Property {@code forbiddenSummaryFragments} - Specify the regexp for forbidden summary fragments.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^$"}.
@@ -59,6 +52,13 @@
* Type is {@code java.lang.String}.
* Default value is {@code "."}.
*
+ *
+ * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations
+ * if the Javadoc being examined by this check violates the tight html rules defined at
+ * Tight-HTML Rules.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
+ *
- * Property {@code max} - Specify the maximum threshold allowed.
- * Type is {@code int}.
- * Default value is {@code 7}.
+ * Property {@code excludeClassesRegexps} - Specify user-configured regular
+ * expressions to ignore classes.
+ * Type is {@code java.util.regex.Pattern[]}.
+ * Default value is {@code ^$}.
*
*
* Property {@code excludedClasses} - Specify user-configured class names to ignore.
@@ -98,16 +99,15 @@
* float, int, long, short, var, void}.
*
*
- * Property {@code excludeClassesRegexps} - Specify user-configured regular
- * expressions to ignore classes.
- * Type is {@code java.util.regex.Pattern[]}.
- * Default value is {@code ^$}.
- *
- *
* Property {@code excludedPackages} - Specify user-configured packages to ignore.
* Type is {@code java.lang.String[]}.
* Default value is {@code ""}.
*
+ *
+ * Property {@code max} - Specify the maximum threshold allowed.
+ * Type is {@code int}.
+ * Default value is {@code 7}.
+ *
- * Property {@code max} - Specify the maximum number of lines allowed.
- * Type is {@code int}.
- * Default value is {@code 150}.
- *
- *
* Property {@code countEmpty} - Control whether to count empty lines and comments.
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
+ * Property {@code max} - Specify the maximum number of lines allowed.
+ * Type is {@code int}.
+ * Default value is {@code 150}.
+ *
+ *
* Property {@code tokens} - tokens to check
* Type is {@code java.lang.String[]}.
* Validation type is {@code tokenSet}.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/design/VisibilityModifierCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/design/VisibilityModifierCheck.xml
index 51e97ff2d3e..366d35689f1 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/design/VisibilityModifierCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/design/VisibilityModifierCheck.xml
@@ -71,17 +71,6 @@
won't be Check's violation.
</p>
-
- Control whether package visible members are allowed.
-
-
- Control whether protected members are allowed.
-
-
- Specify pattern for public members that should be ignored.
- Allow final fields to be declared as public.
@@ -91,17 +80,28 @@
Allow immutable fields to be
declared as public if defined in final class.
-
- Specify immutable classes canonical names.
- Specify annotations canonical
names which ignore variables in consideration.
+
+ Specify immutable classes canonical names.
+
+
+ Control whether package visible members are allowed.
+
+
+ Control whether protected members are allowed.
+
+
+ Specify pattern for public members that should be ignored.
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocMethodCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocMethodCheck.xml
index 75c76bef359..0df3192a73d 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocMethodCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocMethodCheck.xml
@@ -61,14 +61,6 @@
int aLineNo)
</pre>
-
- Specify annotations that allow missed documentation.
-
-
- Control whether to validate {@code throws} tags.
-
@@ -83,6 +75,14 @@
Control whether to ignore violations
when a method returns non-void type and does not have a {@code return} tag in the javadoc.
+
+ Specify annotations that allow missed documentation.
+
+
+ Control whether to validate {@code throws} tags.
+
-
- Control when to print violations
- if the Javadoc being examined by this check violates the tight html rules defined at
- <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>.
-
@@ -29,6 +22,13 @@
Specify the period symbol at the end of first javadoc sentence.
+
+ Control when to print violations
+ if the Javadoc being examined by this check violates the tight html rules defined at
+ <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>.
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/metrics/ClassDataAbstractionCouplingCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/metrics/ClassDataAbstractionCouplingCheck.xml
index dc618c74d0d..b2d9c4fadbd 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/metrics/ClassDataAbstractionCouplingCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/metrics/ClassDataAbstractionCouplingCheck.xml
@@ -61,23 +61,23 @@
</li>
</ol>
-
- Specify the maximum threshold allowed.
-
-
- Specify user-configured class names to ignore.
- Specify user-configured regular
expressions to ignore classes.
+
+ Specify user-configured class names to ignore.
+ Specify user-configured packages to ignore.
+
+ Specify the maximum threshold allowed.
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/sizes/MethodLengthCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/sizes/MethodLengthCheck.xml
index dc4d11ce59d..68fae374e82 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/sizes/MethodLengthCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/sizes/MethodLengthCheck.xml
@@ -13,12 +13,12 @@
individual methods that focus on a specific task.
</p>
-
- Specify the maximum number of lines allowed.
- Control whether to count empty lines and comments.
+
+ Specify the maximum number of lines allowed.
+ default value
since
-
-
packageAllowed
-
Control whether package visible members are allowed.
diff --git a/src/xdocs/checks/javadoc/javadocmethod.xml b/src/xdocs/checks/javadoc/javadocmethod.xml
index 116856fac60..be6dba92856 100644
--- a/src/xdocs/checks/javadoc/javadocmethod.xml
+++ b/src/xdocs/checks/javadoc/javadocmethod.xml
@@ -93,20 +93,6 @@ public int checkReturnTag(final int aTagIndex,
default value
since
-
-
allowedAnnotations
-
Specify annotations that allow missed documentation.
diff --git a/src/xdocs/checks/javadoc/javadocmethod.xml.template b/src/xdocs/checks/javadoc/javadocmethod.xml.template
index 2469aa36f74..542ddc9ddf8 100644
--- a/src/xdocs/checks/javadoc/javadocmethod.xml.template
+++ b/src/xdocs/checks/javadoc/javadocmethod.xml.template
@@ -93,20 +93,6 @@ public int checkReturnTag(final int aTagIndex,
default value
since
-
-
allowedAnnotations
-
Specify annotations that allow missed documentation.
From 70d7213b7ab3cbb7d4cb2480e0b91ae809affcc7 Mon Sep 17 00:00:00 2001
From: Nick Mancuso
Date: Sat, 9 Sep 2023 08:18:40 -0400
Subject: [PATCH 078/833] Issue #13175: Extend generate-extra-site-links.sh to
not include deleted pages in comments
---
.ci/generate-extra-site-links.sh | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/.ci/generate-extra-site-links.sh b/.ci/generate-extra-site-links.sh
index 3b934ed78bd..40d354e8a2c 100755
--- a/.ci/generate-extra-site-links.sh
+++ b/.ci/generate-extra-site-links.sh
@@ -18,12 +18,19 @@ checkForVariable "REPOSITORY_OWNER"
echo "PR_NUMBER=$PR_NUMBER"
echo "AWS_FOLDER_LINK=$AWS_FOLDER_LINK"
-# Extract a list of the changed xdocs in the pull request. For example 'src/xdocs/config_misc.xml'.
-CHANGED_XDOCS_PATHS=$(curl --fail-with-body -Ls \
+GITHUB_API_RESPONSE=$(curl --fail-with-body -Ls \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
- "https://api.github.com/repos/$REPOSITORY_OWNER/checkstyle/pulls/$PR_NUMBER/files?per_page=100" |
- jq -r ".[] | .filename" | grep src/xdocs/ || true)
+ "https://api.github.com/repos/$REPOSITORY_OWNER/checkstyle/pulls/$PR_NUMBER/files?per_page=100")
+echo "GITHUB_API_RESPONSE=$GITHUB_API_RESPONSE"
+
+# Extract a list of the changed xdocs in the pull request. For example 'src/xdocs/config_misc.xml'.
+# We ignore template files and deleted files.
+CHANGED_XDOCS_PATHS=$(echo "$GITHUB_API_RESPONSE" \
+ | jq -r '.[] | select(.status != "removed") | .filename' \
+ | grep src/xdocs/ \
+ | grep -v '.*xml.template$' \
+ || true)
echo "CHANGED_XDOCS_PATHS=$CHANGED_XDOCS_PATHS"
if [[ -z "$CHANGED_XDOCS_PATHS" ]]; then
From ccc12eb6d7f6c8e0876077e7883cf8f59a541a37 Mon Sep 17 00:00:00 2001
From: Roman Ivanov
Date: Tue, 19 Sep 2023 05:11:57 -0700
Subject: [PATCH 079/833] Issue #13666: fix ordering of properties in few
modules
---
...avadocTagContinuationIndentationCheck.java | 10 ++---
.../javadoc/MissingJavadocMethodCheck.java | 30 ++++++-------
.../metrics/ClassFanOutComplexityCheck.java | 18 ++++----
.../checks/naming/LocalVariableNameCheck.java | 10 ++---
...JavadocTagContinuationIndentationCheck.xml | 6 +--
.../javadoc/MissingJavadocMethodCheck.xml | 28 ++++++-------
.../metrics/ClassFanOutComplexityCheck.xml | 16 +++----
.../checks/naming/LocalVariableNameCheck.xml | 10 ++---
.../checkstyle/internal/XdocsPagesTest.java | 4 --
.../javadoctagcontinuationindentation.xml | 14 +++----
...doctagcontinuationindentation.xml.template | 14 +++----
.../checks/javadoc/missingjavadocmethod.xml | 42 +++++++++----------
.../javadoc/missingjavadocmethod.xml.template | 42 +++++++++----------
.../checks/metrics/classfanoutcomplexity.xml | 24 +++++------
.../classfanoutcomplexity.xml.template | 24 +++++------
src/xdocs/checks/naming/localvariablename.xml | 14 +++----
.../naming/localvariablename.xml.template | 14 +++----
17 files changed, 158 insertions(+), 162 deletions(-)
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck.java
index 1009a861834..ef22650d180 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck.java
@@ -38,17 +38,17 @@
*
*
*
+ * Property {@code offset} - Specify how many spaces to use for new indentation level.
+ * Type is {@code int}.
+ * Default value is {@code 4}.
+ *
+ *
* Property {@code violateExecutionOnNonTightHtml} - Control when to print violations
* if the Javadoc being examined by this check violates the tight html rules defined at
* Tight-HTML Rules.
* Type is {@code boolean}.
* Default value is {@code false}.
*
- *
- * Property {@code offset} - Specify how many spaces to use for new indentation level.
- * Type is {@code int}.
- * Default value is {@code 4}.
- *
- * Property {@code minLineCount} - Control the minimal amount of lines in method to allow no
- * documentation.
- * Type is {@code int}.
- * Default value is {@code -1}.
+ * Property {@code allowMissingPropertyJavadoc} - Control whether to allow missing Javadoc on
+ * accessor methods for properties (setters and getters).
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
*
*
* Property {@code allowedAnnotations} - Configure annotations that allow missed
@@ -81,29 +81,29 @@
* Default value is {@code Override}.
*
*
- * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked.
- * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
- * Default value is {@code public}.
- *
- *
* Property {@code excludeScope} - Specify the visibility scope where Javadoc comments are
* not checked.
* Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
* Default value is {@code null}.
*
*
- * Property {@code allowMissingPropertyJavadoc} - Control whether to allow missing Javadoc on
- * accessor methods for properties (setters and getters).
- * Type is {@code boolean}.
- * Default value is {@code false}.
- *
- *
* Property {@code ignoreMethodNamesRegex} - Ignore method whose names are matching specified
* regex.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code null}.
*
*
+ * Property {@code minLineCount} - Control the minimal amount of lines in method to allow no
+ * documentation.
+ * Type is {@code int}.
+ * Default value is {@code -1}.
+ *
+ *
+ * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked.
+ * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
+ * Default value is {@code public}.
+ *
+ *
* Property {@code tokens} - tokens to check
* Type is {@code java.lang.String[]}.
* Validation type is {@code tokenSet}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheck.java
index b48a8845727..21a1ef471a8 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheck.java
@@ -47,9 +47,10 @@
*
*
*
- * Property {@code max} - Specify the maximum threshold allowed.
- * Type is {@code int}.
- * Default value is {@code 20}.
+ * Property {@code excludeClassesRegexps} - Specify user-configured regular
+ * expressions to ignore classes.
+ * Type is {@code java.util.regex.Pattern[]}.
+ * Default value is {@code ^$}.
*
*
* Property {@code excludedClasses} - Specify user-configured class names to ignore.
@@ -65,17 +66,16 @@
* float, int, long, short, var, void}.
*
*
- * Property {@code excludeClassesRegexps} - Specify user-configured regular
- * expressions to ignore classes.
- * Type is {@code java.util.regex.Pattern[]}.
- * Default value is {@code ^$}.
- *
- *
* Property {@code excludedPackages} - Specify user-configured packages to ignore.
* All excluded packages should end with a period, so it also appends a dot to a package name.
* Type is {@code java.lang.String[]}.
* Default value is {@code ""}.
*
+ *
+ * Property {@code max} - Specify the maximum threshold allowed.
+ * Type is {@code int}.
+ * Default value is {@code 20}.
+ *
- * Property {@code format} - Specifies valid identifiers.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
- *
- *
* Property {@code allowOneCharVarInForLoop} - Allow one character variable name in
*
* initialization expressions
@@ -43,6 +38,11 @@
* Type is {@code boolean}.
* Default value is {@code false}.
*
+ *
+ * Property {@code format} - Specifies valid identifiers.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
+ *
*
*
* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker}
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocTagContinuationIndentationCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocTagContinuationIndentationCheck.xml
index 708bc3ab96c..6159f362401 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocTagContinuationIndentationCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocTagContinuationIndentationCheck.xml
@@ -12,6 +12,9 @@
properties below.
</p>
+
+ Specify how many spaces to use for new indentation level.
+
@@ -19,9 +22,6 @@
if the Javadoc being examined by this check violates the tight html rules defined at
<a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>.
-
- Specify how many spaces to use for new indentation level.
-
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocMethodCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocMethodCheck.xml
index 068bc58e4ab..a5c3292a989 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocMethodCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocMethodCheck.xml
@@ -37,9 +37,11 @@
}
</pre>
-
- Control the minimal amount of lines in method to allow no
- documentation.
+
+ Control whether to allow missing Javadoc on
+ accessor methods for properties (setters and getters).Configure annotations that allow missed
documentation.
-
- Specify the visibility scope where Javadoc comments are checked.
- Specify the visibility scope where Javadoc comments are
not checked.
-
-
- Control whether to allow missing Javadoc on
- accessor methods for properties (setters and getters).Ignore method whose names are matching specified
regex.
+
+ Control the minimal amount of lines in method to allow no
+ documentation.
+
+
+ Specify the visibility scope where Javadoc comments are checked.
+
-
- Specify the maximum threshold allowed.
-
-
- Specify user-configured class names to ignore.
- Specify user-configured regular
expressions to ignore classes.
+
+ Specify user-configured class names to ignore.
+ Specify user-configured packages to ignore.
All excluded packages should end with a period, so it also appends a dot to a package name.
+
+ Specify the maximum threshold allowed.
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/LocalVariableNameCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/LocalVariableNameCheck.xml
index f18acdb5041..33c0b1f0cc3 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/LocalVariableNameCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/LocalVariableNameCheck.xml
@@ -10,11 +10,6 @@
a local variable.
</p>
-
- Specifies valid identifiers.
-
@@ -23,6 +18,11 @@
initialization expressions</a>
in FOR loop if one char variable name is prohibited by {@code format} regexp.
+
+ Specifies valid identifiers.
+
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index 195d9a1527e..c33b4e09d18 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -229,10 +229,6 @@ public class XdocsPagesTest {
// until https://github.com/checkstyle/checkstyle/issues/13666
private static final Set MODULES_WITH_UNORDERED_PROPERTIES = Set.of(
"Checker",
- "MissingJavadocMethod",
- "LocalVariableName",
- "JavadocTagContinuationIndentation",
- "ClassFanOutComplexity",
"Translation",
"MethodCount",
"Regexp",
diff --git a/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml b/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml
index ddd1a39b768..bdd5c11a561 100644
--- a/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml
+++ b/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml
@@ -29,6 +29,13 @@
default value
since
+
+
offset
+
Specify how many spaces to use for new indentation level.
From 23eff223e700cf06d91358fafa1527aa621ebfcb Mon Sep 17 00:00:00 2001
From: Vyom-Yadav
Date: Sat, 23 Sep 2023 13:17:17 +0530
Subject: [PATCH 080/833] Issue #13672: Kill mutation related to Charset in
FileText
---
.../pitest-api-suppressions.xml | 36 -------------------
pom.xml | 2 ++
.../NonEmptyAtclauseDescriptionCheckTest.java | 32 +++++++++++++++++
.../checks/sizes/LineLengthCheckTest.java | 27 ++++++++++++++
...tyAtclauseDescriptionDifferentCharset.java | 10 ++++++
.../InputLineLengthUnmappableCharacters.java | 5 +++
6 files changed, 76 insertions(+), 36 deletions(-)
create mode 100644 src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/InputNonEmptyAtclauseDescriptionDifferentCharset.java
create mode 100644 src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLineLengthUnmappableCharacters.java
diff --git a/config/pitest-suppressions/pitest-api-suppressions.xml b/config/pitest-suppressions/pitest-api-suppressions.xml
index b00396e26a9..56a106babe9 100644
--- a/config/pitest-suppressions/pitest-api-suppressions.xml
+++ b/config/pitest-suppressions/pitest-api-suppressions.xml
@@ -9,42 +9,6 @@
charset = null;
-
- FileText.java
- com.puppycrawl.tools.checkstyle.api.FileText
- <init>
- org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator
- removed call to java/nio/charset/CharsetDecoder::onMalformedInput
- decoder.onMalformedInput(CodingErrorAction.REPLACE);
-
-
-
- FileText.java
- com.puppycrawl.tools.checkstyle.api.FileText
- <init>
- org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator
- replaced call to java/nio/charset/CharsetDecoder::onMalformedInput with receiver
- decoder.onMalformedInput(CodingErrorAction.REPLACE);
-
-
-
- FileText.java
- com.puppycrawl.tools.checkstyle.api.FileText
- <init>
- org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator
- removed call to java/nio/charset/CharsetDecoder::onUnmappableCharacter
- decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
-
-
-
- FileText.java
- com.puppycrawl.tools.checkstyle.api.FileText
- <init>
- org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator
- replaced call to java/nio/charset/CharsetDecoder::onUnmappableCharacter with receiver
- decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
-
-
Violation.javacom.puppycrawl.tools.checkstyle.api.Violation
diff --git a/pom.xml b/pom.xml
index d1c633dfc5b..cce4883c834 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4672,6 +4672,8 @@
com.puppycrawl.tools.checkstyle.checks.coding.UnusedLocalVariableCheckTest
com.puppycrawl.tools.checkstyle.checks.OuterTypeFilenameCheckTest
+ com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheckTest
+ com.puppycrawl.tools.checkstyle.checks.javadoc.NonEmptyAtclauseDescriptionCheckTest
org.checkstyle.suppressionxpathfilter.XpathRegressionUnusedLocalVariableTest
com.puppycrawl.tools.checkstyle.checks.javadoc.SummaryJavadocCheckTest
org.checkstyle.suppressionxpathfilter.XpathRegressionJavadocMethodTest
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java
index 2302a1e294c..366cd0b9400 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java
@@ -22,10 +22,16 @@
import static com.google.common.truth.Truth.assertWithMessage;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.NonEmptyAtclauseDescriptionCheck.MSG_KEY;
+import java.nio.charset.CodingErrorAction;
+
import org.junit.jupiter.api.Test;
import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
+import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
+import com.puppycrawl.tools.checkstyle.TreeWalker;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
+import de.thetaphi.forbiddenapis.SuppressForbidden;
public class NonEmptyAtclauseDescriptionCheckTest
extends AbstractModuleTestSupport {
@@ -95,4 +101,30 @@ public void testCheckTwo() throws Exception {
};
verifyWithInlineConfigParser(getPath("InputNonEmptyAtclauseDescriptionTwo.java"), expected);
}
+
+ /**
+ * This tests that the check does not fail when the input file contains unmappable characters.
+ * The test file contains the character ü which is not mappable to US-ASCII. It makes sure that
+ * unmappable characters are replaced with the default replacement character using
+ * {@link CodingErrorAction#REPLACE}.
+ *
+ * @throws Exception exception
+ */
+ @SuppressForbidden
+ @Test
+ public void testDecoderOnMalformedInput() throws Exception {
+ final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
+ final DefaultConfiguration checkConfig =
+ createModuleConfig(NonEmptyAtclauseDescriptionCheck.class);
+
+ final DefaultConfiguration treeWalkerConfig = createModuleConfig(TreeWalker.class);
+ treeWalkerConfig.addChild(checkConfig);
+
+ final DefaultConfiguration checkerConfig = createRootConfig(treeWalkerConfig);
+ checkerConfig.addChild(treeWalkerConfig);
+ checkerConfig.addProperty("charset", "US-ASCII");
+
+ verify(checkerConfig,
+ getPath("InputNonEmptyAtclauseDescriptionDifferentCharset.java"), expected);
+ }
}
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckTest.java
index fc4a8d0f5c1..c2ed9076eab 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckTest.java
@@ -21,9 +21,13 @@
import static com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck.MSG_KEY;
+import java.nio.charset.CodingErrorAction;
+
import org.junit.jupiter.api.Test;
import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
+import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
+import de.thetaphi.forbiddenapis.SuppressForbidden;
public class LineLengthCheckTest extends AbstractModuleTestSupport {
@@ -118,4 +122,27 @@ public void testLineLengthIgnoringImportStatements() throws Exception {
getNonCompilablePath("InputLineLengthIgnoringImportStatements.java"), expected);
}
+ /**
+ * This tests that the check does not fail when the file contains unmappable characters.
+ * Unmappable characters should be replaced with the default replacement character
+ * {@link CodingErrorAction#REPLACE}. For example, the 0x80 (hex.) character is unmappable
+ * in the IBM1098 charset.
+ *
+ * @throws Exception exception
+ */
+ @SuppressForbidden
+ @Test
+ public void testUnmappableCharacters() throws Exception {
+ final String[] expected = {
+ "4: " + getCheckMessage(MSG_KEY, 75, 238),
+ };
+
+ final DefaultConfiguration checkConfig = createModuleConfig(LineLengthCheck.class);
+ checkConfig.addProperty("max", "75");
+
+ final DefaultConfiguration checkerConfig = createRootConfig(checkConfig);
+ checkerConfig.addProperty("charset", "IBM1098");
+
+ verify(checkerConfig, getPath("InputLineLengthUnmappableCharacters.java"), expected);
+ }
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/InputNonEmptyAtclauseDescriptionDifferentCharset.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/InputNonEmptyAtclauseDescriptionDifferentCharset.java
new file mode 100644
index 00000000000..de597ffc75a
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/InputNonEmptyAtclauseDescriptionDifferentCharset.java
@@ -0,0 +1,10 @@
+package com.puppycrawl.tools.checkstyle.checks.javadoc.nonemptyatclausedescription;
+
+public class InputNonEmptyAtclauseDescriptionDifferentCharset {
+
+ /**
+ * @author ü
+ */
+ private void foo() {
+ }
+}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLineLengthUnmappableCharacters.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLineLengthUnmappableCharacters.java
new file mode 100644
index 00000000000..9468f6b5c1c
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLineLengthUnmappableCharacters.java
@@ -0,0 +1,5 @@
+package com.puppycrawl.tools.checkstyle.checks.sizes.linelength;
+
+public class InputLineLengthUnmappableCharacters {
+ String a = "ᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀ"; // violation
+}
From c525c6732e2c1f15bd3f85f943770c649f1ab775 Mon Sep 17 00:00:00 2001
From: Vyom-Yadav
Date: Sat, 23 Sep 2023 18:49:21 +0530
Subject: [PATCH 081/833] minor: Fix wording of Javadoc comment for malformed
input
---
.../javadoc/NonEmptyAtclauseDescriptionCheckTest.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java
index 366cd0b9400..b36bfd25788 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java
@@ -103,10 +103,10 @@ public void testCheckTwo() throws Exception {
}
/**
- * This tests that the check does not fail when the input file contains unmappable characters.
- * The test file contains the character ü which is not mappable to US-ASCII. It makes sure that
- * unmappable characters are replaced with the default replacement character using
- * {@link CodingErrorAction#REPLACE}.
+ * This tests that the check does not fail when the input file contains malformed characters
+ * for a particular charset. The test file contains the character {@code ü} which is not
+ * mappable to US-ASCII. It makes sure that malformed characters than cannot be mapped are
+ * replaced with the default replacement character using {@link CodingErrorAction#REPLACE}.
*
* @throws Exception exception
*/
From ecd2ecf22339b63e81f764e6afe99af2734ed2af Mon Sep 17 00:00:00 2001
From: Ruslan Diachenko
Date: Tue, 12 Sep 2023 21:37:58 +0100
Subject: [PATCH 082/833] Issue #11902: kill mutation in PackageObjectFactory
---
.../pitest-common-suppressions.xml | 9 -----
pom.xml | 4 ++
.../checkstyle/PackageObjectFactory.java | 40 ++++++++++++++-----
3 files changed, 34 insertions(+), 19 deletions(-)
diff --git a/config/pitest-suppressions/pitest-common-suppressions.xml b/config/pitest-suppressions/pitest-common-suppressions.xml
index 1ed5890ad56..718209ca11b 100644
--- a/config/pitest-suppressions/pitest-common-suppressions.xml
+++ b/config/pitest-suppressions/pitest-common-suppressions.xml
@@ -207,15 +207,6 @@
if (!name.contains(PACKAGE_SEPARATOR)) {
-
- PackageObjectFactory.java
- com.puppycrawl.tools.checkstyle.PackageObjectFactory
- createModule
- org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_EQUAL_IF
- removed conditional - replaced equality check with true
- if (thirdPartyNameToFullModuleNames == null) {
-
-
PackageObjectFactory.javacom.puppycrawl.tools.checkstyle.PackageObjectFactory
diff --git a/pom.xml b/pom.xml
index cce4883c834..744f10fd5f3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4361,6 +4361,10 @@
com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheckTest
+
+
+ lazyLoad
+ 10096${pitest.plugin.timeout.factor}
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java b/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java
index c46649e3dcf..723ae94458e 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java
@@ -28,6 +28,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -187,11 +188,7 @@ public Object createModule(String name) throws CheckstyleException {
instance = createFromStandardCheckSet(name);
// find the name in third party map
if (instance == null) {
- if (thirdPartyNameToFullModuleNames == null) {
- thirdPartyNameToFullModuleNames =
- generateThirdPartyNameToFullModuleName(moduleClassLoader);
- }
- instance = createObjectFromMap(name, thirdPartyNameToFullModuleNames);
+ instance = createObjectFromClassPath(name);
}
}
if (instance == null) {
@@ -241,19 +238,23 @@ private Object createFromStandardCheckSet(String name) throws CheckstyleExceptio
}
/**
- * Create object with the help of the supplied map.
+ * Create object with the help of the classpath.
*
* @param name name of module.
- * @param map the supplied map.
* @return instance of module if it is found in modules map and no ambiguous classes exist.
* @throws CheckstyleException if the class fails to instantiate or there are ambiguous classes.
*/
- private Object createObjectFromMap(String name, Map> map)
+ private Object createObjectFromClassPath(String name)
throws CheckstyleException {
- final Set fullModuleNames = map.get(name);
+ thirdPartyNameToFullModuleNames = lazyLoad(
+ thirdPartyNameToFullModuleNames,
+ () -> generateThirdPartyNameToFullModuleName(moduleClassLoader)
+ );
+ final Set fullModuleNames = thirdPartyNameToFullModuleNames.get(name);
Object instance = null;
if (fullModuleNames == null) {
- final Set fullCheckModuleNames = map.get(name + CHECK_SUFFIX);
+ final Set fullCheckModuleNames =
+ thirdPartyNameToFullModuleNames.get(name + CHECK_SUFFIX);
if (fullCheckModuleNames != null) {
instance = createObjectFromFullModuleNames(name, fullCheckModuleNames);
}
@@ -399,6 +400,25 @@ private Object createModuleByTryInEachPackage(String name) throws CheckstyleExce
return instance;
}
+ /**
+ * Initialize object by supplier if object is null.
+ *
+ * @param type of object
+ * @param object object to initialize
+ * @param supplier function to initialize if object is null
+ * @return object as it was provided in method or initialized
+ */
+ private static T lazyLoad(T object, Supplier supplier) {
+ final T result;
+ if (object == null) {
+ result = supplier.get();
+ }
+ else {
+ result = object;
+ }
+ return result;
+ }
+
/**
* Fill short-to-full module names map.
*/
From 37518970e342567088f4311f6be12d83b4da779f Mon Sep 17 00:00:00 2001
From: Rohanraj123
Date: Sat, 23 Sep 2023 01:12:13 +0530
Subject: [PATCH 083/833] Issue #13345: Enable TestCases for
MemberNameCheckExamplesTest
---
.../naming/MemberNameCheckExamplesTest.java | 21 ++++---
.../checks/naming/membername/Example1.java | 30 +++++++++
.../checks/naming/membername/Example1.txt | 28 ---------
.../{Example2.txt => Example2.java} | 15 ++---
.../{Example3.txt => Example3.java} | 15 ++---
src/xdocs/checks/naming/membername.xml | 62 +++++++++----------
.../checks/naming/membername.xml.template | 12 ++--
7 files changed, 96 insertions(+), 87 deletions(-)
create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example1.java
delete mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example1.txt
rename src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/{Example2.txt => Example2.java} (55%)
rename src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/{Example3.txt => Example3.java} (51%)
diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MemberNameCheckExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MemberNameCheckExamplesTest.java
index 843aadc4a37..752ea02270a 100644
--- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MemberNameCheckExamplesTest.java
+++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MemberNameCheckExamplesTest.java
@@ -19,12 +19,12 @@
package com.puppycrawl.tools.checkstyle.checks.naming;
-import org.junit.jupiter.api.Disabled;
+import static com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck.MSG_INVALID_PATTERN;
+
import org.junit.jupiter.api.Test;
import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
-@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345")
public class MemberNameCheckExamplesTest extends AbstractExamplesModuleTestSupport {
@Override
protected String getPackageLocation() {
@@ -34,27 +34,32 @@ protected String getPackageLocation() {
@Test
public void testExample1() throws Exception {
final String[] expected = {
-
+ "21:14: " + getCheckMessage(MSG_INVALID_PATTERN, "NUM1", "^[a-z][a-zA-Z0-9]*$"),
+ "23:17: " + getCheckMessage(MSG_INVALID_PATTERN, "NUM2", "^[a-z][a-zA-Z0-9]*$"),
+ "25:7: " + getCheckMessage(MSG_INVALID_PATTERN, "NUM3", "^[a-z][a-zA-Z0-9]*$"),
+ "27:15: " + getCheckMessage(MSG_INVALID_PATTERN, "NUM4", "^[a-z][a-zA-Z0-9]*$"),
};
- verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example1.java"), expected);
}
@Test
public void testExample2() throws Exception {
final String[] expected = {
-
+ "16:14: " + getCheckMessage(MSG_INVALID_PATTERN, "num1", "^m[A-Z][a-zA-Z0-9]*$"),
+ "20:15: " + getCheckMessage(MSG_INVALID_PATTERN, "num4", "^m[A-Z][a-zA-Z0-9]*$"),
};
- verifyWithInlineConfigParser(getPath("Example2.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example2.java"), expected);
}
@Test
public void testExample3() throws Exception {
final String[] expected = {
-
+ "16:17: " + getCheckMessage(MSG_INVALID_PATTERN, "NUM2", "^[a-z][a-zA-Z0-9]*$"),
+ "18:7: " + getCheckMessage(MSG_INVALID_PATTERN, "NUM3", "^[a-z][a-zA-Z0-9]*$"),
};
- verifyWithInlineConfigParser(getPath("Example3.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example3.java"), expected);
}
}
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example1.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example1.java
new file mode 100644
index 00000000000..82cd49ae7f5
--- /dev/null
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example1.java
@@ -0,0 +1,30 @@
+/*xml
+
+
+
+
+
+*/
+
+package com.puppycrawl.tools.checkstyle.checks.naming.membername;
+
+// xdoc section -- start
+class Example1 {
+ public int num1;
+ protected int num2;
+ final int num3 = 3;
+ private int num4;
+
+ static int num5;
+ public static final int CONSTANT = 1;
+
+ public int NUM1; // violation
+
+ protected int NUM2; // violation
+
+ int NUM3; // violation
+
+ private int NUM4; // violation
+
+}
+// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example1.txt
deleted file mode 100644
index effa41dbb9b..00000000000
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example1.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-/*xml
-
-
-
-
-
-*/
-
-// xdoc section -- start
-class MyClass {
- public int num1; // OK
- protected int num2; // OK
- final int num3 = 3; // OK
- private int num4; // OK
-
- static int num5; // ignored: not an instance variable
- public static final int CONSTANT = 1; // ignored: not an instance variable
-
- public int NUM1; // violation, name 'NUM1'
- // must match pattern '^[a-z][a-zA-Z0-9]*$'
- protected int NUM2; // violation, name 'NUM2'
- // must match pattern '^[a-z][a-zA-Z0-9]*$'
- final int NUM3; // violation, name 'NUM3'
- // must match pattern '^[a-z][a-zA-Z0-9]*$'
- private int NUM4; // violation, name 'NUM4'
- // must match pattern '^[a-z][a-zA-Z0-9]*$'
-}
-// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example2.java
similarity index 55%
rename from src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example2.txt
rename to src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example2.java
index 12692128584..fa40d467c0e 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example2.txt
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example2.java
@@ -9,14 +9,15 @@
*/
+package com.puppycrawl.tools.checkstyle.checks.naming.membername;
// xdoc section -- start
-class MyClass {
- public int num1; // violation, name 'num1'
- // must match pattern '^m[A-Z][a-zA-Z0-9]*$'
- protected int num2; // OK
- int num3; // OK
- private int num4; // violation, name 'num4'
- // must match pattern '^m[A-Z][a-zA-Z0-9]*$'
+class Example2 {
+ public int num1; // violation
+
+ protected int num2;
+ int num3;
+ private int num4; // violation
+
}
// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example3.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example3.java
similarity index 51%
rename from src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example3.txt
rename to src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example3.java
index 0f4e44ff8d9..4e43bfc9f53 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example3.txt
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example3.java
@@ -8,14 +8,15 @@
*/
+package com.puppycrawl.tools.checkstyle.checks.naming.membername;
// xdoc section -- start
-class MyClass {
- public int NUM1; // OK
- protected int NUM2; // violation, name 'NUM2'
- // must match pattern '^[a-z][a-zA-Z0-9]*$'
- int NUM3; // violation, name 'NUM3'
- // must match pattern '^[a-z][a-zA-Z0-9]*$'
- private int NUM4; // OK
+class Example3 {
+ public int NUM1;
+ protected int NUM2; // violation
+
+ int NUM3; // violation
+
+ private int NUM4;
}
// xdoc section -- end
diff --git a/src/xdocs/checks/naming/membername.xml b/src/xdocs/checks/naming/membername.xml
index 7e9a18726b6..8b8364ab871 100644
--- a/src/xdocs/checks/naming/membername.xml
+++ b/src/xdocs/checks/naming/membername.xml
@@ -78,23 +78,23 @@
Code Example:
-class MyClass {
- public int num1; // OK
- protected int num2; // OK
- final int num3 = 3; // OK
- private int num4; // OK
-
- static int num5; // ignored: not an instance variable
- public static final int CONSTANT = 1; // ignored: not an instance variable
-
- public int NUM1; // violation, name 'NUM1'
- // must match pattern '^[a-z][a-zA-Z0-9]*$'
- protected int NUM2; // violation, name 'NUM2'
- // must match pattern '^[a-z][a-zA-Z0-9]*$'
- final int NUM3; // violation, name 'NUM3'
- // must match pattern '^[a-z][a-zA-Z0-9]*$'
- private int NUM4; // violation, name 'NUM4'
- // must match pattern '^[a-z][a-zA-Z0-9]*$'
+class Example1 {
+ public int num1;
+ protected int num2;
+ final int num3 = 3;
+ private int num4;
+
+ static int num5;
+ public static final int CONSTANT = 1;
+
+ public int NUM1; // violation
+
+ protected int NUM2; // violation
+
+ int NUM3; // violation
+
+ private int NUM4; // violation
+
}
@@ -117,13 +117,13 @@ class MyClass {
Code Example:
-class MyClass {
- public int num1; // violation, name 'num1'
- // must match pattern '^m[A-Z][a-zA-Z0-9]*$'
- protected int num2; // OK
- int num3; // OK
- private int num4; // violation, name 'num4'
- // must match pattern '^m[A-Z][a-zA-Z0-9]*$'
+class Example2 {
+ public int num1; // violation
+
+ protected int num2;
+ int num3;
+ private int num4; // violation
+
}
@@ -142,13 +142,13 @@ class MyClass {
Code Example:
-class MyClass {
- public int NUM1; // OK
- protected int NUM2; // violation, name 'NUM2'
- // must match pattern '^[a-z][a-zA-Z0-9]*$'
- int NUM3; // violation, name 'NUM3'
- // must match pattern '^[a-z][a-zA-Z0-9]*$'
- private int NUM4; // OK
+class Example3 {
+ public int NUM1;
+ protected int NUM2; // violation
+
+ int NUM3; // violation
+
+ private int NUM4;
}
diff --git a/src/xdocs/checks/naming/membername.xml.template b/src/xdocs/checks/naming/membername.xml.template
index afc74781c6e..6c59dbdc3dd 100644
--- a/src/xdocs/checks/naming/membername.xml.template
+++ b/src/xdocs/checks/naming/membername.xml.template
@@ -71,13 +71,13 @@
+ value="resources/com/puppycrawl/tools/checkstyle/checks/naming/membername/Example1.java"/>
+ * Property {@code ignoreEnums} - Allow to ignore enums when left curly brace policy is EOL.
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
+ *
+ *
* Property {@code option} - Specify the policy on placement of a left curly brace
* ('{').
* Type is {@code com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyOption}.
* Default value is {@code eol}.
*
*
- * Property {@code ignoreEnums} - Allow to ignore enums when left curly brace policy is EOL.
- * Type is {@code boolean}.
- * Default value is {@code true}.
- *
- *
* Property {@code tokens} - tokens to check
* Type is {@code java.lang.String[]}.
* Validation type is {@code tokenSet}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck.java
index 1c62d765f13..98050625c44 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck.java
@@ -39,6 +39,12 @@
*
*
*
+ * Property {@code allowNewlineParagraph} - Control whether the <p> tag
+ * should be placed immediately before the first word.
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
+ *
- * Property {@code allowNewlineParagraph} - Control whether the <p> tag
- * should be placed immediately before the first word.
- * Type is {@code boolean}.
- * Default value is {@code true}.
- *
- * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked.
- * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
- * Default value is {@code private}.
- *
- *
- * Property {@code excludeScope} - Specify the visibility scope where
- * Javadoc comments are not checked.
- * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
- * Default value is {@code null}.
+ * Property {@code checkEmptyJavadoc} - Control whether to check if the Javadoc
+ * is missing a describing text.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
*
*
* Property {@code checkFirstSentence} - Control whether to check the first
@@ -102,21 +97,26 @@
* Default value is {@code true}.
*
*
+ * Property {@code checkHtml} - Control whether to check for incomplete HTML tags.
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
+ *
+ *
* Property {@code endOfSentenceFormat} - Specify the format for matching
* the end of a sentence.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "([.?!][ \t\n\r\f<])|([.?!]$)"}.
*
*
- * Property {@code checkEmptyJavadoc} - Control whether to check if the Javadoc
- * is missing a describing text.
- * Type is {@code boolean}.
- * Default value is {@code false}.
+ * Property {@code excludeScope} - Specify the visibility scope where
+ * Javadoc comments are not checked.
+ * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
+ * Default value is {@code null}.
*
*
- * Property {@code checkHtml} - Control whether to check for incomplete HTML tags.
- * Type is {@code boolean}.
- * Default value is {@code true}.
+ * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked.
+ * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
+ * Default value is {@code private}.
*
*
* Property {@code tokens} - tokens to check
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheck.java
index c7d357bb4b6..b1d30b35eec 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheck.java
@@ -78,19 +78,19 @@
* Default value is {@code true}.
*
*
- * Property {@code ignoreStatic} - Allow to skip variables with {@code static} modifier.
+ * Property {@code ignoreOverriddenMethods} - Allow to ignore methods tagged with {@code @Override}
+ * annotation (that usually mean inherited name).
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
- * Property {@code ignoreStaticFinal} - Allow to skip variables with both {@code static} and
- * {@code final} modifiers.
+ * Property {@code ignoreStatic} - Allow to skip variables with {@code static} modifier.
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
- * Property {@code ignoreOverriddenMethods} - Allow to ignore methods tagged with {@code @Override}
- * annotation (that usually mean inherited name).
+ * Property {@code ignoreStaticFinal} - Allow to skip variables with both {@code static} and
+ * {@code final} modifiers.
* Type is {@code boolean}.
* Default value is {@code true}.
*
- * Property {@code allowNoEmptyLineBetweenFields} - Allow no empty line between fields.
- * Type is {@code boolean}.
- * Default value is {@code false}.
- *
- *
* Property {@code allowMultipleEmptyLines} - Allow multiple empty lines between class members.
* Type is {@code boolean}.
* Default value is {@code true}.
@@ -69,6 +64,11 @@
* Default value is {@code true}.
*
*
+ * Property {@code allowNoEmptyLineBetweenFields} - Allow no empty line between fields.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
+ *
+ *
* Property {@code tokens} - tokens to check
* Type is {@code java.lang.String[]}.
* Validation type is {@code tokenSet}.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/LeftCurlyCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/LeftCurlyCheck.xml
index 5ddd5378dc0..32142353b19 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/LeftCurlyCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/LeftCurlyCheck.xml
@@ -8,15 +8,15 @@
Checks for the placement of left curly braces (<code>'{'</code>) for code blocks.
</p>
+
+ Allow to ignore enums when left curly brace policy is EOL.
+ Specify the policy on placement of a left curly brace
(<code>'{'</code>).
-
- Allow to ignore enums when left curly brace policy is EOL.
-
+
+ Control whether the <p> tag
+ should be placed immediately before the first word.
+
@@ -24,10 +28,6 @@
<a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">
Tight-HTML Rules</a>.
-
- Control whether the <p> tag
- should be placed immediately before the first word.
-
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocStyleCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocStyleCheck.xml
index 7d81da6a289..13dfb7b0560 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocStyleCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocStyleCheck.xml
@@ -49,31 +49,31 @@
available from Sun. Note: Original Sun's DocCheck tool does not exist anymore.
</p>
-
- Specify the visibility scope where Javadoc comments are checked.
-
-
- Specify the visibility scope where
- Javadoc comments are not checked.
+
+ Control whether to check if the Javadoc
+ is missing a describing text.Control whether to check the first
sentence for proper end of sentence.
+
+ Control whether to check for incomplete HTML tags.
+ Specify the format for matching
the end of a sentence.
-
- Control whether to check if the Javadoc
- is missing a describing text.
+
+ Specify the visibility scope where
+ Javadoc comments are not checked.
-
- Control whether to check for incomplete HTML tags.
+
+ Specify the visibility scope where Javadoc comments are checked.Allow to skip variables with {@code final} modifier.
+
+ Allow to ignore methods tagged with {@code @Override}
+ annotation (that usually mean inherited name).
+ Allow to skip variables with {@code static} modifier.Allow to skip variables with both {@code static} and
{@code final} modifiers.
-
-
- Allow to ignore methods tagged with {@code @Override}
- annotation (that usually mean inherited name).
-
- Allow no empty line between fields.
- Allow multiple empty lines between class members.
@@ -35,6 +30,11 @@
Allow multiple
empty lines inside class members.
+
+ Allow no empty line between fields.
+ default value
since
-
-
option
-
Specify the policy on placement of a left curly brace ('{').
- * Property {@code format} - Specify the pattern to match against.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "^$"}.
- *
- *
- * Property {@code message} - Specify message which is used to notify about
- * violations, if empty then the default (hard-coded) message is used.
- * Type is {@code java.lang.String}.
- * Default value is {@code null}.
- *
- *
- * Property {@code illegalPattern} - Control whether the pattern is required or illegal.
- * Type is {@code boolean}.
- * Default value is {@code false}.
- *
- *
* Property {@code 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,
@@ -116,10 +100,26 @@
* Default value is {@code 100}.
*
*
+ * Property {@code format} - Specify the pattern to match against.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "^$"}.
+ *
+ *
* Property {@code ignoreComments} - Control whether to ignore matches found within comments.
* Type is {@code boolean}.
* Default value is {@code false}.
*
+ *
+ * Property {@code illegalPattern} - Control whether the pattern is required or illegal.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
+ *
+ *
+ * Property {@code message} - Specify message which is used to notify about
+ * violations, if empty then the default (hard-coded) message is used.
+ * Type is {@code java.lang.String}.
+ * Default value is {@code null}.
+ *
- * Property {@code maxTotal} - Specify the maximum number of methods allowed at all scope levels.
+ * Property {@code maxPackage} - Specify the maximum number of {@code package} methods allowed.
* Type is {@code int}.
* Default value is {@code 100}.
*
@@ -84,17 +84,17 @@
* Default value is {@code 100}.
*
*
- * Property {@code maxPackage} - Specify the maximum number of {@code package} methods allowed.
+ * Property {@code maxProtected} - Specify the maximum number of {@code protected} methods allowed.
* Type is {@code int}.
* Default value is {@code 100}.
*
*
- * Property {@code maxProtected} - Specify the maximum number of {@code protected} methods allowed.
+ * Property {@code maxPublic} - Specify the maximum number of {@code public} methods allowed.
* Type is {@code int}.
* Default value is {@code 100}.
*
*
- * Property {@code maxPublic} - Specify the maximum number of {@code public} methods allowed.
+ * Property {@code maxTotal} - Specify the maximum number of methods allowed at all scope levels.
* Type is {@code int}.
* Default value is {@code 100}.
*
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpCheck.xml
index fe34ff9ee3d..4edb099b2d5 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpCheck.xml
@@ -58,16 +58,6 @@
The regular expression should be entered on one line.
</p>
-
- Specify the pattern to match against.
-
-
- Specify message which is used to notify about
- violations, if empty then the default (hard-coded) message is used.
-
-
- Control whether the pattern is required or illegal.
- Control whether to check for duplicates
of a required pattern, any negative value means no checking for duplicates,
@@ -78,9 +68,19 @@
Specify the maximum number of violations before
the check will abort.
+
+ Specify the pattern to match against.
+ Control whether to ignore matches found within comments.
+
+ Control whether the pattern is required or illegal.
+
+
+ Specify message which is used to notify about
+ violations, if empty then the default (hard-coded) message is used.
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/sizes/MethodCountCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/sizes/MethodCountCheck.xml
index 7acf23a3575..6c9385e2909 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/sizes/MethodCountCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/sizes/MethodCountCheck.xml
@@ -45,21 +45,21 @@
}
</pre>
-
- Specify the maximum number of methods allowed at all scope levels.
+
+ Specify the maximum number of {@code package} methods allowed.Specify the maximum number of {@code private} methods allowed.
-
- Specify the maximum number of {@code package} methods allowed.
- Specify the maximum number of {@code protected} methods allowed.Specify the maximum number of {@code public} methods allowed.
+
+ Specify the maximum number of methods allowed at all scope levels.
+ MODULES_WITH_UNORDERED_PROPERTIES = Set.of(
"Checker",
"Translation",
- "MethodCount",
- "Regexp",
"Indentation",
"MethodName",
"AtclauseOrder",
diff --git a/src/xdocs/checks/regexp/regexp.xml b/src/xdocs/checks/regexp/regexp.xml
index d6d09a60231..45c571ffa4b 100644
--- a/src/xdocs/checks/regexp/regexp.xml
+++ b/src/xdocs/checks/regexp/regexp.xml
@@ -66,28 +66,6 @@
- * Property {@code illegalPkgs} - Specify packages to reject, if regexp
- * property is not set, checks if import is the part of package. If regexp
- * property is set, then list of packages will be interpreted as regular expressions.
- * Note, all properties for match will be used.
- * Type is {@code java.lang.String[]}.
- * Default value is {@code sun}.
- *
- *
* Property {@code illegalClasses} - Specify class names to reject, if regexp
* property is not set, checks if import equals class name. If regexp
* property is set, then list of class names will be interpreted as regular expressions.
@@ -59,6 +51,14 @@
* Default value is {@code ""}.
*
*
+ * Property {@code illegalPkgs} - Specify packages to reject, if regexp
+ * property is not set, checks if import is the part of package. If regexp
+ * property is set, then list of packages will be interpreted as regular expressions.
+ * Note, all properties for match will be used.
+ * Type is {@code java.lang.String[]}.
+ * Default value is {@code sun}.
+ *
+ *
* Property {@code regexp} - Control whether the {@code illegalPkgs} and
* {@code illegalClasses} should be interpreted as regular expressions.
* Type is {@code boolean}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheck.java
index 046ecbc4cdb..329e12132fe 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheck.java
@@ -36,11 +36,6 @@
*
*
*
- * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked.
- * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
- * Default value is {@code private}.
- *
- *
* Property {@code excludeScope} - Specify the visibility scope where Javadoc
* comments are not checked.
* Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
@@ -52,6 +47,11 @@
* Default value is {@code null}.
*
*
+ * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked.
+ * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
+ * Default value is {@code private}.
+ *
+ *
* Property {@code tokens} - tokens to check
* Type is {@code java.lang.String[]}.
* Validation type is {@code tokenSet}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/InterfaceMemberImpliedModifierCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/InterfaceMemberImpliedModifierCheck.java
index 0e86b9f01e9..7fb95e9bf29 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/InterfaceMemberImpliedModifierCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/InterfaceMemberImpliedModifierCheck.java
@@ -95,19 +95,19 @@
*
*
*
- * Property {@code violateImpliedPublicField} - Control whether to enforce that {@code public}
- * is explicitly coded on interface fields.
+ * Property {@code violateImpliedAbstractMethod} - Control whether to enforce that {@code abstract}
+ * is explicitly coded on interface methods.
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
- * Property {@code violateImpliedStaticField} - Control whether to enforce that {@code static}
+ * Property {@code violateImpliedFinalField} - Control whether to enforce that {@code final}
* is explicitly coded on interface fields.
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
- * Property {@code violateImpliedFinalField} - Control whether to enforce that {@code final}
+ * Property {@code violateImpliedPublicField} - Control whether to enforce that {@code public}
* is explicitly coded on interface fields.
* Type is {@code boolean}.
* Default value is {@code true}.
@@ -119,14 +119,14 @@
* Default value is {@code true}.
*
*
- * Property {@code violateImpliedAbstractMethod} - Control whether to enforce that {@code abstract}
- * is explicitly coded on interface methods.
+ * Property {@code violateImpliedPublicNested} - Control whether to enforce that {@code public}
+ * is explicitly coded on interface nested types.
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
- * Property {@code violateImpliedPublicNested} - Control whether to enforce that {@code public}
- * is explicitly coded on interface nested types.
+ * Property {@code violateImpliedStaticField} - Control whether to enforce that {@code static}
+ * is explicitly coded on interface fields.
* Type is {@code boolean}.
* Default value is {@code true}.
*
+ * Property {@code fileExtensions} - Specify the file type extension of files to process.
+ * Type is {@code java.lang.String[]}.
+ * Default value is {@code ""}.
+ *
+ *
* Property {@code format} - Specify the format of the regular expression to match.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "$."}.
*
*
- * Property {@code message} - Specify the message which is used to notify about
- * violations, if empty then default (hard-coded) message is used.
- * Type is {@code java.lang.String}.
- * Default value is {@code null}.
- *
- *
* Property {@code ignoreCase} - Control whether to ignore case when searching.
* Type is {@code boolean}.
* Default value is {@code false}.
*
*
- * Property {@code minimum} - Specify the minimum number of matches required in each file.
- * Type is {@code int}.
- * Default value is {@code 0}.
+ * Property {@code matchAcrossLines} - Control whether to match expressions
+ * across multiple lines.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
*
*
* Property {@code maximum} - Specify the maximum number of matches required in each file.
@@ -63,15 +63,15 @@
* Default value is {@code 0}.
*
*
- * Property {@code matchAcrossLines} - Control whether to match expressions
- * across multiple lines.
- * Type is {@code boolean}.
- * Default value is {@code false}.
+ * Property {@code message} - Specify the message which is used to notify about
+ * violations, if empty then default (hard-coded) message is used.
+ * Type is {@code java.lang.String}.
+ * Default value is {@code null}.
*
*
- * Property {@code fileExtensions} - Specify the file type extension of files to process.
- * Type is {@code java.lang.String[]}.
- * Default value is {@code ""}.
+ * Property {@code minimum} - Specify the minimum number of matches required in each file.
+ * Type is {@code int}.
+ * Default value is {@code 0}.
*
- * Property {@code files} - Define the RegExp for matching against the file name associated with
- * an audit event.
+ * Property {@code checks} - Define the RegExp for matching against the name of the check
+ * associated with an audit event.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code null}.
*
*
- * Property {@code checks} - Define the RegExp for matching against the name of the check
- * associated with an audit event.
- * Type is {@code java.util.regex.Pattern}.
+ * Property {@code columns} - Specify a comma-separated list of values, where each value is an
+ * integer or a range of integers denoted by integer-integer.
+ * Type is {@code java.lang.String}.
* Default value is {@code null}.
*
*
- * Property {@code message} - Define the RegExp for matching against the message of the check
- * associated with an audit event.
+ * Property {@code files} - Define the RegExp for matching against the file name associated with
+ * an audit event.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code null}.
*
@@ -79,9 +79,9 @@
* Default value is {@code null}.
*
*
- * Property {@code columns} - Specify a comma-separated list of values, where each value is an
- * integer or a range of integers denoted by integer-integer.
- * Type is {@code java.lang.String}.
+ * Property {@code message} - Define the RegExp for matching against the message of the check
+ * associated with an audit event.
+ * Type is {@code java.util.regex.Pattern}.
* Default value is {@code null}.
*
*
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/IllegalImportCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/IllegalImportCheck.xml
index 4b755aba53d..8abcd05aba5 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/IllegalImportCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/IllegalImportCheck.xml
@@ -15,16 +15,16 @@
packages, set property {@code illegalPkgs} to a list of the illegal packages.
</p>
-
- Specify packages to reject, if <b>regexp</b>
- property is not set, checks if import is the part of package. If <b>regexp</b>
- property is set, then list of packages will be interpreted as regular expressions.
- Note, all properties for match will be used.
- Specify class names to reject, if <b>regexp</b>
property is not set, checks if import equals class name. If <b>regexp</b>
property is set, then list of class names will be interpreted as regular expressions.
+ Note, all properties for match will be used.
+
+
+ Specify packages to reject, if <b>regexp</b>
+ property is not set, checks if import is the part of package. If <b>regexp</b>
+ property is set, then list of packages will be interpreted as regular expressions.
Note, all properties for match will be used.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocVariableCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocVariableCheck.xml
index aea982226cd..1b419a14947 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocVariableCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/JavadocVariableCheck.xml
@@ -8,11 +8,6 @@
Checks that a variable has a Javadoc comment. Ignores {@code serialVersionUID} fields.
</p>
-
- Specify the visibility scope where Javadoc comments are checked.
- Specify the visibility scope where Javadoc
comments are not checked.
@@ -20,6 +15,11 @@
Specify the regexp to define variable names to ignore.
+
+ Specify the visibility scope where Javadoc comments are checked.
+
- Control whether to enforce that {@code public}
- is explicitly coded on interface fields.
-
-
- Control whether to enforce that {@code static}
- is explicitly coded on interface fields.
+ Control whether to enforce that {@code abstract}
+ is explicitly coded on interface methods.Control whether to enforce that {@code final}
is explicitly coded on interface fields.Control whether to enforce that {@code public}
- is explicitly coded on interface methods.
+ is explicitly coded on interface fields.
- Control whether to enforce that {@code abstract}
+ Control whether to enforce that {@code public}
is explicitly coded on interface methods.Control whether to enforce that {@code public}
is explicitly coded on interface nested types.
+
+
+ Control whether to enforce that {@code static}
+ is explicitly coded on interface fields.
+
+ Specify the file type extension of files to process.
+ Specify the format of the regular expression to match.
-
- Specify the message which is used to notify about
- violations, if empty then default (hard-coded) message is used.
- Control whether to ignore case when searching.
-
- Specify the minimum number of matches required in each file.
+
+ Control whether to match expressions
+ across multiple lines.Specify the maximum number of matches required in each file.
-
- Control whether to match expressions
- across multiple lines.
+
+ Specify the message which is used to notify about
+ violations, if empty then default (hard-coded) message is used.
-
- Specify the file type extension of files to process.
+
+ Specify the minimum number of matches required in each file.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressionSingleFilter.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressionSingleFilter.xml
index 6e7a6e4cab6..7b761a15e44 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressionSingleFilter.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressionSingleFilter.xml
@@ -26,17 +26,17 @@
Checker as parent module.
</p>
-
- Define the RegExp for matching against the file name associated with
- an audit event.
- Define the RegExp for matching against the name of the check
associated with an audit event.
-
- Define the RegExp for matching against the message of the check
- associated with an audit event.
+
+ Specify a comma-separated list of values, where each value is an
+ integer or a range of integers denoted by integer-integer.
+
+
+ Define the RegExp for matching against the file name associated with
+ an audit event.Specify a string matched against the ID of the check associated with
@@ -46,9 +46,9 @@
Specify a comma-separated list of values, where each value is an
integer or a range of integers denoted by integer-integer.
-
- Specify a comma-separated list of values, where each value is an
- integer or a range of integers denoted by integer-integer.
+
+ Define the RegExp for matching against the message of the check
+ associated with an audit event.
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index d3288dd4452..f4d6cf5f5ad 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -259,11 +259,6 @@ public class XdocsPagesTest {
"CustomImportOrder",
"Header",
"DescendantToken",
- "RegexpMultiline",
- "JavadocVariable",
- "SuppressionSingleFilter",
- "InterfaceMemberImpliedModifier",
- "IllegalImport",
"NewlineAtEndOfFile",
"SingleLineJavadoc",
"MissingJavadocType",
diff --git a/src/xdocs/checks/imports/illegalimport.xml b/src/xdocs/checks/imports/illegalimport.xml
index 271c9198f0a..a4ca14fb40f 100644
--- a/src/xdocs/checks/imports/illegalimport.xml
+++ b/src/xdocs/checks/imports/illegalimport.xml
@@ -35,16 +35,6 @@
default value
since
-
-
illegalPkgs
-
Specify packages to reject, if regexp property is not set, checks if import
- is the part of package. If regexp property is set, then list of packages will
- be interpreted as regular expressions. Note, all properties for match will be used.
-
Specify class names to reject, if regexp property is not set, checks if
@@ -55,6 +45,16 @@
{}
7.8
+
+
illegalPkgs
+
Specify packages to reject, if regexp property is not set, checks if import
+ is the part of package. If regexp property is set, then list of packages will
+ be interpreted as regular expressions. Note, all properties for match will be used.
+
Specify packages to reject, if regexp property is not set, checks if import
- is the part of package. If regexp property is set, then list of packages will
- be interpreted as regular expressions. Note, all properties for match will be used.
-
Specify class names to reject, if regexp property is not set, checks if
@@ -55,6 +45,16 @@
{}
7.8
+
+
illegalPkgs
+
Specify packages to reject, if regexp property is not set, checks if import
+ is the part of package. If regexp property is set, then list of packages will
+ be interpreted as regular expressions. Note, all properties for match will be used.
+
- * Property {@code exceptionVariableName} - Specify the RegExp for the name of the variable
- * associated with exception. If check meets variable name matching specified value - empty
- * block is suppressed.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "^$"}.
- *
- *
* Property {@code commentFormat} - Specify the RegExp for the first comment inside empty
* catch block. If check meets comment inside empty catch block matching specified format
* - empty block is suppressed. If it is multi-line comment - only its first line is analyzed.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code ".*"}.
*
+ *
+ * Property {@code exceptionVariableName} - Specify the RegExp for the name of the variable
+ * associated with exception. If check meets variable name matching specified value - empty
+ * block is suppressed.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "^$"}.
+ *
- * Property {@code ignoreFormat} - Define the RegExp for names of variables
- * and parameters to ignore.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code null}.
+ * Property {@code ignoreAbstractMethods} - Control whether to ignore parameters
+ * of abstract methods.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
*
*
* Property {@code ignoreConstructorParameter} - Control whether to ignore constructor parameters.
@@ -86,6 +86,12 @@
* Default value is {@code false}.
*
*
+ * Property {@code ignoreFormat} - Define the RegExp for names of variables
+ * and parameters to ignore.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code null}.
+ *
+ *
* Property {@code ignoreSetter} - Allow to ignore the parameter of a property setter method.
* Type is {@code boolean}.
* Default value is {@code false}.
@@ -97,12 +103,6 @@
* Default value is {@code false}.
*
*
- * Property {@code ignoreAbstractMethods} - Control whether to ignore parameters
- * of abstract methods.
- * Type is {@code boolean}.
- * Default value is {@code false}.
- *
- *
* Property {@code tokens} - tokens to check
* Type is {@code java.lang.String[]}.
* Validation type is {@code tokenSet}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheck.java
index be72c57f0e8..c9f45eae597 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheck.java
@@ -54,12 +54,6 @@
*
*
*
- * Property {@code methodMaximum} - Specify the maximum allowed number of
- * non commenting lines in a method.
- * Type is {@code int}.
- * Default value is {@code 50}.
- *
- *
* Property {@code classMaximum} - Specify the maximum allowed number of
* non commenting lines in a class.
* Type is {@code int}.
@@ -72,6 +66,12 @@
* Default value is {@code 2000}.
*
*
+ * Property {@code methodMaximum} - Specify the maximum allowed number of
+ * non commenting lines in a method.
+ * Type is {@code int}.
+ * Default value is {@code 50}.
+ *
+ *
* Property {@code recordMaximum} - Specify the maximum allowed number of
* non commenting lines in a record.
* Type is {@code int}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheck.java
index 5cd3fd96c27..b00160abe94 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheck.java
@@ -44,6 +44,12 @@
*
*
*
+ * Property {@code accessModifiers} - Access modifiers of methods where parameters are
+ * checked.
+ * Type is {@code com.puppycrawl.tools.checkstyle.checks.naming.AccessModifierOption[]}.
+ * Default value is {@code public, protected, package, private}.
+ *
+ *
* Property {@code format} - Specifies valid identifiers.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
@@ -54,12 +60,6 @@
* Type is {@code boolean}.
* Default value is {@code false}.
*
- *
- * Property {@code accessModifiers} - Access modifiers of methods where parameters are
- * checked.
- * Type is {@code com.puppycrawl.tools.checkstyle.checks.naming.AccessModifierOption[]}.
- * Default value is {@code public, protected, package, private}.
- *
- * Property {@code files} - Define a Regular Expression matched against the file
- * name associated with an audit event.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code null}.
- *
- *
* Property {@code checks} - Define a Regular Expression matched against the name
* of the check associated with an audit event.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code null}.
*
*
- * Property {@code message} - Define a Regular Expression matched against the message
- * of the check associated with an audit event.
+ * Property {@code files} - Define a Regular Expression matched against the file
+ * name associated with an audit event.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code null}.
*
@@ -73,6 +67,12 @@
* Default value is {@code null}.
*
*
+ * Property {@code message} - Define a Regular Expression matched against the message
+ * of the check associated with an audit event.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code null}.
+ *
+ *
* Property {@code query} - Define a string xpath query.
* Type is {@code java.lang.String}.
* Default value is {@code null}.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/EmptyCatchBlockCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/EmptyCatchBlockCheck.xml
index a8ddfcbb04e..536fd5d9bf6 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/EmptyCatchBlockCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/EmptyCatchBlockCheck.xml
@@ -14,13 +14,6 @@
If both options are specified - they are applied by <b>any of them is matching</b>.
</p>
-
- Specify the RegExp for the name of the variable
- associated with exception. If check meets variable name matching specified value empty
- block is suppressed.
-
@@ -28,6 +21,13 @@
catch block. If check meets comment inside empty catch block matching specified format
empty block is suppressed. If it is multi-line comment only its first line is analyzed.
+
+ Specify the RegExp for the name of the variable
+ associated with exception. If check meets variable name matching specified value empty
+ block is suppressed.
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/HiddenFieldCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/HiddenFieldCheck.xml
index 0bfe6cc4dd5..2d78b9cfc51 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/HiddenFieldCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/HiddenFieldCheck.xml
@@ -43,25 +43,25 @@
<em>ignoreSetter</em> is set to true.
</p>
-
- Define the RegExp for names of variables
- and parameters to ignore.
+
+ Control whether to ignore parameters
+ of abstract methods.Control whether to ignore constructor parameters.
+
+ Define the RegExp for names of variables
+ and parameters to ignore.
+ Allow to ignore the parameter of a property setter method.Allow to expand the definition of a setter method
to include methods that return the class' instance.
-
-
- Control whether to ignore parameters
- of abstract methods.
-
- Specify the maximum allowed number of
- non commenting lines in a method.
- Specify the maximum allowed number of
non commenting lines in a class.
@@ -40,6 +36,10 @@
Specify the maximum allowed number of
non commenting lines in a file including all top level and nested classes.
+
+
+ Specify the maximum allowed number of
+ non commenting lines in a method.Specify the maximum allowed number of
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/ParameterNameCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/ParameterNameCheck.xml
index 7de80c7eb09..151fd85c04a 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/ParameterNameCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/ParameterNameCheck.xml
@@ -20,6 +20,12 @@
LambdaParameterName</a>.
</p>
+
+ Access modifiers of methods where parameters are
+ checked.
+
@@ -29,12 +35,6 @@
Allows to skip methods with Override annotation from
validation.
-
- Access modifiers of methods where parameters are
- checked.
-
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/whitespace/WhitespaceAroundCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/whitespace/WhitespaceAroundCheck.xml
index d16830df4f0..595b3917fa5 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/whitespace/WhitespaceAroundCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/whitespace/WhitespaceAroundCheck.xml
@@ -50,23 +50,23 @@
of the catch block (right curly bracket).
</p>
+
+ Allow empty catch bodies.
+ Allow empty constructor bodies.
-
- Allow empty method bodies.
-
-
- Allow empty class, interface and enum bodies.
+
+ Allow empty lambda bodies.Allow empty loop bodies.
-
- Allow empty lambda bodies.
+
+ Allow empty method bodies.
-
- Allow empty catch bodies.
+
+ Allow empty class, interface and enum bodies.Ignore whitespace around colon in
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressionXpathSingleFilter.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressionXpathSingleFilter.xml
index 2f2dcef7f23..33d3be0c3ec 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressionXpathSingleFilter.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressionXpathSingleFilter.xml
@@ -26,21 +26,21 @@
SuppressionXpathSingleFilter can suppress Checks that have Treewalker as parent module.
</p>
-
- Define a Regular Expression matched against the file
- name associated with an audit event.
- Define a Regular Expression matched against the name
of the check associated with an audit event.
-
- Define a Regular Expression matched against the message
- of the check associated with an audit event.
+
+ Define a Regular Expression matched against the file
+ name associated with an audit event.Define a string matched against the ID of the check
associated with an audit event.
+
+
+ Define a Regular Expression matched against the message
+ of the check associated with an audit event.Define a string xpath query.
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index f4d6cf5f5ad..0e835b4ec56 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -244,12 +244,6 @@ public class XdocsPagesTest {
"RecordComponentNumber",
"RegexpSingleline",
"RegexpOnFilename",
- "JavaNCSS",
- "EmptyCatchBlock",
- "ParameterName",
- "HiddenField",
- "SuppressionXpathSingleFilter",
- "WhitespaceAround",
"RegexpSinglelineJava",
"ImportOrder",
"IllegalType",
diff --git a/src/xdocs/checks/blocks/emptycatchblock.xml b/src/xdocs/checks/blocks/emptycatchblock.xml
index 2544800e2ac..1d38f3a4d78 100644
--- a/src/xdocs/checks/blocks/emptycatchblock.xml
+++ b/src/xdocs/checks/blocks/emptycatchblock.xml
@@ -34,24 +34,24 @@
since
-
exceptionVariableName
+
commentFormat
- Specify the RegExp for the name of the variable associated with exception.
- If check meets variable name matching specified value - empty block is suppressed.
+ Specify the RegExp for the first comment inside empty catch block.
+ If check meets comment inside empty catch block matching specified format - empty
+ block is suppressed. If it is multi-line comment - only its first line is analyzed.
- Specify the RegExp for the first comment inside empty catch block.
- If check meets comment inside empty catch block matching specified format - empty
- block is suppressed. If it is multi-line comment - only its first line is analyzed.
+ Specify the RegExp for the name of the variable associated with exception.
+ If check meets variable name matching specified value - empty block is suppressed.
- Specify the RegExp for the name of the variable associated with exception.
- If check meets variable name matching specified value - empty block is suppressed.
+ Specify the RegExp for the first comment inside empty catch block.
+ If check meets comment inside empty catch block matching specified format - empty
+ block is suppressed. If it is multi-line comment - only its first line is analyzed.
- Specify the RegExp for the first comment inside empty catch block.
- If check meets comment inside empty catch block matching specified format - empty
- block is suppressed. If it is multi-line comment - only its first line is analyzed.
+ Specify the RegExp for the name of the variable associated with exception.
+ If check meets variable name matching specified value - empty block is suppressed.
- * 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}
- * Type is {@code java.lang.String[]}.
- * Default value is {@code .properties}.
- *
- *
* Property {@code baseName} - Specify
*
* Base name of resource bundles which contain message resources.
@@ -121,6 +113,14 @@
* Default value is {@code "^messages.*$"}.
*
*
+ * 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}
+ * Type is {@code java.lang.String[]}.
+ * Default value is {@code .properties}.
+ *
+ *
* Property {@code requiredTranslations} - Specify language codes of required
* translations which must exist in project.
* Type is {@code java.lang.String[]}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheck.java
index f6bbea4ba65..82b117de3f1 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheck.java
@@ -68,6 +68,12 @@
*
*
*
+ * Property {@code arrayInitIndent} - Specify how far an array initialisation
+ * should be indented when on next line.
+ * Type is {@code int}.
+ * Default value is {@code 4}.
+ *
+ *
* Property {@code basicOffset} - Specify how far new indentation level should be
* indented when on the next line.
* Type is {@code int}.
@@ -86,16 +92,12 @@
* Default value is {@code 4}.
*
*
- * Property {@code throwsIndent} - Specify how far a throws clause should be
- * indented when on next line.
- * Type is {@code int}.
- * Default value is {@code 4}.
- *
- *
- * Property {@code arrayInitIndent} - Specify how far an array initialisation
- * should be indented when on next line.
- * Type is {@code int}.
- * Default value is {@code 4}.
+ * Property {@code forceStrictCondition} - Force strict indent level in line
+ * wrapping case. If value is true, line wrap indent have to be same as
+ * lineWrappingIndentation parameter. If value is false, line wrap indent
+ * could be bigger on any value user would like.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
*
*
* Property {@code lineWrappingIndentation} - Specify how far continuation line
@@ -104,12 +106,10 @@
* Default value is {@code 4}.
*
*
- * Property {@code forceStrictCondition} - Force strict indent level in line
- * wrapping case. If value is true, line wrap indent have to be same as
- * lineWrappingIndentation parameter. If value is false, line wrap indent
- * could be bigger on any value user would like.
- * Type is {@code boolean}.
- * Default value is {@code false}.
+ * Property {@code throwsIndent} - Specify how far a throws clause should be
+ * indented when on next line.
+ * Type is {@code int}.
+ * Default value is {@code 4}.
*
- * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations if the
- * Javadoc being examined by this check violates the tight html rules defined at
- * Tight-HTML Rules.
- * Type is {@code boolean}.
- * Default value is {@code false}.
+ * Property {@code tagOrder} - Specify the order by tags.
+ * Type is {@code java.lang.String[]}.
+ * Default value is
+ * {@code @author, @deprecated, @exception, @param, @return, @see, @serial, @serialData, @serialField, @since, @throws, @version}.
*
- * Property {@code tagOrder} - Specify the order by tags.
- * Type is {@code java.lang.String[]}.
- * Default value is
- * {@code @author, @deprecated, @exception, @param, @return, @see, @serial, @serialData, @serialField, @since, @throws, @version}.
+ * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations if the
+ * Javadoc being examined by this check violates the tight html rules defined at
+ * Tight-HTML Rules.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
*
- * Property {@code format} - Specifies valid identifiers.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
- *
- *
* 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:
@@ -56,25 +51,30 @@
* Default value is {@code false}.
*
*
- * Property {@code applyToPublic} - Controls whether to apply the check to public member.
+ * Property {@code applyToPackage} - Controls whether to apply the check to package-private member.
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
- * Property {@code applyToProtected} - Controls whether to apply the check to protected member.
+ * Property {@code applyToPrivate} - Controls whether to apply the check to private member.
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
- * Property {@code applyToPackage} - Controls whether to apply the check to package-private member.
+ * Property {@code applyToProtected} - Controls whether to apply the check to protected member.
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
- * Property {@code applyToPrivate} - Controls whether to apply the check to private member.
+ * Property {@code applyToPublic} - Controls whether to apply the check to public member.
* Type is {@code boolean}.
* Default value is {@code true}.
*
+ *
+ * Property {@code format} - Specifies valid identifiers.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
+ *
*
*
* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker}
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/TranslationCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/TranslationCheck.xml
index a4481897e08..60be31467ce 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/TranslationCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/TranslationCheck.xml
@@ -55,14 +55,6 @@
<a href="https://github.com/checkstyle/checkstyle/issues/3539">issue</a>.
</p>
-
- 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}
-
@@ -70,6 +62,14 @@
<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.
+
+
+ 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}
+
+ Specify how far an array initialisation
+ should be indented when on next line.
+ Specify how far new indentation level should be
indented when on the next line.
@@ -53,18 +57,6 @@
Specify how far a case label should be indented
when on next line.
-
-
- Specify how far a throws clause should be
- indented when on next line.
-
-
- Specify how far an array initialisation
- should be indented when on next line.
-
-
- Specify how far continuation line
- should be indented when line-wrapping is present.Force strict indent level in line
@@ -72,6 +64,14 @@
lineWrappingIndentation parameter. If value is false, line wrap indent
could be bigger on any value user would like.
+
+ Specify how far continuation line
+ should be indented when line-wrapping is present.
+
+
+ Specify how far a throws clause should be
+ indented when on next line.
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/AtclauseOrderCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/AtclauseOrderCheck.xml
index d8398fa6ced..b81560a250a 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/AtclauseOrderCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/AtclauseOrderCheck.xml
@@ -13,12 +13,10 @@
Note: Google used the term "at-clauses" for block tags in their guide till 2017-02-28.
</p>
-
- Control when to print violations if the
- Javadoc being examined by this check violates the tight html rules defined at
- <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>.
+
+ Specify the order by tags.Specify block tags targeted.
-
- Specify the order by tags.
+
+ Control when to print violations if the
+ Javadoc being examined by this check violates the tight html rules defined at
+ <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/MethodNameCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/MethodNameCheck.xml
index 0477dac78be..2df037c68f7 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/MethodNameCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/MethodNameCheck.xml
@@ -16,11 +16,6 @@
have a choice in renaming such methods.
</p>
-
- Specifies valid identifiers.
- 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
@@ -32,18 +27,23 @@
}
</pre>
-
- Controls whether to apply the check to public member.
-
-
- Controls whether to apply the check to protected member.
- Controls whether to apply the check to package-private member.Controls whether to apply the check to private member.
+
+ Controls whether to apply the check to protected member.
+
+
+ Controls whether to apply the check to public member.
+
+
+ Specifies valid identifiers.
+
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index 0e835b4ec56..e4b11d4988d 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -228,11 +228,6 @@ public class XdocsPagesTest {
// until https://github.com/checkstyle/checkstyle/issues/13666
private static final Set MODULES_WITH_UNORDERED_PROPERTIES = Set.of(
- "Checker",
- "Translation",
- "Indentation",
- "MethodName",
- "AtclauseOrder",
"SuppressWithNearbyTextFilter",
"SuppressWithPlainTextCommentFilter",
"MemberName",
diff --git a/src/xdocs/checks/javadoc/atclauseorder.xml b/src/xdocs/checks/javadoc/atclauseorder.xml
index ef2add798d3..e5b32250485 100644
--- a/src/xdocs/checks/javadoc/atclauseorder.xml
+++ b/src/xdocs/checks/javadoc/atclauseorder.xml
@@ -30,16 +30,13 @@
since
-
violateExecutionOnNonTightHtml
-
- Control when to print violations if the Javadoc being examined by this check
- violates the tight html rules defined at
- Tight-HTML Rules.
-
Force strict indent level in line wrapping case. If value is true, line wrap
+ indent have to be same as lineWrappingIndentation parameter. If value is false,
+ line wrap indent could be bigger on any value user would like.
@@ -104,13 +106,11 @@ if ((condition1 && condition2)
5.9
-
forceStrictCondition
-
Force strict indent level in line wrapping case. If value is true, line wrap
- indent have to be same as lineWrappingIndentation parameter. If value is false,
- line wrap indent could be bigger on any value user would like.
Force strict indent level in line wrapping case. If value is true, line wrap
+ indent have to be same as lineWrappingIndentation parameter. If value is false,
+ line wrap indent could be bigger on any value user would like.
@@ -104,13 +106,11 @@ if ((condition1 && condition2)
5.9
-
forceStrictCondition
-
Force strict indent level in line wrapping case. If value is true, line wrap
- indent have to be same as lineWrappingIndentation parameter. If value is false,
- line wrap indent could be bigger on any value user would like.
- * Property {@code ignoreNumbers} - Specify non-magic numbers.
- * Type is {@code double[]}.
- * Default value is {@code -1, 0, 1, 2}.
- *
- *
- * Property {@code ignoreHashCodeMethod} - Ignore magic numbers in hashCode methods.
- * Type is {@code boolean}.
- * Default value is {@code false}.
- *
- *
- * Property {@code ignoreAnnotation} - Ignore magic numbers in annotation declarations.
- * Type is {@code boolean}.
- * Default value is {@code false}.
- *
- *
- * Property {@code ignoreFieldDeclaration} - Ignore magic numbers in field declarations.
- * Type is {@code boolean}.
- * Default value is {@code false}.
- *
- *
- * Property {@code ignoreAnnotationElementDefaults} -
- * Ignore magic numbers in annotation elements defaults.
- * Type is {@code boolean}.
- * Default value is {@code true}.
- *
- *
* Property {@code constantWaiverParentToken} - Specify tokens that are allowed in the AST path
* from the number literal to the enclosing constant definition.
* Type is {@code java.lang.String[]}.
@@ -114,6 +88,32 @@
* UNARY_PLUS.
*
*
+ * Property {@code ignoreAnnotation} - Ignore magic numbers in annotation declarations.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
+ *
+ *
+ * Property {@code ignoreAnnotationElementDefaults} -
+ * Ignore magic numbers in annotation elements defaults.
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
+ *
+ *
+ * Property {@code ignoreFieldDeclaration} - Ignore magic numbers in field declarations.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
+ *
+ *
+ * Property {@code ignoreHashCodeMethod} - Ignore magic numbers in hashCode methods.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
+ *
+ *
+ * Property {@code ignoreNumbers} - Specify non-magic numbers.
+ * Type is {@code double[]}.
+ * Default value is {@code -1, 0, 1, 2}.
+ *
+ *
* Property {@code tokens} - tokens to check
* Type is {@code java.lang.String[]}.
* Validation type is {@code tokenSet}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheck.java
index cc69296d0e2..f6c4a81a2f8 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheck.java
@@ -55,15 +55,15 @@
*
*
*
- * Property {@code max} - Specify maximum allowed number of throws statements.
- * Type is {@code int}.
- * Default value is {@code 4}.
- *
- *
* Property {@code ignorePrivateMethods} - Allow private methods to be ignored.
* Type is {@code boolean}.
* Default value is {@code true}.
*
+ *
+ * Property {@code max} - Specify maximum allowed number of throws statements.
+ * Type is {@code int}.
+ * Default value is {@code 4}.
+ *
- * Property {@code headerFile} - Specify the name of the file containing the required header.
- * Type is {@code java.net.URI}.
- * Default value is {@code null}.
- *
- *
* Property {@code charset} - Specify the character encoding to use when reading the headerFile.
* Type is {@code java.lang.String}.
* Default value is {@code the charset property of the parent
* Checker module}.
*
*
+ * Property {@code fileExtensions} - Specify the file type extension of files to process.
+ * Type is {@code java.lang.String[]}.
+ * Default value is {@code ""}.
+ *
+ *
* Property {@code header} - Define the required header specified inline.
* Individual header lines must be separated by the string {@code "\n"}
* (even on platforms with a different line separator).
@@ -119,13 +119,13 @@
* Default value is {@code null}.
*
*
- * Property {@code multiLines} - Specify the line numbers to repeat (zero or more times).
- * Type is {@code int[]}.
- * Default value is {@code ""}.
+ * Property {@code headerFile} - Specify the name of the file containing the required header.
+ * Type is {@code java.net.URI}.
+ * Default value is {@code null}.
*
*
- * Property {@code fileExtensions} - Specify the file type extension of files to process.
- * Type is {@code java.lang.String[]}.
+ * Property {@code multiLines} - Specify the line numbers to repeat (zero or more times).
+ * Type is {@code int[]}.
* Default value is {@code ""}.
*
- * Property {@code format} - Specifies valid identifiers.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "^[A-Z][a-zA-Z0-9]*$"}.
+ * Property {@code applyToPackage} - Controls whether to apply the check to package-private member.
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
*
*
- * Property {@code applyToPublic} - Controls whether to apply the check to public member.
+ * Property {@code applyToPrivate} - Controls whether to apply the check to private member.
* Type is {@code boolean}.
* Default value is {@code true}.
*
@@ -43,14 +43,14 @@
* Default value is {@code true}.
*
*
- * Property {@code applyToPackage} - Controls whether to apply the check to package-private member.
+ * Property {@code applyToPublic} - Controls whether to apply the check to public member.
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
- * Property {@code applyToPrivate} - Controls whether to apply the check to private member.
- * Type is {@code boolean}.
- * Default value is {@code true}.
+ * Property {@code format} - Specifies valid identifiers.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "^[A-Z][a-zA-Z0-9]*$"}.
*
- * Property {@code max} - Specify the maximum number of lines allowed.
- * Type is {@code int}.
- * Default value is {@code 2000}.
- *
- *
* Property {@code fileExtensions} - Specify the file type extension of files to process.
* Type is {@code java.lang.String[]}.
* Default value is {@code ""}.
*
+ *
+ * Property {@code max} - Specify the maximum number of lines allowed.
+ * Type is {@code int}.
+ * Default value is {@code 2000}.
+ *
- * Property {@code offCommentFormat} - Specify comment pattern to
- * trigger filter to begin suppression.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "CHECKSTYLE:OFF"}.
+ * Property {@code checkC} - Control whether to check C style comments ({@code /* ... */}).
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
*
*
- * Property {@code onCommentFormat} - Specify comment pattern to trigger filter to end suppression.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "CHECKSTYLE:ON"}.
+ * Property {@code checkCPP} - Control whether to check C++ style comments ({@code //}).
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
*
*
* Property {@code checkFormat} - Specify check pattern to suppress.
@@ -88,24 +87,25 @@
* Default value is {@code ".*"}.
*
*
- * Property {@code messageFormat} - Specify message pattern to suppress.
+ * Property {@code idFormat} - Specify check ID pattern to suppress.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code null}.
*
*
- * Property {@code idFormat} - Specify check ID pattern to suppress.
+ * Property {@code messageFormat} - Specify message pattern to suppress.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code null}.
*
*
- * Property {@code checkCPP} - Control whether to check C++ style comments ({@code //}).
- * Type is {@code boolean}.
- * Default value is {@code true}.
+ * Property {@code offCommentFormat} - Specify comment pattern to
+ * trigger filter to begin suppression.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "CHECKSTYLE:OFF"}.
*
*
- * Property {@code checkC} - Control whether to check C style comments ({@code /* ... */}).
- * Type is {@code boolean}.
- * Default value is {@code true}.
+ * Property {@code onCommentFormat} - Specify comment pattern to trigger filter to end suppression.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "CHECKSTYLE:ON"}.
*
*
*
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/MagicNumberCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/MagicNumberCheck.xml
index a3e46bed9a7..bdd2f2a822a 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/MagicNumberCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/MagicNumberCheck.xml
@@ -24,29 +24,29 @@
static final Integer ANSWER_TO_THE_ULTIMATE_QUESTION_OF_LIFE = new Integer(42);
</pre>
-
- Specify non-magic numbers.
-
-
- Ignore magic numbers in hashCode methods.
+
+ Specify tokens that are allowed in the AST path
+ from the number literal to the enclosing constant definition.Ignore magic numbers in annotation declarations.
-
- Ignore magic numbers in field declarations.
- Ignore magic numbers in annotation elements defaults.
-
- Specify tokens that are allowed in the AST path
- from the number literal to the enclosing constant definition.
+
+ Ignore magic numbers in field declarations.
+
+
+ Ignore magic numbers in hashCode methods.
+
+
+ Specify non-magic numbers.
-
- Specify maximum allowed number of throws statements.
- Allow private methods to be ignored.
+
+ Specify maximum allowed number of throws statements.
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/header/RegexpHeaderCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/header/RegexpHeaderCheck.xml
index 02ef4572c45..89b612b63cf 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/header/RegexpHeaderCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/header/RegexpHeaderCheck.xml
@@ -69,12 +69,12 @@
of header is set to null and the check does not rise any violations.
</p>
-
- Specify the name of the file containing the required header.
- Specify the character encoding to use when reading the headerFile.
+
+ Specify the file type extension of files to process.
+ Define the required header specified inline.
Individual header lines must be separated by the string {@code "\n"}
@@ -83,12 +83,12 @@
forcefully expect an empty line to exist. See examples below.
Regular expressions must not span multiple lines.
+
+ Specify the name of the file containing the required header.
+ Specify the line numbers to repeat (zero or more times).
-
- Specify the file type extension of files to process.
-
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/TypeNameCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/TypeNameCheck.xml
index 264dc7f74b2..7e701a56313 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/TypeNameCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/TypeNameCheck.xml
@@ -8,22 +8,22 @@
Checks that type names conform to a specified pattern.
</p>
-
- Specifies valid identifiers.
+
+ Controls whether to apply the check to package-private member.
-
- Controls whether to apply the check to public member.
+
+ Controls whether to apply the check to private member.Controls whether to apply the check to protected member.
-
- Controls whether to apply the check to package-private member.
+
+ Controls whether to apply the check to public member.
-
- Controls whether to apply the check to private member.
+
+ Specifies valid identifiers.
-
- Specify the maximum number of lines allowed.
- Specify the file type extension of files to process.
+
+ Specify the maximum number of lines allowed.
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressionCommentFilter.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressionCommentFilter.xml
index 616c52b16df..7a7e9659228 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressionCommentFilter.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressionCommentFilter.xml
@@ -36,33 +36,33 @@
SuppressionCommentFilter can suppress Checks that have Treewalker as parent module.
</p>
-
- Specify comment pattern to
- trigger filter to begin suppression.
+
+ Control whether to check C style comments ({@code /* ... */}).
-
- Specify comment pattern to trigger filter to end suppression.
+
+ Control whether to check C++ style comments ({@code //}).Specify check pattern to suppress.
-
- Specify message pattern to suppress.
- Specify check ID pattern to suppress.
-
- Control whether to check C++ style comments ({@code //}).
+
+ Specify message pattern to suppress.
-
- Control whether to check C style comments ({@code /* ... */}).
+
+ Specify comment pattern to
+ trigger filter to begin suppression.
+
+
+ Specify comment pattern to trigger filter to end suppression.
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index e4b11d4988d..26d084d7700 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -251,12 +251,6 @@ public class XdocsPagesTest {
"NewlineAtEndOfFile",
"SingleLineJavadoc",
"MissingJavadocType",
- "FileLength",
- "RegexpHeader",
- "ThrowsCount",
- "SuppressionCommentFilter",
- "TypeName",
- "MagicNumber",
"NeedBraces",
"SeverityMatchFilter",
"SuppressWithNearbyCommentFilter",
diff --git a/src/xdocs/checks/coding/magicnumber.xml b/src/xdocs/checks/coding/magicnumber.xml
index 934d3346916..f26ee97a55c 100644
--- a/src/xdocs/checks/coding/magicnumber.xml
+++ b/src/xdocs/checks/coding/magicnumber.xml
@@ -40,41 +40,6 @@ static final Integer ANSWER_TO_THE_ULTIMATE_QUESTION_OF_LIFE = new Integer(42);
Specify tokens that are allowed in the AST path from the number literal to the
@@ -112,6 +77,41 @@ static final Integer ANSWER_TO_THE_ULTIMATE_QUESTION_OF_LIFE = new Integer(42);
Specify tokens that are allowed in the AST path from the number literal to the
@@ -112,6 +77,41 @@ static final Integer ANSWER_TO_THE_ULTIMATE_QUESTION_OF_LIFE = new Integer(42);
- * Property {@code excludes} - Specify packages where starred class imports are
- * allowed and classes where starred static member imports are allowed.
- * Type is {@code java.lang.String[]}.
- * Default value is {@code ""}.
- *
- *
* Property {@code allowClassImports} - Control whether to allow starred class
* imports like {@code import java.util.*;}.
* Type is {@code boolean}.
@@ -61,6 +55,12 @@
* Type is {@code boolean}.
* Default value is {@code false}.
*
+ *
+ * Property {@code excludes} - Specify packages where starred class imports are
+ * allowed and classes where starred static member imports are allowed.
+ * Type is {@code java.lang.String[]}.
+ * Default value is {@code ""}.
+ *
- * Property {@code format} - Specifies valid identifiers.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
+ * Property {@code applyToPackage} - Controls whether to apply the check to package-private member.
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
*
*
- * Property {@code applyToPublic} - Controls whether to apply the check to public member.
+ * Property {@code applyToPrivate} - Controls whether to apply the check to private member.
* Type is {@code boolean}.
* Default value is {@code true}.
*
@@ -44,14 +44,14 @@
* Default value is {@code true}.
*
*
- * Property {@code applyToPackage} - Controls whether to apply the check to package-private member.
+ * Property {@code applyToPublic} - Controls whether to apply the check to public member.
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
- * Property {@code applyToPrivate} - Controls whether to apply the check to private member.
- * Type is {@code boolean}.
- * Default value is {@code true}.
+ * Property {@code format} - Specifies valid identifiers.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
*
- * Property {@code nearbyTextPattern} - Specify nearby text
- * pattern to trigger filter to begin suppression.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "SUPPRESS CHECKSTYLE (\w+)"}.
- *
- *
* Property {@code checkPattern} - Specify check name pattern to suppress.
* Property can also be a RegExp group index at {@code nearbyTextPattern} in
* format of {@code $x} and be picked from line that matches {@code nearbyTextPattern}.
@@ -64,11 +58,6 @@
* Default value is {@code ".*"}.
*
*
- * Property {@code messagePattern} - Specify check violation message pattern to suppress.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code null}.
- *
- *
* Property {@code idPattern} - Specify check ID pattern to suppress.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code null}.
@@ -81,6 +70,17 @@
* Type is {@code java.lang.String}.
* Default value is {@code "0"}.
*
+ *
+ * Property {@code messagePattern} - Specify check violation message pattern to suppress.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code null}.
+ *
+ *
+ * Property {@code nearbyTextPattern} - Specify nearby text
+ * pattern to trigger filter to begin suppression.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "SUPPRESS CHECKSTYLE (\w+)"}.
+ *
- * Property {@code offCommentFormat} - Specify comment pattern to trigger filter
- * to begin suppression.
+ * Property {@code checkFormat} - Specify check pattern to suppress.
* Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "// CHECKSTYLE:OFF"}.
+ * Default value is {@code ".*"}.
*
*
- * Property {@code onCommentFormat} - Specify comment pattern to trigger filter
- * to end suppression.
+ * Property {@code idFormat} - Specify check ID pattern to suppress.
* Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "// CHECKSTYLE:ON"}.
+ * Default value is {@code null}.
*
*
- * Property {@code checkFormat} - Specify check pattern to suppress.
+ * Property {@code messageFormat} - Specify message pattern to suppress.
* Type is {@code java.util.regex.Pattern}.
- * Default value is {@code ".*"}.
+ * Default value is {@code null}.
*
*
- * Property {@code messageFormat} - Specify message pattern to suppress.
+ * Property {@code offCommentFormat} - Specify comment pattern to trigger filter
+ * to begin suppression.
* Type is {@code java.util.regex.Pattern}.
- * Default value is {@code null}.
+ * Default value is {@code "// CHECKSTYLE:OFF"}.
*
*
- * Property {@code idFormat} - Specify check ID pattern to suppress.
+ * Property {@code onCommentFormat} - Specify comment pattern to trigger filter
+ * to end suppression.
* Type is {@code java.util.regex.Pattern}.
- * Default value is {@code null}.
+ * Default value is {@code "// CHECKSTYLE:ON"}.
*
*
*
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/AvoidStarImportCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/AvoidStarImportCheck.xml
index 55f091254bb..1ed368b606c 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/AvoidStarImportCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/AvoidStarImportCheck.xml
@@ -18,10 +18,6 @@
packages are not automatically excluded.
</p>
-
- Specify packages where starred class imports are
- allowed and classes where starred static member imports are allowed.
- Control whether to allow starred class
imports like {@code import java.util.*;}.
@@ -32,6 +28,10 @@
Control whether to allow starred
static member imports like {@code import static org.junit.Assert.*;}.
+
+ Specify packages where starred class imports are
+ allowed and classes where starred static member imports are allowed.
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/MemberNameCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/MemberNameCheck.xml
index d1811306a00..d29ddf7e330 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/MemberNameCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/MemberNameCheck.xml
@@ -8,22 +8,22 @@
Checks that instance variable names conform to a specified pattern.
</p>
-
- Specifies valid identifiers.
+
+ Controls whether to apply the check to package-private member.
-
- Controls whether to apply the check to public member.
+
+ Controls whether to apply the check to private member.Controls whether to apply the check to protected member.
-
- Controls whether to apply the check to package-private member.
+
+ Controls whether to apply the check to public member.
-
- Controls whether to apply the check to private member.
+
+ Specifies valid identifiers.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressWithNearbyTextFilter.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressWithNearbyTextFilter.xml
index 93a1b513805..7bdf2434d5f 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressWithNearbyTextFilter.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressWithNearbyTextFilter.xml
@@ -15,12 +15,6 @@
out of the rest of the file as a suppression. See the default value as an example.
</p>
-
- Specify nearby text
- pattern to trigger filter to begin suppression.
-
@@ -28,9 +22,6 @@
Property can also be a RegExp group index at {@code nearbyTextPattern} in
format of {@code $x} and be picked from line that matches {@code nearbyTextPattern}.
-
- Specify check violation message pattern to suppress.
- Specify check ID pattern to suppress.
@@ -40,6 +31,15 @@
Property can also be a RegExp group index at {@code nearbyTextPattern} in
format of {@code $x} and be picked from line that matches {@code nearbyTextPattern}.
+
+ Specify check violation message pattern to suppress.
+
+
+ Specify nearby text
+ pattern to trigger filter to begin suppression.
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressWithPlainTextCommentFilter.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressWithPlainTextCommentFilter.xml
index 5cd295c24c9..0eb9f49625e 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressWithPlainTextCommentFilter.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressWithPlainTextCommentFilter.xml
@@ -40,6 +40,17 @@
Checker as parent module.
</p>
+
+ Specify check pattern to suppress.
+
+
+ Specify check ID pattern to suppress.
+
+
+ Specify message pattern to suppress.
+
@@ -52,17 +63,6 @@
Specify comment pattern to trigger filter
to end suppression.
-
- Specify check pattern to suppress.
-
-
- Specify message pattern to suppress.
-
-
- Specify check ID pattern to suppress.
-
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index 26d084d7700..76e5621307c 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -228,10 +228,6 @@ public class XdocsPagesTest {
// until https://github.com/checkstyle/checkstyle/issues/13666
private static final Set MODULES_WITH_UNORDERED_PROPERTIES = Set.of(
- "SuppressWithNearbyTextFilter",
- "SuppressWithPlainTextCommentFilter",
- "MemberName",
- "AvoidStarImport",
"ReturnCount",
"StaticVariableName",
"AvoidEscapedUnicodeCharacters",
diff --git a/src/xdocs/checks/imports/avoidstarimport.xml b/src/xdocs/checks/imports/avoidstarimport.xml
index fa1468c95d7..b8678aa6296 100644
--- a/src/xdocs/checks/imports/avoidstarimport.xml
+++ b/src/xdocs/checks/imports/avoidstarimport.xml
@@ -38,17 +38,6 @@
default value
since
-
-
excludes
-
- Specify packages where starred class imports are
- allowed and classes where starred static member imports are
- allowed.
-
- * Property {@code allowEscapesForControlCharacters} - Allow use escapes for
- * non-printable, control characters.
+ * Property {@code allowByTailComment} - Allow use escapes if trail comment is present.
* Type is {@code boolean}.
* Default value is {@code false}.
*
*
- * Property {@code allowByTailComment} - Allow use escapes if trail comment is present.
+ * Property {@code allowEscapesForControlCharacters} - Allow use escapes for
+ * non-printable, control characters.
* Type is {@code boolean}.
* Default value is {@code false}.
*
+ * Property {@code format} - Specify method names to ignore.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "^equals$"}.
+ *
+ *
* Property {@code max} - Specify maximum allowed number of return statements
* in non-void methods/lambdas.
* Type is {@code int}.
@@ -63,11 +68,6 @@
* Default value is {@code 1}.
*
*
- * Property {@code format} - Specify method names to ignore.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "^equals$"}.
- *
- *
* Property {@code tokens} - tokens to check
* Type is {@code java.lang.String[]}.
* Validation type is {@code tokenSet}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/StaticVariableNameCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/StaticVariableNameCheck.java
index 469a07bad3b..04cce0bf82f 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/StaticVariableNameCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/StaticVariableNameCheck.java
@@ -29,12 +29,12 @@
*
*
*
- * Property {@code format} - Specifies valid identifiers.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
+ * Property {@code applyToPackage} - Controls whether to apply the check to package-private member.
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
*
*
- * Property {@code applyToPublic} - Controls whether to apply the check to public member.
+ * Property {@code applyToPrivate} - Controls whether to apply the check to private member.
* Type is {@code boolean}.
* Default value is {@code true}.
*
@@ -44,14 +44,14 @@
* Default value is {@code true}.
*
*
- * Property {@code applyToPackage} - Controls whether to apply the check to package-private member.
+ * Property {@code applyToPublic} - Controls whether to apply the check to public member.
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
- * Property {@code applyToPrivate} - Controls whether to apply the check to private member.
- * Type is {@code boolean}.
- * Default value is {@code true}.
+ * Property {@code format} - Specifies valid identifiers.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "^[a-z][a-zA-Z0-9]*$"}.
*
- * Property {@code max} - Specify the maximum number of parameters allowed.
- * Type is {@code int}.
- * Default value is {@code 7}.
- *
- *
* Property {@code ignoreOverriddenMethods} - Ignore number of parameters for
* methods with {@code @Override} annotation.
* Type is {@code boolean}.
* Default value is {@code false}.
*
*
+ * Property {@code max} - Specify the maximum number of parameters allowed.
+ * Type is {@code int}.
+ * Default value is {@code 7}.
+ *
+ *
* Property {@code tokens} - tokens to check
* Type is {@code java.lang.String[]}.
* Validation type is {@code tokenSet}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/RecordComponentNumberCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/RecordComponentNumberCheck.java
index 47466a3b0de..e1429c13785 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/RecordComponentNumberCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/RecordComponentNumberCheck.java
@@ -38,17 +38,17 @@
*
*
*
- * Property {@code max} - Specify the maximum number of components allowed in the header of a
- * record definition.
- * Type is {@code int}.
- * Default value is {@code 8}.
- *
- *
* Property {@code accessModifiers} - Access modifiers of record definitions where
* the number of record components should be checked.
* Type is {@code com.puppycrawl.tools.checkstyle.checks.naming.AccessModifierOption[]}.
* Default value is {@code public, protected, package, private}.
*
+ *
+ * Property {@code max} - Specify the maximum number of components allowed in the header of a
+ * record definition.
+ * Type is {@code int}.
+ * Default value is {@code 8}.
+ *
*
*
* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker}
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/AvoidEscapedUnicodeCharactersCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/AvoidEscapedUnicodeCharactersCheck.xml
index 3be5cc38bbc..0a09a1ce4ce 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/AvoidEscapedUnicodeCharactersCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/AvoidEscapedUnicodeCharactersCheck.xml
@@ -16,15 +16,15 @@
allow using escapes if literal contains only them.
</p>
+
+ Allow use escapes if trail comment is present.
+ Allow use escapes for
non-printable, control characters.
-
- Allow use escapes if trail comment is present.
-
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/ReturnCountCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/ReturnCountCheck.xml
index e07af877fd4..715e534ba43 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/ReturnCountCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/ReturnCountCheck.xml
@@ -25,6 +25,11 @@
attempting to do too much or may be difficult to understand.
</p>
+
+ Specify method names to ignore.
+ Specify maximum allowed number of return statements
in non-void methods/lambdas.
@@ -33,11 +38,6 @@
Specify maximum allowed number of return statements
in void methods/constructors/lambdas.
-
- Specify method names to ignore.
-
-
- Specifies valid identifiers.
+
+ Controls whether to apply the check to package-private member.
-
- Controls whether to apply the check to public member.
+
+ Controls whether to apply the check to private member.Controls whether to apply the check to protected member.
-
- Controls whether to apply the check to package-private member.
+
+ Controls whether to apply the check to public member.
-
- Controls whether to apply the check to private member.
+
+ Specifies valid identifiers.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/sizes/ParameterNumberCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/sizes/ParameterNumberCheck.xml
index 69bf51bd1b3..b12bf9520ad 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/sizes/ParameterNumberCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/sizes/ParameterNumberCheck.xml
@@ -8,13 +8,13 @@
Checks the number of parameters of a method or constructor.
</p>
-
- Specify the maximum number of parameters allowed.
- Ignore number of parameters for
methods with {@code @Override} annotation.
+
+ Specify the maximum number of parameters allowed.
+
-
- Specify the maximum number of components allowed in the header of a
- record definition.
- Access modifiers of record definitions where
the number of record components should be checked.
+
+ Specify the maximum number of components allowed in the header of a
+ record definition.
+
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index 76e5621307c..d28c4d6af99 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -228,11 +228,6 @@ public class XdocsPagesTest {
// until https://github.com/checkstyle/checkstyle/issues/13666
private static final Set MODULES_WITH_UNORDERED_PROPERTIES = Set.of(
- "ReturnCount",
- "StaticVariableName",
- "AvoidEscapedUnicodeCharacters",
- "ParameterNumber",
- "RecordComponentNumber",
"RegexpSingleline",
"RegexpOnFilename",
"RegexpSinglelineJava",
diff --git a/src/xdocs/checks/coding/returncount.xml b/src/xdocs/checks/coding/returncount.xml
index d5a557833ad..432c26ada92 100644
--- a/src/xdocs/checks/coding/returncount.xml
+++ b/src/xdocs/checks/coding/returncount.xml
@@ -43,6 +43,13 @@
- * Property {@code validateAbstractClassNames} - Control whether to validate abstract class names.
- * Type is {@code boolean}.
- * Default value is {@code false}.
+ * Property {@code ignoredMethodNames} - Specify methods that should not be checked.
+ * Type is {@code java.lang.String[]}.
+ * Default value is {@code getEnvironment, getInitialContext}.
+ *
+ *
+ * Property {@code illegalAbstractClassNameFormat} - Specify RegExp for illegal abstract class
+ * names.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "^(.*[.])?Abstract.*$"}.
*
*
* Property {@code illegalClassNames} - Specify classes that should not be used
@@ -99,17 +105,6 @@
* Default value is {@code ""}.
*
*
- * Property {@code ignoredMethodNames} - Specify methods that should not be checked.
- * Type is {@code java.lang.String[]}.
- * Default value is {@code getEnvironment, getInitialContext}.
- *
- *
- * Property {@code illegalAbstractClassNameFormat} - Specify RegExp for illegal abstract class
- * names.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "^(.*[.])?Abstract.*$"}.
- *
- *
* Property {@code memberModifiers} - Control whether to check only methods and fields with any
* of the specified modifiers.
* This property does not affect method calls nor method references nor record components.
@@ -118,6 +113,11 @@
* Default value is {@code ""}.
*
*
+ * Property {@code validateAbstractClassNames} - Control whether to validate abstract class names.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
+ *
+ *
* Property {@code tokens} - tokens to check
* Type is {@code java.lang.String[]}.
* Validation type is {@code tokenSet}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheck.java
index 9c189834412..74bbb7da874 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheck.java
@@ -50,12 +50,12 @@
*
*
*
- * Property {@code format} - Specify pattern for exception class names.
+ * Property {@code extendedClassNameFormat} - Specify pattern for extended class names.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^.*Exception$|^.*Error$|^.*Throwable$"}.
*
*
- * Property {@code extendedClassNameFormat} - Specify pattern for extended class names.
+ * Property {@code format} - Specify pattern for exception class names.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "^.*Exception$|^.*Error$|^.*Throwable$"}.
*
- * Property {@code headerFile} - Specify the name of the file containing the required header.
- * Type is {@code java.net.URI}.
- * Default value is {@code null}.
- *
- *
* Property {@code charset} - Specify the character encoding to use when reading the headerFile.
* Type is {@code java.lang.String}.
* Default value is {@code the charset property of the parent
* Checker module}.
*
*
+ * Property {@code fileExtensions} - Specify the file type extension of files to process.
+ * Type is {@code java.lang.String[]}.
+ * Default value is {@code ""}.
+ *
+ *
* Property {@code header} - Specify the required header specified inline.
* Individual header lines must be separated by the string {@code "\n"}
* (even on platforms with a different line separator), see examples below.
@@ -73,13 +73,13 @@
* Default value is {@code null}.
*
*
- * Property {@code ignoreLines} - Specify the line numbers to ignore.
- * Type is {@code int[]}.
- * Default value is {@code ""}.
+ * Property {@code headerFile} - Specify the name of the file containing the required header.
+ * Type is {@code java.net.URI}.
+ * Default value is {@code null}.
*
*
- * Property {@code fileExtensions} - Specify the file type extension of files to process.
- * Type is {@code java.lang.String[]}.
+ * Property {@code ignoreLines} - Specify the line numbers to ignore.
+ * Type is {@code int[]}.
* Default value is {@code ""}.
*
*
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java
index 52c99a6860f..c4c167e36e7 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java
@@ -141,14 +141,16 @@
* Default value is {@code ""}.
*
*
- * Property {@code standardPackageRegExp} - Specify RegExp for STANDARD_JAVA_PACKAGE group imports.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "^(java|javax)\."}.
+ * Property {@code separateLineBetweenGroups} - Force empty line separator between
+ * import groups.
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
*
*
- * Property {@code thirdPartyPackageRegExp} - Specify RegExp for THIRD_PARTY_PACKAGE group imports.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code ".*"}.
+ * Property {@code sortImportsInGroupAlphabetically} - Force grouping alphabetically,
+ * in ASCII sort order.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
*
*
* Property {@code specialImportsRegExp} - Specify RegExp for SPECIAL_IMPORTS group imports.
@@ -156,16 +158,14 @@
* Default value is {@code "^$"}.
*
*
- * Property {@code separateLineBetweenGroups} - Force empty line separator between
- * import groups.
- * Type is {@code boolean}.
- * Default value is {@code true}.
+ * Property {@code standardPackageRegExp} - Specify RegExp for STANDARD_JAVA_PACKAGE group imports.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "^(java|javax)\."}.
*
*
- * Property {@code sortImportsInGroupAlphabetically} - Force grouping alphabetically,
- * in ASCII sort order.
- * Type is {@code boolean}.
- * Default value is {@code false}.
+ * Property {@code thirdPartyPackageRegExp} - Specify RegExp for THIRD_PARTY_PACKAGE group imports.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code ".*"}.
*
- * Property {@code option} - Specify policy on the relative order between type imports and static
- * imports.
- * Type is {@code com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderOption}.
- * Default value is {@code under}.
+ * Property {@code caseSensitive} - Control whether string comparison should be
+ * case-sensitive or not. Case-sensitive sorting is in
+ * ASCII sort order.
+ * It affects both type imports and static imports.
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
*
*
* Property {@code groups} - Specify list of type import groups. Every group identified
@@ -76,6 +78,12 @@
* Default value is {@code ""}.
*
*
+ * Property {@code option} - Specify policy on the relative order between type imports and static
+ * imports.
+ * Type is {@code com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderOption}.
+ * Default value is {@code under}.
+ *
+ *
* Property {@code ordered} - Control whether type imports within each group should be
* sorted.
* It doesn't affect sorting for static imports.
@@ -98,12 +106,10 @@
* Default value is {@code false}.
*
*
- * Property {@code caseSensitive} - Control whether string comparison should be
- * case-sensitive or not. Case-sensitive sorting is in
- * ASCII sort order.
- * It affects both type imports and static imports.
+ * Property {@code sortStaticImportsAlphabetically} - Control whether
+ * static imports located at top or bottom are sorted within the group.
* Type is {@code boolean}.
- * Default value is {@code true}.
+ * Default value is {@code false}.
*
*
* Property {@code staticGroups} - Specify list of static import groups. Every group
@@ -116,12 +122,6 @@
* Default value is {@code ""}.
*
*
- * Property {@code sortStaticImportsAlphabetically} - Control whether
- * static imports located at top or bottom are sorted within the group.
- * Type is {@code boolean}.
- * Default value is {@code false}.
- *
- *
* Property {@code useContainerOrderingForStatic} - Control whether to use container
* ordering (Eclipse IDE term) for static imports or not.
* Type is {@code boolean}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck.java
index 84578b0bb7f..663a8bd0b47 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck.java
@@ -63,27 +63,6 @@
*
*
*
- * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked.
- * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
- * Default value is {@code private}.
- *
- *
- * Property {@code excludeScope} - Specify the visibility scope where Javadoc
- * comments are not checked.
- * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
- * Default value is {@code null}.
- *
- *
- * Property {@code authorFormat} - Specify the pattern for {@code @author} tag.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code null}.
- *
- *
- * Property {@code versionFormat} - Specify the pattern for {@code @version} tag.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code null}.
- *
- *
* Property {@code allowMissingParamTags} - Control whether to ignore violations
* when a class has type parameters but does not have matching param tags in the Javadoc.
* Type is {@code boolean}.
@@ -102,6 +81,27 @@
* Default value is {@code Generated}.
*
*
+ * Property {@code authorFormat} - Specify the pattern for {@code @author} tag.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code null}.
+ *
+ *
+ * Property {@code excludeScope} - Specify the visibility scope where Javadoc
+ * comments are not checked.
+ * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
+ * Default value is {@code null}.
+ *
+ *
+ * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked.
+ * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
+ * Default value is {@code private}.
+ *
+ *
+ * Property {@code versionFormat} - Specify the pattern for {@code @version} tag.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code null}.
+ *
+ *
* Property {@code tokens} - tokens to check
* Type is {@code java.lang.String[]}.
* Validation type is {@code tokenSet}.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheck.java
index e630b746168..4f62fcbf626 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheck.java
@@ -33,12 +33,12 @@
*
*
*
- * Property {@code format} - Specifies valid identifiers.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"}.
+ * Property {@code applyToPackage} - Controls whether to apply the check to package-private member.
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
*
*
- * Property {@code applyToPublic} - Controls whether to apply the check to public member.
+ * Property {@code applyToPrivate} - Controls whether to apply the check to private member.
* Type is {@code boolean}.
* Default value is {@code true}.
*
@@ -48,14 +48,14 @@
* Default value is {@code true}.
*
*
- * Property {@code applyToPackage} - Controls whether to apply the check to package-private member.
+ * Property {@code applyToPublic} - Controls whether to apply the check to public member.
* Type is {@code boolean}.
* Default value is {@code true}.
*
*
- * Property {@code applyToPrivate} - Controls whether to apply the check to private member.
- * Type is {@code boolean}.
- * Default value is {@code true}.
+ * Property {@code format} - Specifies valid identifiers.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"}.
*
*
*
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/IllegalTypeCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/IllegalTypeCheck.xml
index d03c78070ea..2dccc7369e5 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/IllegalTypeCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/coding/IllegalTypeCheck.xml
@@ -48,10 +48,16 @@
benefit from checking for them.
</p>
-
- Control whether to validate abstract class names.
+
+ Specify methods that should not be checked.
+
+
+ Specify RegExp for illegal abstract class
+ names.Define abstract classes that may be used as types.
-
- Specify methods that should not be checked.
-
-
- Specify RegExp for illegal abstract class
- names.
-
+
+ Control whether to validate abstract class names.
+
- Specify pattern for exception class names.
+ Specify pattern for extended class names.
- Specify pattern for extended class names.
+ Specify pattern for exception class names.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/header/HeaderCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/header/HeaderCheck.xml
index d9a348df05a..8a5b17db27f 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/header/HeaderCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/header/HeaderCheck.xml
@@ -31,23 +31,23 @@
of header is set to {@code null} and the check does not rise any violations.
</p>
-
- Specify the name of the file containing the required header.
- Specify the character encoding to use when reading the headerFile.
+
+ Specify the file type extension of files to process.
+ Specify the required header specified inline.
Individual header lines must be separated by the string {@code "\n"}
(even on platforms with a different line separator), see examples below.
+
+ Specify the name of the file containing the required header.
+ Specify the line numbers to ignore.
-
- Specify the file type extension of files to process.
-
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/CustomImportOrderCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/CustomImportOrderCheck.xml
index 9833b9213d1..79e2a10cbd1 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/CustomImportOrderCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/CustomImportOrderCheck.xml
@@ -111,21 +111,6 @@
Specify format of order declaration
customizing by user.
-
- Specify RegExp for STANDARD_JAVA_PACKAGE group imports.
-
-
- Specify RegExp for THIRD_PARTY_PACKAGE group imports.
-
-
- Specify RegExp for SPECIAL_IMPORTS group imports.
-
@@ -138,6 +123,21 @@
Force grouping alphabetically,
in <a href="https://en.wikipedia.org/wiki/ASCII#Order">ASCII sort order</a>.
+
+ Specify RegExp for SPECIAL_IMPORTS group imports.
+
+
+ Specify RegExp for STANDARD_JAVA_PACKAGE group imports.
+
+
+ Specify RegExp for THIRD_PARTY_PACKAGE group imports.
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/ImportOrderCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/ImportOrderCheck.xml
index d6b02b0db92..291c727c9b1 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/ImportOrderCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/imports/ImportOrderCheck.xml
@@ -34,11 +34,11 @@
</li>
</ul>
-
- Specify policy on the relative order between type imports and static
- imports.
+
+ Control whether string comparison should be
+ case-sensitive or not. Case-sensitive sorting is in
+ <a href="https://en.wikipedia.org/wiki/ASCII#Order">ASCII sort order</a>.
+ It affects both type imports and static imports.Specify list of <b>type import</b> groups. Every group identified
@@ -46,6 +46,12 @@
(e.g. {@code /regexp/}). All type imports, which does not match any group, falls into an
additional group, located at the end.
Thus, the empty list of type groups (the default value) means one group for all type imports.
+
+
+ Specify policy on the relative order between type imports and static
+ imports.Control whether type imports within each group should be
@@ -63,11 +69,11 @@
This property has effect only when the property {@code option} is set to {@code top}
or {@code bottom} and when property {@code staticGroups} is enabled.
-
- Control whether string comparison should be
- case-sensitive or not. Case-sensitive sorting is in
- <a href="https://en.wikipedia.org/wiki/ASCII#Order">ASCII sort order</a>.
- It affects both type imports and static imports.
+
+ Control whether
+ <b>static imports</b> located at <b>top</b> or <b>bottom</b> are sorted within the group.
-
-
- Control whether
- <b>static imports</b> located at <b>top</b> or <b>bottom</b> are sorted within the group.
-
- Specify the visibility scope where Javadoc comments are checked.
-
-
- Specify the visibility scope where Javadoc
- comments are not checked.
-
-
- Specify the pattern for {@code @author} tag.
-
-
- Specify the pattern for {@code @version} tag.
- Control whether to ignore violations
when a class has type parameters but does not have matching param tags in the Javadoc.
@@ -54,6 +39,21 @@
Specify annotations that allow
skipping validation at all. Only short names are allowed, e.g. {@code Generated}.
+
+ Specify the pattern for {@code @author} tag.
+
+
+ Specify the visibility scope where Javadoc
+ comments are not checked.
+
+
+ Specify the visibility scope where Javadoc comments are checked.
+
+
+ Specify the pattern for {@code @version} tag.
+
-
- Specifies valid identifiers.
+
+ Controls whether to apply the check to package-private member.
-
- Controls whether to apply the check to public member.
+
+ Controls whether to apply the check to private member.Controls whether to apply the check to protected member.
-
- Controls whether to apply the check to package-private member.
+
+ Controls whether to apply the check to public member.
-
- Controls whether to apply the check to private member.
+
+ Specifies valid identifiers.
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index d28c4d6af99..e9177260c70 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -231,13 +231,6 @@ public class XdocsPagesTest {
"RegexpSingleline",
"RegexpOnFilename",
"RegexpSinglelineJava",
- "ImportOrder",
- "IllegalType",
- "ConstantName",
- "MutableException",
- "JavadocType",
- "CustomImportOrder",
- "Header",
"DescendantToken",
"NewlineAtEndOfFile",
"SingleLineJavadoc",
diff --git a/src/xdocs/checks/coding/illegaltype.xml b/src/xdocs/checks/coding/illegaltype.xml
index 7cfd0a982f1..d7866f29d8e 100644
--- a/src/xdocs/checks/coding/illegaltype.xml
+++ b/src/xdocs/checks/coding/illegaltype.xml
@@ -34,11 +34,18 @@
Control whether string comparison should be case-sensitive or not.
+ Case-sensitive sorting is in
+ ASCII sort order.
+ It affects both type imports and static imports.
+
Control whether type imports within each group should be sorted.
@@ -97,15 +108,14 @@
8.12
-
caseSensitive
-
Control whether string comparison should be case-sensitive or not.
- Case-sensitive sorting is in
- ASCII sort order.
- It affects both type imports and static imports.
+
sortStaticImportsAlphabetically
+
+ Control whether static imports located at top or
+ bottom are sorted within the group.
Control whether string comparison should be case-sensitive or not.
+ Case-sensitive sorting is in
+ ASCII sort order.
+ It affects both type imports and static imports.
+
Control whether type imports within each group should be sorted.
@@ -97,15 +108,14 @@
8.12
-
caseSensitive
-
Control whether string comparison should be case-sensitive or not.
- Case-sensitive sorting is in
- ASCII sort order.
- It affects both type imports and static imports.
+
sortStaticImportsAlphabetically
+
+ Control whether static imports located at top or
+ bottom are sorted within the group.
- * Property {@code allowSingleLineStatement} - Allow single-line statements without braces.
+ * Property {@code allowEmptyLoopBody} - Allow loops with empty bodies.
* Type is {@code boolean}.
* Default value is {@code false}.
*
*
- * Property {@code allowEmptyLoopBody} - Allow loops with empty bodies.
+ * Property {@code allowSingleLineStatement} - Allow single-line statements without braces.
* Type is {@code boolean}.
* Default value is {@code false}.
*
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheck.java
index c33aa0cec55..05fcef688af 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheck.java
@@ -51,11 +51,6 @@
* Default value is {@code 1}.
*
*
- * Property {@code ignoreStringsRegexp} - Specify RegExp for ignored strings (with quotation marks).
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "^""$"}.
- *
- *
* Property {@code ignoreOccurrenceContext} - Specify token type names where duplicate
* strings are ignored even if they don't match ignoredStringsRegexp. This allows you to
* exclude syntactical contexts like annotations or static initializers from the check.
@@ -63,6 +58,11 @@
* Validation type is {@code tokenTypesSet}.
* Default value is {@code ANNOTATION}.
*
+ *
+ * Property {@code ignoreStringsRegexp} - Specify RegExp for ignored strings (with quotation marks).
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code "^""$"}.
+ *
- * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked.
- * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
- * Default value is {@code public}.
- *
- *
* Property {@code excludeScope} - Specify the visibility scope where Javadoc comments are not
* checked.
* Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
* Default value is {@code null}.
*
*
+ * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked.
+ * Type is {@code com.puppycrawl.tools.checkstyle.api.Scope}.
+ * Default value is {@code public}.
+ *
+ *
* Property {@code skipAnnotations} - Specify annotations that allow missed
* documentation. If annotation is present in target sources in multiple forms of qualified
* name, all forms should be listed in this property.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilter.java
index a2ccd6a0267..009d7fb3ad8 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilter.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilter.java
@@ -34,11 +34,6 @@
*
*
*
- * Property {@code severity} - Specify the severity level of this filter.
- * Type is {@code com.puppycrawl.tools.checkstyle.api.SeverityLevel}.
- * Default value is {@code error}.
- *
- *
* Property {@code acceptOnMatch} - Control whether the filter accepts an audit
* event if and only if there is a match between the event's severity level and
* property severity. If acceptOnMatch is {@code false}, then the filter accepts
@@ -47,6 +42,11 @@
* Type is {@code boolean}.
* Default value is {@code true}.
*
+ *
+ * Property {@code severity} - Specify the severity level of this filter.
+ * Type is {@code com.puppycrawl.tools.checkstyle.api.SeverityLevel}.
+ * Default value is {@code error}.
+ *
- * Property {@code commentFormat} - Specify comment pattern to trigger filter to begin suppression.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code "SUPPRESS CHECKSTYLE (\w+)"}.
+ * Property {@code checkC} - Control whether to check C style comments ({@code /* ... */}).
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
+ *
+ *
+ * Property {@code checkCPP} - Control whether to check C++ style comments ({@code //}).
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
*
*
* Property {@code checkFormat} - Specify check pattern to suppress.
@@ -71,9 +76,9 @@
* Default value is {@code ".*"}.
*
*
- * Property {@code messageFormat} - Define message pattern to suppress.
+ * Property {@code commentFormat} - Specify comment pattern to trigger filter to begin suppression.
* Type is {@code java.util.regex.Pattern}.
- * Default value is {@code null}.
+ * Default value is {@code "SUPPRESS CHECKSTYLE (\w+)"}.
*
*
* Property {@code idFormat} - Specify check ID pattern to suppress.
@@ -87,14 +92,9 @@
* Default value is {@code "0"}.
*
*
- * Property {@code checkCPP} - Control whether to check C++ style comments ({@code //}).
- * Type is {@code boolean}.
- * Default value is {@code true}.
- *
- *
- * Property {@code checkC} - Control whether to check C style comments ({@code /* ... */}).
- * Type is {@code boolean}.
- * Default value is {@code true}.
+ * Property {@code messageFormat} - Define message pattern to suppress.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code null}.
*
*
*
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/NeedBracesCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/NeedBracesCheck.xml
index 6fa5032f396..5b2ddb05bf9 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/NeedBracesCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/blocks/NeedBracesCheck.xml
@@ -8,14 +8,14 @@
Checks for braces around code blocks.
</p>
+
+ Allow loops with empty bodies.
+ Allow single-line statements without braces.
-
- Allow loops with empty bodies.
- Specify the maximum number of occurrences
to allow without generating a warning.
-
- Specify RegExp for ignored strings (with quotation marks).
-
+
+ Specify RegExp for ignored strings (with quotation marks).
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocTypeCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocTypeCheck.xml
index 4c3b9ef561d..5890976e8e7 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocTypeCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocTypeCheck.xml
@@ -11,15 +11,15 @@
{@code Scope} constants.
</p>
+
+ Specify the visibility scope where Javadoc comments are not
+ checked.
+ Specify the visibility scope where Javadoc comments are checked.
-
- Specify the visibility scope where Javadoc comments are not
- checked.
-
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SeverityMatchFilter.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SeverityMatchFilter.xml
index 22f2e3cb8a7..9038c3af543 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SeverityMatchFilter.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SeverityMatchFilter.xml
@@ -12,11 +12,6 @@
SeverityMatchFilter can suppress Checks that have Treewalker or Checker as parent module.
</p>
-
- Specify the severity level of this filter.
- Control whether the filter accepts an audit
event if and only if there is a match between the event's severity level and
@@ -24,6 +19,11 @@
an audit event if and only if there is not a match between the event's severity
level and property severity.
+
+ Specify the severity level of this filter.
+
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressWithNearbyCommentFilter.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressWithNearbyCommentFilter.xml
index 33b30b5baae..74838e3eb72 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressWithNearbyCommentFilter.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/filters/SuppressWithNearbyCommentFilter.xml
@@ -26,18 +26,21 @@
Treewalker as parent module.
</p>
-
- Specify comment pattern to trigger filter to begin suppression.
+
+ Control whether to check C style comments ({@code /* ... */}).
+
+
+ Control whether to check C++ style comments ({@code //}).Specify check pattern to suppress.
-
- Define message pattern to suppress.
+
+ Specify comment pattern to trigger filter to begin suppression.Specify check ID pattern to suppress.
@@ -46,11 +49,8 @@
Specify negative/zero/positive value that
defines the number of lines preceding/at/following the suppression comment.
-
- Control whether to check C++ style comments ({@code //}).
-
-
- Control whether to check C style comments ({@code /* ... */}).
+
+ Define message pattern to suppress.
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index e9177260c70..8dc89d4d1e3 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -233,12 +233,7 @@ public class XdocsPagesTest {
"RegexpSinglelineJava",
"DescendantToken",
"NewlineAtEndOfFile",
- "SingleLineJavadoc",
- "MissingJavadocType",
- "NeedBraces",
- "SeverityMatchFilter",
- "SuppressWithNearbyCommentFilter",
- "MultipleStringLiterals"
+ "SingleLineJavadoc"
);
/**
diff --git a/src/xdocs/checks/blocks/needbraces.xml b/src/xdocs/checks/blocks/needbraces.xml
index ca15c98caa9..fe1938a6a23 100644
--- a/src/xdocs/checks/blocks/needbraces.xml
+++ b/src/xdocs/checks/blocks/needbraces.xml
@@ -23,18 +23,18 @@
-
- ImportControlLoader.java
- com.puppycrawl.tools.checkstyle.checks.imports.ImportControlLoader
- load
- org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator
- removed call to java/lang/Exception::getMessage
- + " - " + ex.getMessage(), ex);
-
-
-
- ImportControlLoader.java
- com.puppycrawl.tools.checkstyle.checks.imports.ImportControlLoader
- startElement
- org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator
- removed call to com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader::containsRegexAttribute
- final boolean regex = containsRegexAttribute(attributes);
-
-
PkgImportControl.javacom.puppycrawl.tools.checkstyle.checks.imports.PkgImportControl
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java
index 56e633f9f96..78b0ed9de72 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java
@@ -19,10 +19,12 @@
package com.puppycrawl.tools.checkstyle.checks.imports;
+import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck.MSG_DISALLOWED;
import static com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck.MSG_MISSING_FILE;
import static com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck.MSG_UNKNOWN_PKG;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.File;
import java.nio.file.Files;
@@ -439,6 +441,29 @@ public void testBeginTreeCurrentImportControl() throws Exception {
verifyWithInlineConfigParser(file1, file2, expectedFirstInput, expectedSecondInput);
}
+ @Test
+ public void testImportControlFileName() throws Exception {
+ final String[] expected = {
+ "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"),
+ };
+
+ verifyWithInlineConfigParser(
+ getPath("InputImportControlTestRegexpInFile.java"), expected);
+ }
+
+ @Test
+ public void testImportControlTestException() {
+ final CheckstyleException ex = assertThrows(CheckstyleException.class, () -> {
+ verifyWithInlineConfigParser(getPath("InputImportControlTestException.java"));
+ });
+
+ assertThat(ex.getCause().getCause().getCause().getCause().getCause().getMessage())
+ .startsWith("unable to parse file:");
+ assertThat(ex.getCause().getCause().getCause().getCause().getCause().getMessage())
+ .endsWith("- Document root element \"import-control\", must match DOCTYPE"
+ + " root \"null\".");
+ }
+
/**
* Returns String message of original exception that was thrown in
* ImportControlCheck.setUrl or ImportControlCheck.setFile
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importcontrol/InputImportControlTestException.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importcontrol/InputImportControlTestException.java
new file mode 100644
index 00000000000..c61ff23d3f5
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importcontrol/InputImportControlTestException.java
@@ -0,0 +1,11 @@
+/*
+ImportControl
+file = (file)InputImportControlTestException.xml
+path = (default).*
+
+
+*/
+
+package com.puppycrawl.tools.checkstyle.checks.imports.importcontrol;
+
+public class InputImportControlTestException { }
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importcontrol/InputImportControlTestException.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importcontrol/InputImportControlTestException.xml
new file mode 100644
index 00000000000..ec09bfa9d1c
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importcontrol/InputImportControlTestException.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importcontrol/InputImportControlTestRegexpInFile.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importcontrol/InputImportControlTestRegexpInFile.java
new file mode 100644
index 00000000000..bc33a53dfb1
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importcontrol/InputImportControlTestRegexpInFile.java
@@ -0,0 +1,14 @@
+/*
+ImportControl
+file = (file)(resource)InputImportControlTestRegexpInFile.xml
+path = (default).*
+
+
+*/
+
+package com.puppycrawl.tools.checkstyle.checks.imports.importcontrol;
+
+import java.awt.Image; // violation 'Disallowed import - java.awt.Image'
+
+public class InputImportControlTestRegexpInFile {
+}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importcontrol/InputImportControlTestRegexpInFile.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importcontrol/InputImportControlTestRegexpInFile.xml
new file mode 100644
index 00000000000..5c78da49f9c
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importcontrol/InputImportControlTestRegexpInFile.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
From 2ab52c61a6634c2c01cb7b5750867902d12c58df Mon Sep 17 00:00:00 2001
From: Rohanraj123
Date: Mon, 25 Sep 2023 23:51:15 +0530
Subject: [PATCH 104/833] Issue #13345: Enable Test Cases for
MethodNameCheckExamplesTest
---
.../naming/MethodNameCheckExamplesTest.java | 25 ++++++-----
.../checks/naming/methodname/Example1.java | 18 ++++++++
.../checks/naming/methodname/Example1.txt | 18 --------
.../{Example2.txt => Example2.java} | 9 ++--
.../{Example3.txt => Example3.java} | 9 ++--
.../{Example4.txt => Example4.java} | 9 ++--
.../checks/naming/methodname/Example5.java | 22 +++++++++
.../checks/naming/methodname/Example5.txt | 22 ---------
src/xdocs/checks/naming/methodname.xml | 45 ++++++++-----------
.../checks/naming/methodname.xml.template | 20 ++++-----
10 files changed, 98 insertions(+), 99 deletions(-)
create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example1.java
delete mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example1.txt
rename src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/{Example2.txt => Example2.java} (56%)
rename src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/{Example3.txt => Example3.java} (62%)
rename src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/{Example4.txt => Example4.java} (63%)
create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example5.java
delete mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example5.txt
diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckExamplesTest.java
index 60843bce447..8f4cef8450e 100644
--- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckExamplesTest.java
+++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckExamplesTest.java
@@ -19,12 +19,13 @@
package com.puppycrawl.tools.checkstyle.checks.naming;
-import org.junit.jupiter.api.Disabled;
+import static com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck.MSG_INVALID_PATTERN;
+import static com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck.MSG_KEY;
+
import org.junit.jupiter.api.Test;
import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
-@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345")
public class MethodNameCheckExamplesTest extends AbstractExamplesModuleTestSupport {
@Override
protected String getPackageLocation() {
@@ -34,19 +35,20 @@ protected String getPackageLocation() {
@Test
public void testExample1() throws Exception {
final String[] expected = {
-
+ "15:16: " + getCheckMessage(MSG_INVALID_PATTERN, "Method3", "^[a-z][a-zA-Z0-9]*$"),
+ "16:15: " + getCheckMessage(MSG_INVALID_PATTERN, "Method4", "^[a-z][a-zA-Z0-9]*$"),
};
- verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example1.java"), expected);
}
@Test
public void testExample2() throws Exception {
final String[] expected = {
-
+ "16:15: " + getCheckMessage(MSG_INVALID_PATTERN, "Method2", "^[a-z](_?[a-zA-Z0-9]+)*$"),
};
- verifyWithInlineConfigParser(getPath("Example2.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example2.java"), expected);
}
@Test
@@ -55,24 +57,25 @@ public void testExample3() throws Exception {
};
- verifyWithInlineConfigParser(getPath("Example3.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example3.java"), expected);
}
@Test
public void testExample4() throws Exception {
final String[] expected = {
-
+ "17:15: " + getCheckMessage(MSG_KEY, "Example4"),
};
- verifyWithInlineConfigParser(getPath("Example4.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example4.java"), expected);
}
@Test
public void testExample5() throws Exception {
final String[] expected = {
-
+ "19:16: " + getCheckMessage(MSG_INVALID_PATTERN, "Method3", "^[a-z](_?[a-zA-Z0-9]+)*$"),
+ "20:8: " + getCheckMessage(MSG_INVALID_PATTERN, "Method4", "^[a-z](_?[a-zA-Z0-9]+)*$"),
};
- verifyWithInlineConfigParser(getPath("Example5.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example5.java"), expected);
}
}
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example1.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example1.java
new file mode 100644
index 00000000000..9e61922c6b3
--- /dev/null
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example1.java
@@ -0,0 +1,18 @@
+/*xml
+
+
+
+
+
+*/
+
+package com.puppycrawl.tools.checkstyle.checks.naming.methodname;
+
+// xdoc section -- start
+class Example1 {
+ public void method1() {}
+ protected void method2() {}
+ private void Method3() {} // violation
+ public void Method4() {} // violation
+}
+// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example1.txt
deleted file mode 100644
index a602e83cd22..00000000000
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example1.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-/*xml
-
-
-
-
-
-*/
-
-// xdoc section -- start
-class MyClass {
- public void firstMethod1() {} // OK
- protected void secondMethod() {} // OK
- private void ThirdMethod() {} // violation, method name must match to the
- // default pattern '^[a-z][a-zA-Z0-9]*$'
- public void fourth_Method4() {} // violation, method name must match to the
- // default pattern '^[a-z][a-zA-Z0-9]*$'
-}
-// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example2.java
similarity index 56%
rename from src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example2.txt
rename to src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example2.java
index fe7916a7ee7..11c8e74b669 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example2.txt
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example2.java
@@ -8,10 +8,11 @@
*/
+package com.puppycrawl.tools.checkstyle.checks.naming.methodname;
+
// xdoc section -- start
-class MyClass {
- public void myMethod() {} // OK
- public void MyMethod() {} // violation, name "MyMethod"
- // should match the pattern "^[a-z](_?[a-zA-Z0-9]+)*$"
+class Example2 {
+ public void method1() {}
+ public void Method2() {} // violation
}
// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example3.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example3.java
similarity index 62%
rename from src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example3.txt
rename to src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example3.java
index 259cfa669bf..0d9381c93be 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example3.txt
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example3.java
@@ -9,10 +9,11 @@
*/
+package com.puppycrawl.tools.checkstyle.checks.naming.methodname;
+
// xdoc section -- start
-class MyClass {
- public MyClass() {} // OK
- public void MyClass() {} // OK, method Name 'MyClass' is allowed to be
- // equal to the enclosing class name
+class Example3 {
+ public Example3() {}
+ public void Example3() {}
}
// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example4.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example4.java
similarity index 63%
rename from src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example4.txt
rename to src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example4.java
index 8caa069e99a..de1f30f7833 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example4.txt
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example4.java
@@ -9,10 +9,11 @@
*/
+package com.puppycrawl.tools.checkstyle.checks.naming.methodname;
+
// xdoc section -- start
-class MyClass {
- public MyClass() {} // OK
- public void MyClass() {} // violation, method Name 'MyClass' must not
- // equal the enclosing class name
+class Example4 {
+ public Example4() {}
+ public void Example4() {} // violation
}
// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example5.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example5.java
new file mode 100644
index 00000000000..a00fa4a539f
--- /dev/null
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example5.java
@@ -0,0 +1,22 @@
+/*xml
+
+
+
+
+
+
+
+
+
+*/
+
+package com.puppycrawl.tools.checkstyle.checks.naming.methodname;
+
+// xdoc section -- start
+class Example5 {
+ public void Method1() {}
+ protected void Method2() {}
+ private void Method3() {} // violation
+ void Method4() {} // violation
+}
+// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example5.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example5.txt
deleted file mode 100644
index 6da1081ca84..00000000000
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example5.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-/*xml
-
-
-
-
-
-
-
-
-
-*/
-
-// xdoc section -- start
-class MyClass {
- public void FirstMethod() {} // OK
- protected void SecondMethod() {} // OK
- private void ThirdMethod() {} // violation, name 'ThirdMethod' must match
- // pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- void FourthMethod() {} // violation, name 'FourthMethod' must match
- // pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
-}
-// xdoc section -- end
diff --git a/src/xdocs/checks/naming/methodname.xml b/src/xdocs/checks/naming/methodname.xml
index 55e2460b263..a05236b6315 100644
--- a/src/xdocs/checks/naming/methodname.xml
+++ b/src/xdocs/checks/naming/methodname.xml
@@ -107,13 +107,11 @@ class MyClass {
Code Example:
-class MyClass {
- public void firstMethod1() {} // OK
- protected void secondMethod() {} // OK
- private void ThirdMethod() {} // violation, method name must match to the
- // default pattern '^[a-z][a-zA-Z0-9]*$'
- public void fourth_Method4() {} // violation, method name must match to the
- // default pattern '^[a-z][a-zA-Z0-9]*$'
+class Example1 {
+ public void method1() {}
+ protected void method2() {}
+ private void Method3() {} // violation
+ public void Method4() {} // violation
}
@@ -131,10 +129,9 @@ class MyClass {
Code Example:
-class MyClass {
- public void myMethod() {} // OK
- public void MyMethod() {} // violation, name "MyMethod"
- // should match the pattern "^[a-z](_?[a-zA-Z0-9]+)*$"
+class Example2 {
+ public void method1() {}
+ public void Method2() {} // violation
}
@@ -153,10 +150,9 @@ class MyClass {
Code Example:
-class MyClass {
- public MyClass() {} // OK
- public void MyClass() {} // OK, method Name 'MyClass' is allowed to be
- // equal to the enclosing class name
+class Example3 {
+ public Example3() {}
+ public void Example3() {}
}
@@ -175,10 +171,9 @@ class MyClass {
Code Example:
-class MyClass {
- public MyClass() {} // OK
- public void MyClass() {} // violation, method Name 'MyClass' must not
- // equal the enclosing class name
+class Example4 {
+ public Example4() {}
+ public void Example4() {} // violation
}
@@ -197,13 +192,11 @@ class MyClass {
Code Example:
-class MyClass {
- public void FirstMethod() {} // OK
- protected void SecondMethod() {} // OK
- private void ThirdMethod() {} // violation, name 'ThirdMethod' must match
- // pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- void FourthMethod() {} // violation, name 'FourthMethod' must match
- // pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
+class Example5 {
+ public void Method1() {}
+ protected void Method2() {}
+ private void Method3() {} // violation
+ void Method4() {} // violation
}
diff --git a/src/xdocs/checks/naming/methodname.xml.template b/src/xdocs/checks/naming/methodname.xml.template
index a9bd8f02ef7..564413c6883 100644
--- a/src/xdocs/checks/naming/methodname.xml.template
+++ b/src/xdocs/checks/naming/methodname.xml.template
@@ -100,13 +100,13 @@ class MyClass {
+ value="resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/Example1.java"/>
- * Property {@code minimumDepth} - Specify the minimum depth for descendant counts.
- * Type is {@code int}.
- * Default value is {@code 0}.
- *
- *
* Property {@code maximumDepth} - Specify the maximum depth for descendant counts.
* Type is {@code int}.
* Default value is {@code 2147483647}.
*
*
- * Property {@code minimumNumber} - Specify a minimum count for descendants.
- * Type is {@code int}.
- * Default value is {@code 0}.
+ * Property {@code maximumMessage} - Define the violation message
+ * when the maximum count is exceeded.
+ * Type is {@code java.lang.String}.
+ * Default value is {@code null}.
*
*
* Property {@code maximumNumber} - Specify a maximum count for descendants.
@@ -69,10 +65,9 @@
* Default value is {@code 2147483647}.
*
*
- * Property {@code sumTokenCounts} - Control whether the number of tokens found
- * should be calculated from the sum of the individual token counts.
- * Type is {@code boolean}.
- * Default value is {@code false}.
+ * Property {@code minimumDepth} - Specify the minimum depth for descendant counts.
+ * Type is {@code int}.
+ * Default value is {@code 0}.
*
*
* Property {@code minimumMessage} - Define the violation message
@@ -81,10 +76,15 @@
* Default value is {@code null}.
*
*
- * Property {@code maximumMessage} - Define the violation message
- * when the maximum count is exceeded.
- * Type is {@code java.lang.String}.
- * Default value is {@code null}.
+ * Property {@code minimumNumber} - Specify a minimum count for descendants.
+ * Type is {@code int}.
+ * Default value is {@code 0}.
+ *
+ *
+ * Property {@code sumTokenCounts} - Control whether the number of tokens found
+ * should be calculated from the sum of the individual token counts.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
*
- * Property {@code lineSeparator} - Specify the type of line separator.
- * Type is {@code com.puppycrawl.tools.checkstyle.checks.LineSeparatorOption}.
- * Default value is {@code lf_cr_crlf}.
- *
- *
* Property {@code fileExtensions} - Specify the file type extension of the files to check.
* Type is {@code java.lang.String[]}.
* Default value is {@code ""}.
*
+ *
+ * Property {@code lineSeparator} - Specify the type of line separator.
+ * Type is {@code com.puppycrawl.tools.checkstyle.checks.LineSeparatorOption}.
+ * Default value is {@code lf_cr_crlf}.
+ *
- * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations
- * if the Javadoc being examined by this check violates the tight html rules defined at
- * Tight-HTML Rules.
+ * Property {@code ignoreInlineTags} - Control whether
+ *
+ * inline tags must be ignored.
* Type is {@code boolean}.
- * Default value is {@code false}.
+ * Default value is {@code true}.
*
*
* Property {@code ignoredTags} - Specify
@@ -49,11 +49,11 @@
* Default value is {@code ""}.
*
*
- * Property {@code ignoreInlineTags} - Control whether
- *
- * inline tags must be ignored.
+ * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations
+ * if the Javadoc being examined by this check violates the tight html rules defined at
+ * Tight-HTML Rules.
* Type is {@code boolean}.
- * Default value is {@code true}.
+ * Default value is {@code false}.
*
- * Property {@code folderPattern} - Specify the regular expression to match the folder path against.
- * Type is {@code java.util.regex.Pattern}.
- * Default value is {@code null}.
- *
+ * 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.
+ * Type is {@code java.lang.String[]}.
+ * Default value is {@code ""}.
*
* Property {@code fileNamePattern} - Specify the regular expression to match the file name against.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code null}.
- *
*
- * Property {@code 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.
- * Type is {@code boolean}.
- * Default value is {@code true}.
- *
+ * Property {@code folderPattern} - Specify the regular expression to match the folder path against.
+ * Type is {@code java.util.regex.Pattern}.
+ * Default value is {@code null}.
*
* Property {@code ignoreFileNameExtensions} - Control whether to ignore the file extension for
* the file name match.
* Type is {@code boolean}.
* Default value is {@code false}.
- *
*
- * 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.
- * Type is {@code java.lang.String[]}.
- * Default value is {@code ""}.
+ * Property {@code 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.
+ * Type is {@code boolean}.
+ * Default value is {@code true}.
*
+ * Property {@code fileExtensions} - Specify the file type extension of files to process.
+ * Type is {@code java.lang.String[]}.
+ * Default value is {@code ""}.
+ *
+ *
* Property {@code format} - Specify the format of the regular expression to match.
* Type is {@code java.util.regex.Pattern}.
* Default value is {@code "$."}.
*
*
- * Property {@code message} - Specify the message which is used to notify about
- * violations, if empty then default (hard-coded) message is used.
- * Type is {@code java.lang.String}.
- * Default value is {@code null}.
- *
- *
* Property {@code ignoreCase} - Control whether to ignore case when searching.
* Type is {@code boolean}.
* Default value is {@code false}.
*
*
- * Property {@code minimum} - Specify the minimum number of matches required in each file.
+ * Property {@code maximum} - Specify the maximum number of matches required in each file.
* Type is {@code int}.
* Default value is {@code 0}.
*
*
- * Property {@code maximum} - Specify the maximum number of matches required in each file.
- * Type is {@code int}.
- * Default value is {@code 0}.
+ * Property {@code message} - Specify the message which is used to notify about
+ * violations, if empty then default (hard-coded) message is used.
+ * Type is {@code java.lang.String}.
+ * Default value is {@code null}.
*
*
- * Property {@code fileExtensions} - Specify the file type extension of files to process.
- * Type is {@code java.lang.String[]}.
- * Default value is {@code ""}.
+ * Property {@code minimum} - Specify the minimum number of matches required in each file.
+ * Type is {@code int}.
+ * Default value is {@code 0}.
*
*
*
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheck.java
index 42f95973a72..394b9bb6684 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheck.java
@@ -44,20 +44,14 @@
* Default value is {@code "$."}.
*
*
- * Property {@code message} - Specify the message which is used to notify about
- * violations, if empty then default (hard-coded) message is used.
- * Type is {@code java.lang.String}.
- * Default value is {@code null}.
- *
- *
* Property {@code ignoreCase} - Control whether to ignore case when searching.
* Type is {@code boolean}.
* Default value is {@code false}.
*
*
- * Property {@code minimum} - Specify the minimum number of matches required in each file.
- * Type is {@code int}.
- * Default value is {@code 0}.
+ * Property {@code ignoreComments} - Control whether to ignore text in comments when searching.
+ * Type is {@code boolean}.
+ * Default value is {@code false}.
*
*
* Property {@code maximum} - Specify the maximum number of matches required in each file.
@@ -65,9 +59,15 @@
* Default value is {@code 0}.
*
*
- * Property {@code ignoreComments} - Control whether to ignore text in comments when searching.
- * Type is {@code boolean}.
- * Default value is {@code false}.
+ * Property {@code message} - Specify the message which is used to notify about
+ * violations, if empty then default (hard-coded) message is used.
+ * Type is {@code java.lang.String}.
+ * Default value is {@code null}.
+ *
+ *
+ * Property {@code minimum} - Specify the minimum number of matches required in each file.
+ * Type is {@code int}.
+ * Default value is {@code 0}.
*
*
*
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/DescendantTokenCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/DescendantTokenCheck.xml
index f8dababc64e..9d407039b15 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/DescendantTokenCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/DescendantTokenCheck.xml
@@ -22,29 +22,29 @@
validation-type="tokenTypesSet">
Specify set of tokens with limited occurrences as descendants.
-
- Specify the minimum depth for descendant counts.
- Specify the maximum depth for descendant counts.
-
- Specify a minimum count for descendants.
+
+ Define the violation message
+ when the maximum count is exceeded.Specify a maximum count for descendants.
-
- Control whether the number of tokens found
- should be calculated from the sum of the individual token counts.
+
+ Specify the minimum depth for descendant counts.Define the violation message
when the minimum count is not reached.
-
- Define the violation message
- when the maximum count is exceeded.
+
+ Specify a minimum count for descendants.
+
+
+ Control whether the number of tokens found
+ should be calculated from the sum of the individual token counts.tokens to check
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/NewlineAtEndOfFileCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/NewlineAtEndOfFileCheck.xml
index d20d8b386a2..3400e381581 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/NewlineAtEndOfFileCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/NewlineAtEndOfFileCheck.xml
@@ -48,14 +48,14 @@
platforms, with the {@code lineSeparator} property.
</p>
+
+ Specify the file type extension of the files to check.
+ Specify the type of line separator.
-
- Specify the file type extension of the files to check.
-
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/SingleLineJavadocCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/SingleLineJavadocCheck.xml
index 1d00e60bb46..595e8dd1eab 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/SingleLineJavadocCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/SingleLineJavadocCheck.xml
@@ -9,22 +9,22 @@
Javadoc comment that contains at least one block tag should be formatted in a few lines.
</p>
-
- Control when to print violations
- if the Javadoc being examined by this check violates the tight html rules defined at
- <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>.
+
+ Control whether
+ <a href="https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#CHDBEFIF">
+ inline tags</a> must be ignored.Specify
<a href="https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#CHDBEFIF">
block tags</a> which are ignored by the check.
-
- Control whether
- <a href="https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#CHDBEFIF">
- inline tags</a> must be ignored.
+
+ Control when to print violations
+ if the Javadoc being examined by this check violates the tight html rules defined at
+ <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>.
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 441cb1e96f5..3920a70dd56 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
@@ -45,15 +45,16 @@
messages.
</p>
-
- Specify the regular expression to match the folder path against.
+
+ 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 regular expression to match the file name against.
-
- 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.
+
+ Specify the regular expression to match the folder path against.Control whether to ignore the file extension for
the file name match.
-
- 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.
+
+ 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.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpSinglelineCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpSinglelineCheck.xml
index 8617a808295..44583533145 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpSinglelineCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpSinglelineCheck.xml
@@ -13,24 +13,24 @@
{@code System.out.println()}, {@code System.exit()}, etc.
</p>
+
+ Specify the file type extension of files to process.
+ Specify the format of the regular expression to match.
-
- Specify the message which is used to notify about
- violations, if empty then default (hard-coded) message is used.
- Control whether to ignore case when searching.
-
- Specify the minimum number of matches required in each file.
- Specify the maximum number of matches required in each file.
-
- Specify the file type extension of files to process.
+
+ Specify the message which is used to notify about
+ violations, if empty then default (hard-coded) message is used.
+
+
+ Specify the minimum number of matches required in each file.
diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpSinglelineJavaCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpSinglelineJavaCheck.xml
index 201d645ba32..cd6756e9740 100644
--- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpSinglelineJavaCheck.xml
+++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/regexp/RegexpSinglelineJavaCheck.xml
@@ -18,21 +18,21 @@
Specify the format of the regular expression to match.
-
- Specify the message which is used to notify about
- violations, if empty then default (hard-coded) message is used.
- Control whether to ignore case when searching.
-
- Specify the minimum number of matches required in each file.
+
+ Control whether to ignore text in comments when searching.Specify the maximum number of matches required in each file.
-
- Control whether to ignore text in comments when searching.
+
+ Specify the message which is used to notify about
+ violations, if empty then default (hard-coded) message is used.
+
+
+ Specify the minimum number of matches required in each file.
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
index 8dc89d4d1e3..5ecb2bcc18a 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
@@ -226,16 +226,6 @@ public class XdocsPagesTest {
private static final Set GOOGLE_MODULES = Collections.unmodifiableSet(
CheckUtil.getConfigGoogleStyleModules());
- // until https://github.com/checkstyle/checkstyle/issues/13666
- private static final Set MODULES_WITH_UNORDERED_PROPERTIES = Set.of(
- "RegexpSingleline",
- "RegexpOnFilename",
- "RegexpSinglelineJava",
- "DescendantToken",
- "NewlineAtEndOfFile",
- "SingleLineJavadoc"
- );
-
/**
* Generate xdoc content from templates before validation.
* This method will be removed once
@@ -810,9 +800,7 @@ private static void validatePropertySection(String fileName, String sectionName,
.that(table.getNodeName())
.isEqualTo("table");
- if (!MODULES_WITH_UNORDERED_PROPERTIES.contains(sectionName)) {
- validatePropertySectionPropertiesOrder(fileName, sectionName, table, properties);
- }
+ validatePropertySectionPropertiesOrder(fileName, sectionName, table, properties);
validatePropertySectionProperties(fileName, sectionName, table, instance,
properties);
diff --git a/src/xdocs/checks/javadoc/singlelinejavadoc.xml b/src/xdocs/checks/javadoc/singlelinejavadoc.xml
index 0dc0af3b9e3..0ef745b8e2f 100644
--- a/src/xdocs/checks/javadoc/singlelinejavadoc.xml
+++ b/src/xdocs/checks/javadoc/singlelinejavadoc.xml
@@ -27,15 +27,15 @@
since
-
violateExecutionOnNonTightHtml
+
ignoreInlineTags
- Control when to print violations if the Javadoc being examined by this check
- violates the tight html rules defined at
- Tight-HTML Rules.
+ Control whether
+
+ inline tags must be ignored.
- Control whether
-
- inline tags must be ignored.
+ Control when to print violations if the Javadoc being examined by this check
+ violates the tight html rules defined at
+ Tight-HTML Rules.
- Control when to print violations if the Javadoc being examined by this check
- violates the tight html rules defined at
- Tight-HTML Rules.
+ Control whether
+
+ inline tags must be ignored.
- Control whether
-
- inline tags must be ignored.
+ Control when to print violations if the Javadoc being examined by this check
+ violates the tight html rules defined at
+ Tight-HTML Rules.
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. 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. 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. If this is specified, then
- only files that match these types are examined with the other patterns.
This type represents a set of strings. The string representation
- is parsed as a set of comma (',') separated strings.
+ is parsed as a set of comma (',') separated strings. Extra spaces are allowed.
Alternatively, a property of this type can be supplied multiple times which
@@ -933,7 +933,7 @@
following:
+ value="resources/com/puppycrawl/tools/checkstyle/checks/annotation/annotationlocation/Example4.java"/>
From 41f880a15422809ff461b6a67bc4131405648ad9 Mon Sep 17 00:00:00 2001
From: piyush kumar sadangi
Date: Wed, 4 Oct 2023 12:14:26 +0530
Subject: [PATCH 119/833] Issue #13345: Enable examples tests for
InvalidJavadocPosition
---
.../javadoc/InvalidJavadocPositionCheckExamplesTest.java | 8 ++++----
.../{Example1.txt => Example1.java} | 8 ++++++--
src/xdocs/checks/javadoc/invalidjavadocposition.xml | 6 ++++--
.../checks/javadoc/invalidjavadocposition.xml.template | 4 ++--
4 files changed, 16 insertions(+), 10 deletions(-)
rename src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition/{Example1.txt => Example1.java} (50%)
diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheckExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheckExamplesTest.java
index 065885fd586..dc2ecbb07b5 100644
--- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheckExamplesTest.java
+++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheckExamplesTest.java
@@ -19,12 +19,12 @@
package com.puppycrawl.tools.checkstyle.checks.javadoc;
-import org.junit.jupiter.api.Disabled;
+import static com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPositionCheck.MSG_KEY;
+
import org.junit.jupiter.api.Test;
import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
-@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345")
public class InvalidJavadocPositionCheckExamplesTest extends AbstractExamplesModuleTestSupport {
@Override
protected String getPackageLocation() {
@@ -34,9 +34,9 @@ protected String getPackageLocation() {
@Test
public void testExample1() throws Exception {
final String[] expected = {
-
+ "14:1: " + getCheckMessage(MSG_KEY),
};
- verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example1.java"), expected);
}
}
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition/Example1.java
similarity index 50%
rename from src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition/Example1.txt
rename to src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition/Example1.java
index cb5cd3368ad..88638f13f06 100644
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition/Example1.txt
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition/Example1.java
@@ -6,12 +6,16 @@
*/
+package com.puppycrawl.tools.checkstyle.checks.javadoc.invalidjavadocposition;
+
// xdoc section -- start
@SuppressWarnings("serial")
+// violation below, 'Javadoc comment is placed in the wrong location'
/**
* This comment looks like Javadoc but it is at an invalid location.
- * Therefore, the text will not get into TestClass.html and the check will produce a violation.
+ * Therefore, the text will not get into TestClass.html.
+ * And, the check will produce a violation.
*/
-public class TestClass {
+public class Example1 {
}
// xdoc section -- end
diff --git a/src/xdocs/checks/javadoc/invalidjavadocposition.xml b/src/xdocs/checks/javadoc/invalidjavadocposition.xml
index bbd0a9b7b88..3d91dddf2c6 100644
--- a/src/xdocs/checks/javadoc/invalidjavadocposition.xml
+++ b/src/xdocs/checks/javadoc/invalidjavadocposition.xml
@@ -38,11 +38,13 @@
@SuppressWarnings("serial")
+// violation below, 'Javadoc comment is placed in the wrong location'
/**
* This comment looks like Javadoc but it is at an invalid location.
- * Therefore, the text will not get into TestClass.html and the check will produce a violation.
+ * Therefore, the text will not get into TestClass.html.
+ * And, the check will produce a violation.
*/
-public class TestClass {
+public class Example1 {
}
diff --git a/src/xdocs/checks/javadoc/invalidjavadocposition.xml.template b/src/xdocs/checks/javadoc/invalidjavadocposition.xml.template
index 768a41d9cfe..9120103a02a 100644
--- a/src/xdocs/checks/javadoc/invalidjavadocposition.xml.template
+++ b/src/xdocs/checks/javadoc/invalidjavadocposition.xml.template
@@ -27,7 +27,7 @@
+ value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition/Example1.java"/>
@@ -36,7 +36,7 @@
+ value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition/Example1.java"/>
From 5797f9534904a17c4ea629c5b3b80c96ba83ad5f Mon Sep 17 00:00:00 2001
From: Rohanraj123
Date: Mon, 2 Oct 2023 08:55:13 +0530
Subject: [PATCH 120/833] Issue #13213: Remove ok comments from Fallthrough
Package
---
config/checkstyle-input-suppressions.xml | 38 -------------------
.../coding/fallthrough/InputFallThrough.java | 3 +-
.../coding/fallthrough/InputFallThrough3.java | 6 +--
.../coding/fallthrough/InputFallThrough4.java | 2 +-
.../coding/fallthrough/InputFallThrough.java | 4 +-
.../coding/fallthrough/InputFallThrough3.java | 4 +-
.../coding/fallthrough/InputFallThrough5.java | 2 +-
.../coding/fallthrough/InputFallThrough7.java | 4 +-
.../fallthrough/InputFallThroughDefault.java | 4 +-
...tFallThroughFallThroughLotsOfComment2.java | 2 +-
.../InputFallThroughStringSwitch.java | 2 +-
.../InputFallThroughWithEmoji.java | 6 +--
12 files changed, 20 insertions(+), 57 deletions(-)
diff --git a/config/checkstyle-input-suppressions.xml b/config/checkstyle-input-suppressions.xml
index 399ab6d9164..acb945bb5b5 100644
--- a/config/checkstyle-input-suppressions.xml
+++ b/config/checkstyle-input-suppressions.xml
@@ -147,16 +147,6 @@
files="checks[\\/]coding[\\/]equalsavoidnull[\\/]InputEqualsAvoidNullRecordsAndCompactCtors.java"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- e, V value, String line) {
case "EVICTING":
// In the case of eviction we add the node back as if it was a HIR_RESIDENT
// we now have a HIR resident
- case "HIR_RESIDENT": // ok
+ case "HIR_RESIDENT":
// case 2
if (lirsNode.stackNode != null) {
// This is the (a) example
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughStringSwitch.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughStringSwitch.java
index 2d95ad7b247..cae8cbe719d 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughStringSwitch.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughStringSwitch.java
@@ -13,7 +13,7 @@ public class InputFallThroughStringSwitch
int method(String arg) {
int i = 0;
switch (arg) {
- case "ok": // ok
+ case "ok":
case "break":
break;
case "violation":
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughWithEmoji.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughWithEmoji.java
index aef11a9e679..993c361e03b 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughWithEmoji.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThroughWithEmoji.java
@@ -15,7 +15,7 @@ void foo() {
while (true) {
int i = 0;
switch ("👍") {
- case "ds😂": // ok
+ case "ds😂":
case "": i++; break;
case "👇🏻":
i++;
@@ -62,7 +62,7 @@ void fooFallThru() {
int i = 0;
switch ("") {
- case "ds😂": // ok
+ case "ds😂":
case "":
i++;
break;
@@ -97,7 +97,7 @@ void fooFallThru() {
//🥳d🥳 fallthru
case "10": String s2 = "s🥳d🥳s";
- /*🥳🥳🥳🥳🥳🥳*/ /* fallthru */ default: i++; // ok
+ /*🥳🥳🥳🥳🥳🥳*/ /* fallthru */ default: i++;
}
}
From ac7b37c47da117f9b6f5dabef41e7ab7b4c2c3ee Mon Sep 17 00:00:00 2001
From: Roman Ivanov
Date: Wed, 4 Oct 2023 06:05:32 -0700
Subject: [PATCH 121/833] minor: bountysource is closed
---
.github/FUNDING.yml | 1 -
README.md | 8 --------
config/jsoref-spellchecker/whitelist.words | 1 -
pom.xml | 3 ---
src/xdocs/contributing.xml | 15 ---------------
src/xdocs/sponsoring.xml | 18 ------------------
6 files changed, 46 deletions(-)
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index 900bd3e48af..70c0b1f2376 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -9,4 +9,3 @@ open_collective: checkstyle
liberapay: checkstyle
# issuehunt: # Replace with a single IssueHunt username
# otechie: # Replace with a single Otechie username
-custom: https://www.bountysource.com/teams/checkstyle/issues
diff --git a/README.md b/README.md
index cba86025761..63e4839a5e3 100644
--- a/README.md
+++ b/README.md
@@ -73,8 +73,6 @@ Bugs and Feature requests (not the questions): https://github.com/checkstyle/che
If you want to speed up fixing of issue and want to encourage somebody in
internet to resolve any issue:
-[![][bountysource img]][bountysource]
-[![][salt.bountysource img]][salt.bountysource]
[![][flattr img]][flattr]
[![][liberapay img]][liberapay]
[![][backers.opencollective img]][backers.opencollective]
@@ -161,12 +159,6 @@ are in the file named "LICENSE.apache20" in this directory.
[liberapay]:https://liberapay.com/checkstyle/
[liberapay img]:https://liberapay.com/assets/widgets/donate.svg
-[bountysource]:https://www.bountysource.com/teams/checkstyle/issues
-[bountysource img]:https://api.bountysource.com/badge/team?team_id=3568&style=bounties_posted
-
-[salt.bountysource]:https://salt.bountysource.com/teams/checkstyle
-[salt.bountysource img]:https://img.shields.io/bountysource/team/checkstyle/activity.svg?label=salt.bountysource
-
[backers.opencollective]:https://opencollective.com/checkstyle/
[backers.opencollective img]:https://opencollective.com/checkstyle/backers/badge.svg
diff --git a/config/jsoref-spellchecker/whitelist.words b/config/jsoref-spellchecker/whitelist.words
index 8e4f1c3ef6b..7cf031017d9 100644
--- a/config/jsoref-spellchecker/whitelist.words
+++ b/config/jsoref-spellchecker/whitelist.words
@@ -128,7 +128,6 @@ Bludov
BNOT
booleanexpressioncomplexity
bothfiles
-bountysource
Bpmn
bracesareused
breadcrumbs
diff --git a/pom.xml b/pom.xml
index 76a8c8b9d0c..bec1c9d4018 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2119,9 +2119,6 @@
https://www.w3.org/TR/*https://maven.apache.org/*
-
- https://www.bountysource.com/*
- https://api.bountysource.com/*https://bitbucket.org/atlassian/bamboo-checkstyle-plugin
diff --git a/src/xdocs/contributing.xml b/src/xdocs/contributing.xml
index d4666042b71..8e9c4c8edc7 100644
--- a/src/xdocs/contributing.xml
+++ b/src/xdocs/contributing.xml
@@ -189,20 +189,5 @@
-
-
-
- Some (mostly important) issues are marked with the label
- has bounty.
- By solving such problem, you will not only help the community,
- but also get free beer (in monetary terms to your PayPal account).
-
-
-
- All you need to do is link your github
- account and paypal account through
- the bountysource website.
-
All messages can be customized if the default message doesn't suit you.
Please see the documentation
diff --git a/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml b/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml
index bdd5c11a561..a1d6e22d0dc 100644
--- a/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml
+++ b/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml
@@ -139,24 +139,27 @@ public class Test {
All messages can be customized if the default message doesn't suit you.
Please see the documentation
diff --git a/src/xdocs/checks/javadoc/requireemptylinebeforeblocktaggroup.xml b/src/xdocs/checks/javadoc/requireemptylinebeforeblocktaggroup.xml
index 081dab94413..09175919778 100644
--- a/src/xdocs/checks/javadoc/requireemptylinebeforeblocktaggroup.xml
+++ b/src/xdocs/checks/javadoc/requireemptylinebeforeblocktaggroup.xml
@@ -92,24 +92,27 @@ public boolean testMethod(int firstParam) {