From d4604131107ef1ac1df0910b69334254d57a2c45 Mon Sep 17 00:00:00 2001
From: Federico Moya Checks that all package annotations are in the package-info.java file. According to the Java Language Specification. The JLS does not enforce the placement of package annotations.This placement may vary based on implementation. The JLSdoes highly recommend that all package annotations areplaced in the package-info.java file.See Java Language Specification, §7.4.1.
+ Checks that all package annotations are in the package-info.java file. For Java SE8 and above, placement of package annotations in the package-info.javafile is enforced by the compiler and this check is not necessary. For Java SE7 and below, the Java Language Specification highly recommendsbut doesn't require that annotations are placed in the package-info.java file,and this check can help to enforce that placement. See Java Language Specification, §7.4.1 for more info.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Checks that overload methods are grouped together.
+ Checks that overloaded methods are grouped together. Overloaded methods have the samename but different signatures where the signature can differ by the number of inputparameters or type of input parameters or both.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Ensures that a class has a package declaration, and (optionally) whetherthe package name matches the directory name for the source file. Rationale: Classes that live in the null package cannot beimported. Many novice developers are not aware of this. Packages provide logical namespace to classes and should be stored inthe form of directory levels to provide physical grouping to your classes.These directories are added to the classpath so that your classesare visible to JVM when it runs the code.
+ Ensures that a class has a package declaration, and (optionally) whetherthe package name matches the directory name for the source file. Rationale: Classes that live in the null package cannot beimported. Many novice developers are not aware of this. Packages provide logical namespace to classes and should be stored inthe form of directory levels to provide physical grouping to your classes.These directories are added to the classpath so that your classesare visible to JVM when it runs the code. Note:This Check is partially supported by Xpath Suppression Filters. In case of testing emptyjava files, Xpath Suppression Filters are not supported for this Check. (until#8110)
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Checks if unnecessary semicolon is used after type declaration.
+ 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.coding com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterTypeMemberDeclarationCheck: Description: |Checks if unnecessary semicolon is used after type member declaration.
@@ -421,7 +427,7 @@ com.puppycrawl.tools.checkstyle.checks.design.MutableExceptionCheck: Package: com.puppycrawl.tools.checkstyle.checks.design com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck: Description: | -
Checks that each top-level class, interface orenum resides in a source file of its own.Official description of a 'top-level' term:7.6. Top Level Type Declarations.If file doesn't contains public class, enum or interface,top-level type is the first type in file.
+
Checks that each top-level class, interface, enumor annotation resides in a source file of its own.Official description of a 'top-level' term:7.6. Top Level Type Declarations.If file doesn't contains public class, interface, enum or annotation,top-level type is the first type in file.
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.design @@ -433,7 +439,7 @@ com.puppycrawl.tools.checkstyle.checks.design.ThrowsCountCheck: Package: com.puppycrawl.tools.checkstyle.checks.design com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck: Description: | -Checks visibility of class members. Only static final, immutable or annotatedby specified annotation members may be public; other class members must be privateunless the property protectedAllowed
or packageAllowed
is set.
Public members are not flagged if the name matches the publicmember regular expression (contains "^serialVersionUID$"
by default).
Note thatCheckstyle 2 used to include "^f[A-Z][a-zA-Z0-9]*$"
in the defaultpattern to allow names used in container-managed persistence for Enterprise JavaBeans(EJB) 1.1 with the default settings. With EJB 2.0 it is no longer necessary to havepublic access for persistent fields, so the default has been changed.
Rationale: Enforce encapsulation.
Check also has options making it less strict:
ignoreAnnotationCanonicalNames - the list of annotations which ignore variablesin consideration. If user will provide short annotation name that type will match to anynamed the same type without consideration of package.
allowPublicFinalFields - which allows public final fields.
allowPublicImmutableFields - which allows immutable fields to be declared aspublic if defined in final class.
Field is known to be immutable if:
Classes known to be immutable are listed in immutableClassCanonicalNames by theircanonical names.
Rationale: Forcing all fields of class to have private modifier by default is goodin most cases, but in some cases it drawbacks in too much boilerplate get/set code.One of such cases are immutable classes.
Restriction: Check doesn't check if class is immutable, there's nochecking if accessory methods are missing and all fields are immutable, we only checkif current field is immutable or final. Under the flagallowPublicImmutableFields, the enclosing class must also be final, to encourageimmutability. Under the flag allowPublicFinalFields, the final modifier onthe enclosing class is optional.
Star imports are out of scope of this Check. So if one of type imported viastar import collides with user specified one by its short name -there won't be Check's violation.
+
Checks visibility of class members. Only static final, immutable or annotatedby specified annotation members may be public; other class members must be privateunless the property protectedAllowed
or packageAllowed
is set.
Public members are not flagged if the name matches the publicmember regular expression (contains "^serialVersionUID$"
by default).
Note thatCheckstyle 2 used to include "^f[A-Z][a-zA-Z0-9]*$"
in the defaultpattern to allow names used in container-managed persistence for Enterprise JavaBeans(EJB) 1.1 with the default settings. With EJB 2.0 it is no longer necessary to havepublic access for persistent fields, so the default has been changed.
Rationale: Enforce encapsulation.
Check also has options making it less strict:
ignoreAnnotationCanonicalNames - the list of annotations which ignore variablesin consideration. If user will provide short annotation name that type will match to anynamed the same type without consideration of package.
allowPublicFinalFields - which allows public final fields.
allowPublicImmutableFields - which allows immutable fields to be declared aspublic if defined in final class.
Field is known to be immutable if:
Classes known to be immutable are listed in immutableClassCanonicalNames by theircanonical names.
Property Rationale: Forcing all fields of class to have private modifier by default isgood in most cases, but in some cases it drawbacks in too much boilerplate get/set code.One of such cases are immutable classes.
Restriction: Check doesn't check if class is immutable, there's nochecking if accessory methods are missing and all fields are immutable, we only checkif current field is immutable or final. Under the flagallowPublicImmutableFields, the enclosing class must also be final, to encourageimmutability. Under the flag allowPublicFinalFields, the final modifier onthe enclosing class is optional.
Star imports are out of scope of this Check. So if one of type imported viastar import collides with user specified one by its short name -there won't be Check's violation.
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.design @@ -469,7 +475,7 @@ com.puppycrawl.tools.checkstyle.filters.SuppressionSingleFilterCheck: Package: com.puppycrawl.tools.checkstyle.filters com.puppycrawl.tools.checkstyle.filters.SuppressionXpathFilterCheck: Description: | -Filter SuppressionXpathFilter
works asSuppressionFilter.Additionally, filter processes suppress-xpath
elements,which contains xpath-expressions. Xpath-expressionsare queries for suppressed nodes inside the AST tree.
Currently, filter does not support the following checks:
Also, the filter does not support 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 SuppressionXpathFilter
works asSuppressionFilter.Additionally, filter processes suppress-xpath
elements,which contains xpath-expressions. Xpath-expressionsare queries for suppressed nodes inside the AST tree.
Currently, filter does not support the following checks:
Certain Checks are partially supported by the filter:
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.Support for Indentation check will be available after resolving issue#7734.
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.
Package: com.puppycrawl.tools.checkstyle.filters @@ -587,6 +593,12 @@ com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck: 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.javadoc +com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck: + Description: | +Checks that there is at least one whitespace after the leading asterisk.Although spaces after asterisks are optional in the Javadoc comments, their absencemakes the documentation difficult to read. It is the de facto standard to put at leastone whitespace after the leading asterisk.
+ 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.javadoc com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck: Description: |Checks that each Java package has a Javadoc file used forcommenting. By default it only allows a package-info.java
file, but can beconfigured to allow a package.html
file.
A violation will be reported if both files exist as this is notallowed by the Javadoc tool.
@@ -601,7 +613,7 @@ com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck: Package: com.puppycrawl.tools.checkstyle.checks.javadoc com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck: Description: | -
Validates Javadoc comments to help ensure they are well formed.
The following checks are performed:
{@inheritDoc}
tag are exempt from thisrequirement.@param
and @return
.These checks were patterned after the checks made by the DocCheckdoclet available from Sun. Note: Original Sun's DocCheck tool does not exist anymore.
+
Validates Javadoc comments to help ensure they are well formed.
The following checks are performed:
{@inheritDoc}
tag are exempt from thisrequirement.@param
and @return
.These checks were patterned after the checks made by the DocCheckdoclet available from Sun. Note: Original Sun's DocCheck tool does not exist anymore.
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.javadoc @@ -818,7 +830,7 @@ com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCheck: ".OverviewCheck": {} com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck: Description: | -Validates abbreviations (consecutive capital letters)length in identifier name, it also allows to enforce camel case naming. Please read more atGoogle Style Guideto get to know how to avoid long abbreviations in names.
allowedAbbreviationLength
specifies how many consecutive capital letters areallowed in the identifier.A value of 3 indicates that up to 4 consecutive capital letters are allowed,one after the other, before a violation is printed. The identifier 'MyTEST' would beallowed, but 'MyTESTS' would not be.A value of 0 indicates that only 1 consecutive capital letter is allowed. Thisis what should be used to enforce strict camel casing. The identifier 'MyTest' wouldbe allowed, but 'MyTEst' would not be.
+
Validates abbreviations (consecutive capital letters)length in identifier name, it also allows to enforce camel case naming. Please read more atGoogle Style Guideto get to know how to avoid long abbreviations in names.
allowedAbbreviationLength
specifies how many consecutive capital letters areallowed in the identifier.A value of 3 indicates that up to 4 consecutive capital letters are allowed,one after the other, before a violation is printed. The identifier 'MyTEST' would beallowed, but 'MyTESTS' would not be.A value of 0 indicates that only 1 consecutive capital letter is allowed. Thisis what should be used to enforce strict camel casing. The identifier 'MyTest' wouldbe allowed, but 'MyTEst' would not be.
ignoreFinal
, ignoreStatic
, and ignoreStaticFinal
control whether variables with the respective modifiers are to be ignored.Note that a variable that is both static and final will always be considered underignoreStaticFinal
only, regardless of the values of ignoreFinal
and ignoreStatic
. So for example if ignoreStatic
is true butignoreStaticFinal
is false, then static final variables will not be ignored.
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 @@ -1020,7 +1032,7 @@ com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck: Package: com.puppycrawl.tools.checkstyle.checks.whitespace com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck: Description: | -Checks that the whitespace around the Generic tokens (angle brackets)"<" and ">" are correct to the typical convention.The convention is not configurable.
Left angle bracket ("<"):
Right angle bracket (">"):
Examples with correct spacing:
+
Checks that the whitespace around the Generic tokens (angle brackets)"<" and ">" are correct to the typical convention.The convention is not configurable.
Left angle bracket ("<"):
Right angle bracket (">"):
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 From 5dd0fb02bb7d48ac9bb5fbff8783d95ab5662675 Mon Sep 17 00:00:00 2001 From: Federico Moya