Google's Java Style Checkstyle Coverage

Useful information

This coverage report was created for Google Java Style( cached page), version of 23 May 2018, current as of 07 May 2019. New target of coverage is the latest version of Google Java Style( cached page), version of 03 Feb 2022.

Checkstyle's html report for Guava library

Checkstyle configuration for 'Google Java Style'

Legend

"--" - There is no rule in this paragraph.
"↓" - This paragraph is the high-level point of some group.
- Existing Check covers all requirements from Google.
- Existing Check covers some part of requirements from Google.
- Requirements are not possible to check by Checkstyle at all.

Coverage table

ATTENTION: Links to config and test in following table reference to latest (not released yet) config. Config might be slightly different from what we have in latest release. Please always use config that is embedded to jar or use a custom version copied from one that matches your checkstyle version.

Google's Java Style Rule Checkstyle Check Applied to config
1 Introduction --
1.1 Terminology notes --
1.2 Guide notes --
2 Source file basics
2.1 File name OuterTypeFilename config
test
2.2 File encoding: UTF-8 explanation
2.3 Special characters
2.3.1 Whitespace characters FileTabCharacter config
test
2.3.2 Special escape sequences IllegalTokenText config
test
2.3.3 Non-ASCII characters AvoidEscapedUnicodeCharacters config
test
3 Source file structure EmptyLineSeparator config
test
3.1 License or copyright information, if present --
3.2 Package statement LineLength

NoLineWrap
config config
test
3.3 Import statements
3.3.1 No wildcard imports AvoidStarImport config
test
3.3.2 No line-wrapping LineLength

NoLineWrap
config
config
test
3.3.3 Ordering and spacing CustomImportOrder config
test
3.3.4 No static import for classes That validation could not be checked by Checkstyle. It's need information from another class(java file). But Checkstyle have no way to open or look at another java file.
3.4 Class declaration
3.4.1 Exactly one top-level class declaration OneTopLevelClass config
test
3.4.2 Class member ordering --
3.4.2.1 Overloads: never split OverloadMethodsDeclarationOrder

ConstructorsDeclarationGrouping
config
config
test
4 Formatting --
4.1 Braces
4.1.1 Use of optional braces NeedBraces config
test
4.1.2 Nonempty blocks: K & R style LeftCurly

RightCurly

The "Exception" part of the rule is not satisfied, it will be addressed in the issue #14294
config
config
test
4.1.3 Empty blocks: may be concise EmptyBlock

EmptyCatchBlock
config
config
test
4.2 Block indentation: +2 spaces Indentation
The rule "A line is never broken adjacent to the arrow in a lambda, except that a break may come immediately after the arrow if the body of the lambda consists of a single unbraced expression" will be addressed in the issue #4006.
config
test
4.3 One statement per line OneStatementPerLine config
test
4.4 Column limit: 100 LineLength

We can detect URL with protocol type as http://, https:// etc.
JSNI is not supported, see reason at: #14938.

Long identifiers will be handled at #15233.
config
test
4.5 Line-wrapping --
4.5.1 Where to break OperatorWrap

SeparatorWrap

MethodParamPad
config
config
config
test
4.5.2 Indent continuation lines at least +4 spaces Indentation config
test
4.6 Whitespace
4.6.1 Vertical Whitespace EmptyLineSeparator
Blank lines between two consecutive fields are optional. This exception is not satisfied
config
test
4.6.2 Horizontal whitespace WhitespaceAround

GenericWhitespace

MethodParamPad

ParenPad

WhitespaceAfter

NoWhitespaceBefore

NoWhitespaceBeforeCaseDefaultColon

There are some false positive and negative cases for "{}" and "{ }". See issue #15338 for more detailed explanation.
config
config
config
config
config
config
config
test
4.6.3 Horizontal alignment: never required --
4.7 Grouping parentheses: recommended --
4.8 Specific constructs
4.8.1 Enum classes --
4.8.2 Variable declarations
4.8.2.1 One variable per declaration MultipleVariableDeclarations config
test
4.8.2.2 Declared when needed VariableDeclarationUsageDistance
config
test
4.8.3 Arrays
4.8.3.1 Array initializers: can be "block-like" --
4.8.3.2 No C-style array declarations ArrayTypeStyle config
test
4.8.4 Switch statements --
4.8.4.1 Indentation Indentation config
test
4.8.4.2 Fall-through: commented FallThrough config
test
4.8.4.3 Presence of the default label MissingSwitchDefault
"Exception: enum type may omit the default statement group" requirement can not be covered as we can not distinguish types, enum values may look the same as static final String constants.
config
test
4.8.5 Annotations
4.8.5.1 Type-use annotations Type-use annotations cannot be detected by Checkstyle due to it's limitations, see issue #15416 for more detailed explanation.
4.8.5.2 Class Annotations AnnotationLocation

InvalidJavadocPosition
config
config
test
4.8.5.3 Methods And Constructors Annotations AnnotationLocation

InvalidJavadocPosition
config
config
test
4.8.5.4 Field Annotations AnnotationLocation

InvalidJavadocPosition
config
config
test
4.8.5.5 Parameter and local variable annotations --

For type-use annotations see 4.8.5.1 Type-use annotations
4.8.6 Comments
4.8.6.1 Block comment style CommentsIndentation config
test
4.8.7 Modifiers ModifierOrder config
test
4.8.8 Numeric Literals UpperEll config
test
5 Naming
5.1 Rules common to all identifiers CatchParameterName

All other types of identifiers are covered in special sections below
config
test
5.2 Rules by identifier type
5.2.1 Package names PackageName config
test
5.2.2 Class names TypeName config
test
5.2.3 Method names MethodName
No ability to distinguish verb at the beginning of name; distinguishing of Test method from others to allow "_" in test methods only will be done at #15429.
config
test
5.2.4 Constant names Every constant is a static final field, but not all static final fields are constants - impossible to check such rule.
5.2.5 Non-constant field names MemberName config
test
5.2.6 Parameter names ParameterName

CatchParameterName

LambdaParameterName

RecordComponentName
config
config
config
config
test
5.2.7 Local variable names LocalVariableName

PatternVariableName
config
config
test
5.2.8 Type variable names MethodTypeParameterName

ClassTypeParameterName

InterfaceTypeParameterName

RecordTypeParameterName
config
config
config
config
test
5.3 Camel case: defined AbbreviationAsWordInName
Non covered: Some words are ambiguously hyphenated in the English language. No way to distinguish "YouTubeImporter" or "YoutubeImporter".
config
test
6 Programming Practices
6.1 @Override: always used That validation could not be checked by Checkstyle. It's need to take a look as parent class. But Checkstyle have no way to open or look at another Class file.
6.2 Caught exceptions: not ignored EmptyBlock

EmptyCatchBlock
config
config
test
6.3 Static members: qualified using class Proper validation require parsing other files, sources are not always available.
6.4 Finalizers: not used NoFinalizer config
test
7 Javadoc
7.1 Formatting
7.1.1 General form SingleLineJavadoc

InvalidJavadocPosition
config
config
test
7.1.2 Paragraphs JavadocParagraph
We don't have support to check for the extra preceding p tag before block tag; there is known issue to cover it fully: #15011

RequireEmptyLineBeforeBlockTagGroup
config
config
test
7.1.3 Block tags AtclauseOrder

JavadocTagContinuationIndentation

NonEmptyAtclauseDescription
config
config
config
test
7.2 The summary fragment SummaryJavadoc config
test
7.3 Where Javadoc is used MissingJavadocType

MissingJavadocMethod

JavadocMethod
config
config
config
test
7.3.1 Exception: self-explanatory members MissingJavadocMethod

JavadocMethod

"protected" methods are not detected for missing javadoc, it will be addressed at: #15434

Optional javadoc for "simple, obvious" members is not fully supported, it will be addressed at: #15414
config
config
test
7.3.2 Exception: overrides MissingJavadocMethod
Overrides are checked by presence of "@Override" annotation on method.

JavadocMethod
config
config
test
7.3.4 Non-required Javadoc InvalidJavadocPosition config
test

Severity Level

To adjust the default severity level for violations using Checkstyle's Google style configuration, set the following system property:

org.checkstyle.google.severity

For detailed guidance on severity levels, refer to the Severity Level. To configure this property, see the instructions for the CLI's -p option , or use the properties parameter in Ant, or set the Java system property before running Checkstyle.

Suppressions

It is possible to suppress some violations by embeded filters SuppressionFilter, SuppressionXpathFilter, SuppressWithNearbyCommentFilter, SuppressionCommentFilter and SuppressWarningsFilter.

Location of config file for SuppressionFilter can be defined by system property org.checkstyle.google.suppressionfilter.config (default value is checkstyle-suppressions.xml).

Location of config file for SuppressionXpathFilter can be defined by system property org.checkstyle.google.suppressionxpathfilter.config (default value is checkstyle-xpath-suppressions.xml).

To suppress a check in the next line of code using SuppressWithNearbyCommentFilterprecede the line of code with // CHECKSTYLE.SUPPRESS: NameOfTheCheck (replace NameOfTheCheck with the actual check to be suppressed).

To suppress a check on a block of code using SuppressionCommentFilter add // CHECKSTYLE.OFF: NameOfTheCheck before the beginning of the code block and // CHECKSTYLE.ON: NameOfTheCheck after the end of the code block (replace NameOfTheCheck with the actual check to be suppressed).

To suppress a check using SuppressWarningsFilter use Java's@SuppressWarnings({"checkstyle:name_of_the_check", ...}) annotation. Each value passed in the array parameter must meet the format checkstyle:name_of_the_check where the checkstyle: is optional and name_of_the_check is the actual name of check to be suppressed in lowercase format.

For more details please review exact configuration of Filters in google_checks.xml: SuppressionFilter, SuppressionXpathFilter SuppressWithNearbyCommentFilter, SuppressionCommentFilter, SuppressWarningsFilter,