diff --git a/CHECKSTYLE_VERSION b/CHECKSTYLE_VERSION
index 803ed03..1a2c355 100644
--- a/CHECKSTYLE_VERSION
+++ b/CHECKSTYLE_VERSION
@@ -1 +1 @@
-8.39
+9.2
diff --git a/Dockerfile b/Dockerfile
index 3ac3895..6ffb154 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,7 +2,7 @@ FROM ruby:2.6.3-alpine
ENV LANG C.UTF-8
-MAINTAINER "Code Climate Finds nested blocks (blocks that are used freely in the code). Rationale: Nested blocks are often leftovers from thedebugging process, they confuse the reader. For example this Check finds the obsolete braces in and debugging / refactoring leftovers such as A case in a switch statement does not implicitly form a block.Thus to be able to introduce local variables that have casescope it is necessary to open a nested block. This issupported, set the allowInSwitchCase property to true andinclude all statements of the case in the block.
+ Finds nested blocks (blocks that are used freely in the code). Rationale: Nested blocks are often leftovers from thedebugging process, they confuse the reader. For example, this check finds the obsolete braces in and debugging / refactoring leftovers such as A case in a switch statement does not implicitly form a block.Thus to be able to introduce local variables that have casescope it is necessary to open a nested block. This issupported, set the allowInSwitchCase property to true andinclude all statements of the case in the block.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Detects double brace initialization. Rationale: Double brace initialization (set ofInstance Initializers in class body) may look cool,but it is considered as anti-pattern and should be avoided.This is also can lead to a hard-to-detect memory leak, if the anonymous class instance isreturned outside and other object(s) hold reference to it.Created anonymous class is not static, it holds an implicit reference to the outer classinstance.See thisblog post andarticle for more details.Check ignores any comments and semicolons in class body.
+ Detects double brace initialization. Rationale: Double brace initialization (set ofInstance Initializers in class body) may look cool,but it is considered as anti-pattern and should be avoided.This is also can lead to a hard-to-detect memory leak, if the anonymous class instance isreturned outside and other object(s) hold reference to it.Created anonymous class is not static, it holds an implicit reference to the outer classinstance.See thisblog post andarticle for more details.Check ignores any comments and semicolons in class body.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Evaluates Xpath query and report violation on all matching AST nodes. This check allowsuser to implement custom checks using Xpath. If Xpath query is not specified explicitly,then the check does nothing. It is recommended to define custom message for violation to explain what is not allowedand what to use instead, default message might be too abstract. To customize a messageyou need to add Please read more about Xpath syntax atXpath Syntax.Information regarding Xpath functions can be found atXSLT/XPathReference. Note, that @text attribute can used only with token types thatare listed inXpathUtil.
+ Evaluates Xpath query and report violation on all matching AST nodes. This check allowsuser to implement custom checks using Xpath. If Xpath query is not specified explicitly,then the check does nothing. It is recommended to define custom message for violation to explain what is not allowedand what to use instead, default message might be too abstract. To customize a messageyou need to add Please read more about Xpath syntax atXpath Syntax.Information regarding Xpath functions can be found atXSLT/XPathReference. Note, that @text attribute can used only with token types thatare listed inXpathUtil.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Checks that for loop control variables are not modified insidethe for block. An example is: Rationale: If the control variable is modified inside the loopbody, the program flow becomes more difficult to follow. SeeFOR statement specification for more details. Such loop would be suppressed:
+ Checks that for loop control variables are not modified insidethe for block. An example is: Rationale: If the control variable is modified inside the loopbody, the program flow becomes more difficult to follow. SeeFOR statement specification for more details. Such loop would be suppressed: NOTE:The check works with only primitive type variables.The check will not work for arrays used as control variable.An example is
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Checks that string literals are not used with Rationale: Novice Java programmers often use code like: when they mean
+ Checks that string literals are not used with Rationale: Novice Java programmers often use code like: when they mean
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Checks if unnecessary parentheses are used in a statement or expression.The check will flag the following with warnings:
+ Checks if unnecessary parentheses are used in a statement or expression.The check will flag the following with warnings:
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Checks the distance between declaration of variable and its first usage.
+ Checks the distance between declaration of variable and its first usage.Note : Variable declaration/initialization statements are not countedwhile calculating length.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Ensures that exception classes (classes with names conforming to some regularexpression and explicitly extending classes with names conforming to otherregular expression) are immutable, that is, that they have only final fields. The current algorithm is very simple: it checks that all members ofexception are final. The user can still mutate an exception's instance(e.g. Throwable has a method called Rationale: Exception instances should represent an errorcondition. Having non final fields not only allows the state to bemodified by accident and therefore mask the original condition butalso allows developers to accidentally forget to set the initial state.In both cases, code catching the exception could draw incorrectconclusions based on the state.
+ Ensures that exception classes (classes with names conforming to some patternand explicitly extending classes with names conforming to otherpattern) are immutable, that is, that they have only final fields. The current algorithm is very simple: it checks that all members ofexception are final. The user can still mutate an exception's instance(e.g. Throwable has a method called Rationale: Exception instances should represent an errorcondition. Having non final fields not only allows the state to bemodified by accident and therefore mask the original condition butalso allows developers to accidentally forget to set the initial state.In both cases, code catching the exception could draw incorrectconclusions based on the state.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Filter Currently, filter does not support the following checks: Also, the filter does not support suppressions inside javadoc reported by Javadoc checks: Note, that support for these Checks will be available after resolving issues#5770 and#5777. Currently, filter supports the followingxpath axes: You can use the command line helper tool to generate xpathsuppressions based on your configuration file and input files.Seeherefor more details.
+ Filter Currently, filter does not support the following checks: Also, the filter does not support suppressions inside javadoc reported by Javadoc checks: Note, that support for these Checks will be available after resolving issue#5770. Currently, filter supports the followingxpath axes: You can use the command line helper tool to generate xpathsuppressions based on your configuration file and input files.Seeherefor more details.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Checks the header of a source file against a header that contains aregular expression for each line of the source header. Rationale: In some projects checking against afixed header is not sufficient, e.g. the header might require acopyright line where the year information is not static. For example, consider the following header: Lines 1 and 6 demonstrate a more compact notation for 71 '/'characters. Line 4 enforces that the copyright notice includes afour digit year. Line 5 is an example how to enforce revisioncontrol keywords in a file header. Lines 12-14 is a template forjavadoc (line 13 is so complicated to remove conflict with and ofjavadoc comment). Lines 7, 9 and 11 will be treated as '^$' andwill forcefully expect the line to be empty. Different programming languages have different comment syntaxrules, but all of them start a comment with a non-wordcharacter. Hence you can often use the non-word characterclass to abstract away the concrete comment syntax and allowchecking the header for different languages with a singleheader definition. For example, consider the following headerspecification (note that this is not the full Apache licenseheader): Lines 1 and 2 leave room for technical header lines, e.g. the"#!/bin/sh" line in Unix shell scripts, or the XML file headerof XML files. Set the multiline property to "1, 2" so theselines can be ignored for file types where they do no apply.Lines 3 through 6 define the actual header content. Note howlines 2, 4 and 5 use escapes for characters that have specialregexp semantics. In default configuration, if header is not specified, the default valueof header is set to null and the check does not rise any violations.
+ Checks the header of a source file against a header that contains apattern for each line of the source header. Rationale: In some projects checking against afixed header is not sufficient, e.g. the header might require acopyright line where the year information is not static. For example, consider the following header: Lines 1 and 6 demonstrate a more compact notation for 71 '/'characters. Line 4 enforces that the copyright notice includes afour digit year. Line 5 is an example how to enforce revisioncontrol keywords in a file header. Lines 12-14 is a template forjavadoc (line 13 is so complicated to remove conflict with and ofjavadoc comment). Lines 7, 9 and 11 will be treated as '^$' andwill forcefully expect the line to be empty. Different programming languages have different comment syntaxrules, but all of them start a comment with a non-wordcharacter. Hence you can often use the non-word characterclass to abstract away the concrete comment syntax and allowchecking the header for different languages with a singleheader definition. For example, consider the following headerspecification (note that this is not the full Apache licenseheader): Lines 1 and 2 leave room for technical header lines, e.g. the"#!/bin/sh" line in Unix shell scripts, or the XML file headerof XML files. Set the multiline property to "1, 2" so theselines can be ignored for file types where they do no apply.Lines 3 through 6 define the actual header content. Note howlines 2, 4 and 5 use escapes for characters that have specialregexp semantics. In default configuration, if header is not specified, the default valueof header is set to null and the check does not rise any violations.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Checks the Javadoc of a method or constructor. The scopeto verify is specified using the Violates parameters and type parametersfor which no param tags arepresent can be suppressed by defining property Violates methods which return non-void but for which no return tag ispresent can be suppressed by defining property Violates exceptions which are declared to be thrown (by ATTENTION: Checkstyle does not have information about hierarchy of exception typesso usage of base class is considered as separate exception type.As workaround you need to specify both types in javadoc (parent and exact type). Javadoc is not required on a method that is tagged with the Note that only inheritable items will allow the For example, if the following method isimplementing a method required by an interface, then theJavadoc could be done as:
+ Checks the Javadoc of a method or constructor. Violates parameters and type parametersfor which no param tags arepresent can be suppressed by defining property Violates methods which return non-void but for which no return tag ispresent can be suppressed by defining property Violates exceptions which are declared to be thrown (by ATTENTION: Checkstyle does not have information about hierarchy of exception typesso usage of base class is considered as separate exception type.As workaround you need to specify both types in javadoc (parent and exact type). Javadoc is not required on a method that is tagged with the Note that only inheritable items will allow the For example, if the following method isimplementing a method required by an interface, then theJavadoc could be done as:
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Checks the Javadoc comments for type definitions.By default, does not check for author or version tags. Thescope to verify is specified using the Does not perform checks for author and version tags for innerclasses, as they should be redundant because of outer class. Error messages about type parameters and record components for which noparam tags are present can be suppressed by defining property
+ Checks the Javadoc comments for type definitions.By default, does not check for author or version tags. Thescope to verify is specified using the Does not perform checks for author and version tags for innerclasses, as they should be redundant because of outer class. Error messages about type parameters and record components for which noparam tags are present can be suppressed by defining property
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Checks for missing Javadoc comments for a method or constructor.The scope to verify is specified using the Javadoc is not required on a method that is tagged with the For getters and setters for the property
+ Checks for missing Javadoc comments for a method or constructor.The scope to verify is specified using the Javadoc is not required on a method that is tagged with the For getters and setters for the property
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Controls the indentation between comments and surrounding code.Comments are indented at the same level as the surrounding code.Detailed info about such convention can be foundhere Please take a look at the following examples to understand how the check works: Example #1: Block comments. Example #2: Comment is placed at the end of the block and has previous statement. Example #3: Comment is used as a single line border to separate groups of methods. Example #4: Comment has distributed previous statement. Example #5: Single line block comment is placed within an empty code block.Note, if comment is placed at the end of the empty code block, we have Checkstyle'slimitations to clearly detect user intention of explanation target - above or below. Theonly case we can assume as a violation is when a single line comment within the emptycode block has indentation level that is lower than the indentation level of the closingright curly brace. Example #6: 'fallthrough' comments and similar. Example #7: Comment is placed within a distributed statement. Example #8: Comment is placed within an empty case block.Note, if comment is placed at the end of the empty case block, we have Checkstyle'slimitations to clearly detect user intention of explanation target - above or below. Theonly case we can assume as a violation is when a single line comment within the empty caseblock has indentation level that is lower than the indentation level of the next casetoken. Example #9: Single line block comment has previous and next statement. Example #10: Comment within the block tries to describe the next code block.
+ Controls the indentation between comments and surrounding code.Comments are indented at the same level as the surrounding code.Detailed info about such convention can be foundhere
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Checks for
+ Checks for
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
The check to ensure that requires that comments be the only thing ona line. For the case of Rationale: Steve McConnell in Code Complete suggests thatendline comments are a bad practice. An end line comment would beone that is on the same line as actual code. For example: Quoting Code Complete for the justification: McConnell's comments on being hard to maintain when the size of the linechanges are even more important in the age of automatedrefactorings.
+ The check to ensure that lines with code do not end with comment.For the case of Rationale: Steve McConnell in Code Complete suggests thatendline comments are a bad practice. An end line comment would beone that is on the same line as actual code. For example: Quoting Code Complete for the justification: McConnell's comments on being hard to maintain when the size of the linechanges are even more important in the age of automatedrefactorings.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Checks that the order of modifiers conforms to the suggestions inthe JavaLanguage specification, § 8.1.1, 8.3.1, 8.4.3 and9.4. The correct order is: In additional, modifiers are checked to ensure all annotations aredeclared before all other modifiers. Rationale: Code is easier to read if everybody follows a standard. ATTENTION: We skiptype annotations from validation.
+ Checks that the order of modifiers conforms to the suggestions inthe JavaLanguage specification, § 8.1.1, 8.3.1, 8.4.3 and9.4. The correct order is: In additional, modifiers are checked to ensure all annotations aredeclared before all other modifiers. Rationale: Code is easier to read if everybody follows a standard. ATTENTION: We skiptype annotations from validation.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Ensures that the names of abstract classes conforming to some regular expression andcheck that Rationale: Abstract classes are convenience base class implementations ofinterfaces, not types as such. As such they should be named to indicate this.Also if names of classes starts with 'Abstract' it's very convenient thatthey will have abstract modifier.
+ Ensures that the names of abstract classes conforming to some pattern andcheck that Rationale: Abstract classes are convenience base class implementations ofinterfaces, not types as such. As such they should be named to indicate this.Also if names of classes starts with 'Abstract' it's very convenient thatthey will have abstract modifier.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
com.puppycrawl.tools.checkstyle.checks.naming Checks identifiers with a regular expression for a set of illegal names, such as thosethat are restricted or contextual keywords. Examples include "yield", "record","_", and "var". Please read more atJava Language Specificationto get to know more about restricted keywords. Since this check uses aregular expression to specify valid identifiers, users can also prohibit the usageof certain symbols, such as "$", or any non-ascii character.
+ Checks identifiers with a pattern for a set of illegal names, such as thosethat are restricted or contextual keywords. Examples include "yield", "record","_", and "var". Please read more atJava Language Specificationto get to know more about restricted keywords. Since this check uses apattern to specify valid identifiers, users can also prohibit the usageof certain symbols, such as "$", or any non-ascii character.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
com.puppycrawl.tools.checkstyle.checks.naming
public void guessTheOutput()
{
int whichIsWhich = 0;
{
whichIsWhich = 2;
}
System.out.println("value = " + whichIsWhich);
}
// if (conditionThatIsNotUsedAnyLonger)
{
System.out.println("unconditional");
}
switch (a)
{
case 0:
// Never OK, break outside block
{
x = 1;
}
break;
case 1:
// Never OK, statement outside block
System.out.println("Hello");
{
x = 2;
break;
}
case 2:
// OK if allowInSwitchCase is true
{
System.out.println("Hello");
x = 3;
break;
}
}
public void guessTheOutput()
{
int whichIsWhich = 0;
{
whichIsWhich = 2;
}
System.out.println("value = " + whichIsWhich);
}
// if (conditionThatIsNotUsedAnyLonger)
{
System.out.println("unconditional");
}
message
element with matchxpath.match askey
attribute and desired message as value
attribute.message
element with matchxpath.match askey
attribute and desired message as value
attribute.
for (int i = 0; i < 1; i++) {
i++; //violation
}
for (int i = 0; i < 10;) {
i++;
}
for (int i = 0; i < 1; i++) {
i++; // violation
}
for (int i = 0; i < 10;) {
i++;
}
for (int a[]={0};a[0] < 10;a[0]++) {
a[0]++; // it will skip this violation
}
==
or!=
.Since ==
will compare the object references,not the actual value of the strings,String.equals()
should be used.More information can be foundin this article.
if (x == "something")
if ("something".equals(x))
==
or!=
.Since ==
will compare the object references,not the actual value of the strings,String.equals()
should be used.More information can be foundin this article.
if (x == "something")
if ("something".equals(x))
return (x); // parens around identifier
return (x + 1); // parens around return value
int x = (y / 2 + 1); // parens around assignment rhs
for (int i = (0); i < 10; i++) { // parens around literal
t -= (z + 1); // parens around assignment rhs
return (x); // parens around identifier
return (x + 1); // parens around return value
int x = (y / 2 + 1); // parens around assignment rhs
for (int i = (0); i < 10; i++) { // parens around literal
t -= (z + 1); // parens around assignment rhs
boolean a = (x > 7 && y > 5) // parens around expression
|| z < 9;
boolean b = (~a) > -27 // parens around ~a
&& (a-- < 30); // parens around expression
setStackTrace
which changes the exception's stack trace). But, at least, all informationprovided by this exception type is unchangeable.setStackTrace
which changes the exception's stack trace). But, at least, all informationprovided by this exception type is unchangeable.SuppressionXpathFilter
works asSuppressionFilter.Additionally, filter processes suppress-xpath
elements,which contains xpath-expressions. Xpath-expressionsare queries for suppressed nodes inside the AST tree.SuppressionXpathFilter
works asSuppressionFilter.Additionally, filter processes suppress-xpath
elements,which contains xpath-expressions. Xpath-expressionsare queries for suppressed nodes inside the AST tree.
line 1: ^/{71}$
line 2: ^// checkstyle:$
line 3: ^// Checks Java source code for adherence to a set of rules\.$
line 4: ^// Copyright \(C\) \d\d\d\d Oliver Burn$
line 5: ^// Last modification by \$Author.*\$$
line 6: ^/{71}$
line 7:
line 8: ^package
line 9:
line 10: ^import
line 11:
line 12: ^/\*\*
line 13: ^ \*([^/]|$)
line 14: ^ \*/
line 1: ^#!
line 2: ^<\?xml.*>$
line 3: ^\W*$
line 4: ^\W*Copyright 2006 The Apache Software Foundation or its licensors, as applicable\.$
line 5: ^\W*Licensed under the Apache License, Version 2\.0 \(the "License"\);$
line 6: ^\W*$
line 1: ^/{71}$
line 2: ^// checkstyle:$
line 3: ^// Checks Java source code for adherence to a set of rules\.$
line 4: ^// Copyright \(C\) \d\d\d\d Oliver Burn$
line 5: ^// Last modification by \$Author.*\$$
line 6: ^/{71}$
line 7:
line 8: ^package
line 9:
line 10: ^import
line 11:
line 12: ^/\*\*
line 13: ^ \*([^/]|$)
line 14: ^ \*/
line 1: ^#!
line 2: ^<\?xml.*>$
line 3: ^\W*$
line 4: ^\W*Copyright 2006 The Apache Software Foundation or its licensors, as applicable\.$
line 5: ^\W*Licensed under the Apache License, Version 2\.0 \(the "License"\);$
line 6: ^\W*$
Scope
class anddefaults to Scope.PRIVATE
. To verify anotherscope, set property scope to a differentscope.allowMissingParamTags
.allowMissingReturnTag
.throws
in the methodsignature or by throw new
in the method body), but for which no throws tag ispresent by activation of property validateThrows
.Note that throw new
is not checked in the following places:@Override
annotation. However underJava 5 it is not possible to mark a method required for aninterface (this was corrected under Java 6). HenceCheckstyle supports using the convention of using a single{@inheritDoc}
tag instead of all theother tags.{@inheritDoc}
tag to be used in placeof comments. Static methods at all visibilities, private non-staticmethods and constructors are not inheritable.
/** {@inheritDoc} */
public int checkReturnTag(final int aTagIndex,
JavadocTag[] aTags,
int aLineNo)
allowMissingParamTags
.allowMissingReturnTag
.throws
in the methodsignature or by throw new
in the method body), but for which no throws tag ispresent by activation of property validateThrows
.Note that throw new
is not checked in the following places:@Override
annotation. However underJava 5 it is not possible to mark a method required for aninterface (this was corrected under Java 6). HenceCheckstyle supports using the convention of using a single{@inheritDoc}
tag instead of all theother tags.{@inheritDoc}
tag to be used in placeof comments. Static methods at all visibilities, private non-staticmethods and constructors are not inheritable.
/** {@inheritDoc} */
public int checkReturnTag(final int aTagIndex,
JavadocTag[] aTags,
int aLineNo)
Scope
class and defaults to Scope.PRIVATE
. To verifyanother scope, set property scope to one of theScope
constants. To define the format for anauthor tag or a version tag, set property authorFormat orversionFormat respectively to aregular expression.allowMissingParamTags
.Scope
class and defaults to Scope.PRIVATE
. To verifyanother scope, set property scope to one of theScope
constants. To define the format for anauthor tag or a version tag, set property authorFormat orversionFormat respectively to apattern.allowMissingParamTags
.Scope
class anddefaults to Scope.PUBLIC
. To verify anotherscope, set property scope to a differentscope.@Override
annotation. However underJava 5 it is not possible to mark a method required for aninterface (this was corrected under Java 6). HenceCheckstyle supports using the convention of using a single{@inheritDoc}
tag instead of all theother tags.allowMissingPropertyJavadoc
,the methods must match exactly the structures below.public void setNumber(final int number){mNumber = number;}public int getNumber(){return mNumber;}public boolean isSomething(){return false;}
Scope
class anddefaults to Scope.PUBLIC
. To verify anotherscope, set property scope to a differentscope.@Override
annotation. However underJava 5 it is not possible to mark a method required for aninterface (this was corrected under Java 6). HenceCheckstyle supports using the convention of using a single{@inheritDoc}
tag instead of all theother tags.allowMissingPropertyJavadoc
,the methods must match exactly the structures below.
public void setNumber(final int number)
{
mNumber = number;
}
public int getNumber()
{
return mNumber;
}
public boolean isSomething()
{
return false;
}
1 /*
2 * it is Ok
3 */
4 boolean bool = true;
5
6 /* violation
7 * (block comment should have the same indentation level as line 9)
8 */
9 double d = 3.14;
1 public void foo1() {
2 foo2();
3 // it is OK
4 }
5
6 public void foo2() {
7 foo3();
8 // violation (comment should have the same indentation level as line 7)
9 }
1 /////////////////////////////// it is OK
2
3 public void foo7() {
4 int a = 0;
5 }
6
7 ///////////////////////////// violation (should have the same indentation level as line 9)
8
9 public void foo8() {}
1 public void foo11() {
2 CheckUtil
3 .getFirstNode(new DetailAST())
4 .getFirstChild()
5 .getNextSibling();
6 // it is OK
7 }
8
9 public void foo12() {
10 CheckUtil
11 .getFirstNode(new DetailAST())
12 .getFirstChild()
13 .getNextSibling();
14 // violation (should have the same indentation level as line 10)
15 }
1 public void foo46() {
2 // comment
3 // block
4 // it is OK (we cannot clearly detect user intention of explanation target)
5 }
6
7 public void foo46() {
8 // comment
9 // block
10 // violation (comment should have the same indentation level as line 11)
11 }
0 switch(a) {
1 case "1":
2 int k = 7;
3 // it is OK
4 case "2":
5 int k = 7;
6 // it is OK
7 case "3":
8 if (true) {}
9 // violation (should have the same indentation level as line 8 or 10)
10 case "4":
11 case "5": {
12 int a;
13 }
14 // fall through (it is OK)
15 case "12": {
16 int a;
17 }
18 default:
19 // it is OK
20 }
1 String breaks = "J"
2 // violation (comment should have the same indentation level as line 3)
3 + "A"
4 // it is OK
5 + "V"
6 + "A"
7 // it is OK
8 ;
1 case 4:
2 // it is OK
3 case 5:
4 // violation (should have the same indentation level as line 3 or 5)
5 case 6:
1 String s1 = "Clean code!";
2 s.toString().toString().toString();
3 // single line
4 // block
5 // comment (it is OK)
6 int a = 5;
7
8 String s2 = "Code complete!";
9 s.toString().toString().toString();
10 // violation (should have the same indentation level as line 11)
11 // violation (should have the same indentation level as line 12)
12 // violation (should have the same indentation level as line 13)
13 int b = 18;
1 public void foo42() {
2 int a = 5;
3 if (a == 5) {
4 int b;
5 // it is OK
6 } else if (a ==6) { ... }
7 }
8
9 public void foo43() {
10 try {
11 int a;
12 // Why do we catch exception here? - violation (not the same indentation as line 11)
13 } catch (Exception e) { ... }
14 }
TODO:
comments. Actuallyit is a genericregularexpression matcher on Java comments. To check for otherpatterns in Java comments, set the format
property.TODO:
comments. Actuallyit is a genericpattern matcher on Java comments. To check for otherpatterns in Java comments, set the format
property.//
comments that means that the only thingthat should precede it is whitespace. It doesn't check comments ifthey do not end a line; for example, it accepts the following:Thread.sleep( 10 /*some comment here*/ );
Formatproperty is intended to deal with the } // while
example.
a = b + c; // Some insightful comment
d = e / f; // Another comment for this line
//
comments that means that the only thingthat should precede it is whitespace. It doesn't check comments ifthey do not end a line; for example, it accepts the following:Thread.sleep( 10 /*some comment here*/ );
Formatproperty is intended to deal with the } // while
example.
a = b + c; // Some insightful comment
d = e / f; // Another comment for this line
public
protected
private
abstract
default
static
final
transient
volatile
synchronized
native
strictfp
public
protected
private
abstract
default
static
sealed
non-sealed
final
transient
volatile
synchronized
native
strictfp
abstract
modifier exists.abstract
modifier exists.
com.puppycrawl.tools.checkstyle.checks.naming
.RecordComponentNameCheck": + Description: | +Checks that record component names conform to a specified pattern.
+ This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project. +
+ Package: "com.puppycrawl.tools.checkstyle.checks.naming
" "com.puppycrawl.tools.checkstyle.checks.naming
.RecordTypeParameterNameCheck": Description: |Checks that record type parameter names conform to a specified pattern.
@@ -1056,10 +1062,9 @@ com.puppycrawl.tools.checkstyle.checks.sizes.RecordComponentNumberCheck: This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Package: com.puppycrawl.tools.checkstyle.checks.sizes -".Caching SupportCheck": {} -".Localisation SupportCheck": {} -".Base directory supportCheck": {} +".Localization SupportCheck": {} ".Enable External DTD loadCheck": {} +".Property chaining supportCheck": {} com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck: Description: |Checks the padding of an empty for initializer; that is whethera white space is required at an empty for initializer, or such whitespace is forbidden. No check occurs if there is a line wrap at theinitializer, as in
@@ -1074,7 +1079,7 @@ com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck: Package: com.puppycrawl.tools.checkstyle.checks.whitespace com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck: Description: | -
Checks for empty line separators after header, package, all import declarations,fields, constructors, methods, nested classes,static initializers and instance initializers.
ATTENTION: empty line separator is required between token siblings,not after line where token is found.If token does not have same type sibling then empty lineis required at its end (for example for CLASS_DEF it is after '}').Also, trailing comments are skipped.
ATTENTION: violations from multiple empty lines cannot be suppressed via XPath:#8179.
+
Checks for empty line separators before package, all import declarations,fields, constructors, methods, nested classes,static initializers and instance initializers.
Checks for empty line separators before not only statements butimplementation and documentation comments and blocks as well.
ATTENTION: empty line separator is required between token siblings,not after line where token is found.If token does not have same type sibling then empty lineis required at its end (for example for CLASS_DEF it is after '}').Also, trailing comments are skipped.
ATTENTION: violations from multiple empty lines cannot be suppressed via XPath:#8179.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Package: com.puppycrawl.tools.checkstyle.checks.whitespace @@ -1114,6 +1119,12 @@ com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCheck: This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project. Package: com.puppycrawl.tools.checkstyle.checks.whitespace +com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck: + Description: | +Checks that there is no whitespace before the colon in a switch block.
+ This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project. +
+ Package: com.puppycrawl.tools.checkstyle.checks.whitespace com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapCheck: Description: |Checks the policy on how to wrap lines on operators.
diff --git a/config/codeclimate_checkstyle.xml b/config/codeclimate_checkstyle.xml
index 34bd873..8f6cca6 100644
--- a/config/codeclimate_checkstyle.xml
+++ b/config/codeclimate_checkstyle.xml
@@ -125,7 +125,7 @@