https://github.com/ngeor/checkstyle-rules
Rules for [checkstyle]. Share rules among projects.
https://github.com/ngeor/checkstyle-rules
checkstyle java
Last synced: 5 months ago
JSON representation
Rules for [checkstyle]. Share rules among projects.
- Host: GitHub
- URL: https://github.com/ngeor/checkstyle-rules
- Owner: ngeor
- License: mit
- Created: 2021-10-03T09:11:55.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-11-15T13:31:17.000Z (7 months ago)
- Last Synced: 2025-11-15T15:25:49.096Z (7 months ago)
- Topics: checkstyle, java
- Language: Java
- Homepage:
- Size: 114 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# checkstyle-rules
Rules for [checkstyle]. Share rules among projects.
[](https://central.sonatype.com/artifact/com.github.ngeor/checkstyle-rules)
[](https://github.com/ngeor/checkstyle-rules/actions/workflows/build.yml)
[](https://javadoc.io/doc/com.github.ngeor/checkstyle-rules)
## Overview
The rules are based on the default Sun checks, with some modifications.
## Usage
You can configure the maven-checkstyle-plugin in this way:
```xml
org.apache.maven.plugins
maven-checkstyle-plugin
3.1.2
validate
validate
check
com.puppycrawl.tools
checkstyle
8.45.1
com.github.ngeor
checkstyle-rules
4.9.3
com/github/ngeor/checkstyle.xml
true
```
## Rules in details
### [Annotations](https://checkstyle.sourceforge.io/config_annotation.html)
| Rule | Status |
| ---------------------- | -------- |
| AnnotationLocation | Not Used |
| AnnotationOnSameLine | Not Used |
| AnnotationUseStyle | Not Used |
| MissingDeprecated | Not Used |
| MissingOverride | Not Used |
| PackageAnnotation | Not Used |
| SuppressWarnings | Not Used |
| SuppressWarningsHolder | Used |
### [Block Checks](https://checkstyle.sourceforge.io/config_blocks.html)
| Rule | Status |
| ----------------- | -------- |
| AvoidNestedBlocks | Used |
| EmptyBlock | Used |
| EmptyCatchBlock | Not Used |
| LeftCurly | Used |
| NeedBraces | Used |
| RightCurly | Used |
### [Class Design](https://checkstyle.sourceforge.io/config_design.html)
| Rule | Status |
| --------------------------- | ---------- |
| DesignForExtension | _Disabled_ |
| FinalClass | Used |
| HideUtilityClassConstructor | Used |
| InnerTypeLast | Not Used |
| InterfaceIsType | Used |
| MutableException | Not Used |
| OneTopLevelClass | _Enabled_ |
| ThrowsCount | Not Used |
| VisibilityModifier | Used |
### [Coding](https://checkstyle.sourceforge.io/config_coding.html)
| Rule | Status |
| ---------------------------------------------- | ---------- |
| ArrayTrailingComma | Not Used |
| AvoidInlineConditionals | _Disabled_ |
| CovariantEquals | _Enabled_ |
| DeclarationOrder | _Enabled_ |
| DefaultComesLast | _Enabled_ |
| EmptyStatement | Used |
| EqualsAvoidNull | _Enabled_ |
| EqualsHashCode | Used |
| ExplicitInitialization | _Enabled_ |
| FallThrough | _Enabled_ |
| FinalLocalVariable | Not Used |
| HiddenField | _Altered_ |
| IllegalCatch | _Enabled_ |
| IllegalInstantiation | Used |
| IllegalThrows | _Enabled_ |
| IllegalToken | Not Used |
| IllegalTokenText | Not Used |
| IllegalType | _Enabled_ |
| InnerAssignment | Used |
| MagicNumber | _Altered_ |
| MissingCtor | Not Used |
| MissingSwitchDefault | Used |
| ModifiedControlVariable | _Enabled_ |
| MultipleStringLiterals | Not Used |
| MultipleVariableDeclarations | _Enabled_ |
| NestedForDepth | _Enabled_ |
| NestedIfDepth | _Enabled_ |
| NestedTryDepth | _Enabled_ |
| NoClone | _Enabled_ |
| NoFinalizer | _Enabled_ |
| OneStatementPerLine | _Enabled_ |
| OverloadMethodsDeclarationOrder | _Enabled_ |
| PackageDeclaration | _Enabled_ |
| ParameterAssignment | _Enabled_ |
| RequireThis | Not Used |
| ReturnCount | Not Used |
| SimplifyBooleanExpression | Used |
| SimplifyBooleanReturn | Used |
| StringLiteralEquality | _Enabled_ |
| SuperClone | Not Used |
| SuperFinalize | Not Used |
| UnnecessaryParentheses | _Enabled_ |
| UnnecessarySemicolonAfterTypeMemberDeclaration | Not Used |
| UnnecessarySemicolonInEnumeration | Not Used |
| UnnecessarySemicolonInTryWithResources | Not Used |
| VariableDeclarationUsageDistance | Not Used |
#### HiddenField
- ignoreConstructorParameter set to true
- ignoreSetter set to true
#### MagicNumber
Allows magic numbers in hash code, field declarations and annotations.
### [Headers](https://checkstyle.sourceforge.io/config_header.html)
| Rule | Status |
| ------------ | ---------- |
| Header | _Disabled_ |
| RegexpHeader | Not Used |
### [Imports](https://checkstyle.sourceforge.io/config_imports.html)
| Rule | Status |
| ----------------- | ---------- |
| AvoidStarImport | _Not Used_ |
| AvoidStaticImport | Not Used |
| CustomImportOrder | Not Used |
| IllegalImport | Used |
| ImportControl | Not Used |
| ImportOrder | _Altered_ |
| RedundantImport | Used |
| UnusedImports | Used |
#### ImportOrder
Matches [Palantir](https://github.com/palantir/palantir-java-format) style:
- All static imports in one group, alphabetically sorted
- One line separator
- All non-static imports in one group, alphabetically sorted
### [Javadoc Comments](https://checkstyle.sourceforge.io/config_javadoc.html)
| Rule | Status |
| --------------------------------- | ----------------------------- |
| AtclauseOrder | Not Used |
| InvalidJavadocPosition | Not Used |
| JavadocBlockTagLocation | Not Used |
| JavadocMethod | Not Used |
| JavadocPackage | Not Used |
| JavadocParagraph | Not Used |
| JavadocStyle | Used |
| JavadocTagContinuationIndentation | Not Used |
| JavadocType | Not Used |
| JavadocVariable | Not Used |
| MissingJavadocMethod | Not Used |
| MissingJavadocPackage | Not Used |
| MissingJavadocType | Not Used |
| NonEmptyAtclauseDescription | Not Used |
| SingleLineJavadoc | Not Used |
| SummaryJavadoc | Not Used |
| WriteTag | Not Used |
### [Metrics](https://checkstyle.sourceforge.io/config_metrics.html)
| Rule | Status |
| ---------------------------- | -------- |
| BooleanExpressionComplexity | Not Used |
| ClassDataAbstractionCoupling | Not Used |
| ClassFanOutComplexity | Not Used |
| CyclomaticComplexity | Not Used |
| JavaNCSS | Not Used |
| NPathComplexity | Not Used |
### [Miscellaneous](https://checkstyle.sourceforge.io/config_misc.html)
| Rule | Status |
| ----------------------------- | ---------- |
| ArrayTypeStyle | Used |
| AvoidEscapedUnicodeCharacters | Not Used |
| CommentsIndentation | _Enabled_ |
| DescendantToken | Not Used |
| FinalParameters | _Disabled_ |
| Indentation | _Enabled_ |
| NewlineAtEndOfFile | Used |
| OrderedProperties | Not Used |
| OuterTypeFilename | _Enabled_ |
| TodoComment | _Disabled_ |
| TrailingComment | Not Used |
| Translation | Used |
| UncommentedMain | Not Used |
| UniqueProperties | Not Used |
| UpperEll | Used |
### [Modifiers](https://checkstyle.sourceforge.io/config_modifier.html)
| Rule | Status |
| ------------------------------ | -------- |
| ClassMemberImpliedModifier | Not Used |
| InterfaceMemberImpliedModifier | Not Used |
| ModifierOrder | Used |
| RedundantModifier | Used |
### [Naming Conventions](https://checkstyle.sourceforge.io/config_naming.html)
| Rule | Status |
| -------------------------- | --------- |
| AbbreviationAsWordInName | Not Used |
| AbstractClassName | Not Used |
| CatchParameterName | Not Used |
| ClassTypeParameterName | Not Used |
| ConstantName | Used |
| InterfaceTypeParameterName | Not Used |
| LambdaParameterName | Not Used |
| LocalFinalVariableName | Used |
| LocalVariableName | Used |
| MemberName | Used |
| MethodName | _Altered_ |
| MethodTypeParameterName | Not Used |
| PackageName | _Altered_ |
| ParameterName | Used |
| StaticVariableName | Used |
| TypeName | Used |
#### MethodName
Using Google flavor to permit underscore in test method names:
`^[a-z][a-z0-9][a-zA-Z0-9_]*$"`
#### PackageName
Limited to lowercase letters and numbers: `^[a-z]+(\.[a-z][a-z0-9]*)*$`
### [Regexp](https://checkstyle.sourceforge.io/config_regexp.html)
| Rule | Status |
| -------------------- | --------- |
| Regexp | Not Used |
| RegexpMultiline | Not Used |
| RegexpOnFilename | Not Used |
| RegexpSingleline | _Altered_ |
| RegexpSinglelineJava | Not Used |
#### RegexSingleline
Verifies that lines do not have trailing spaces.
### [Size Violations](https://checkstyle.sourceforge.io/config_sizes.html)
| Rule | Status |
| ------------------------ | ------------------------------------- |
| AnonInnerLength | Not Used |
| ExecutableStatementCount | Not Used |
| FileLength | Used |
| LineLength | _Altered_ increased to 120 characters |
| MethodCount | Not Used |
| MethodLength | Used |
| OuterTypeNumber | Not Used |
| ParameterNumber | Used |
### [Whitespace](https://checkstyle.sourceforge.io/config_whitespace.html)
| Rule | Status |
| ---------------------- | --------- |
| EmptyForInitializerPad | Not Used |
| EmptyForIteratorPad | Used |
| EmptyLineSeparator | _Altered_ |
| FileTabCharacter | Used |
| GenericWhitespace | Used |
| MethodParamPad | Used |
| NoLineWrap | Not Used |
| NoWhitespaceAfter | Used |
| NoWhitespaceBefore | Used |
| OperatorWrap | Used |
| ParenPad | Used |
| SeparatorWrap | Not Used |
| SingleSpaceSeparator | Not Used |
| TypecastParenPad | Used |
| WhitespaceAfter | Used |
| WhitespaceAround | _Altered_ |
#### EmptyLineSeparator
- allowNoEmptyLineBetweenFields set to true
- allowMultipleEmptyLines set to false
#### WhitespaceAround
- allows empty constructor bodies
- allows empty methods
- allows empty class, interface and enum bodies
## Suppressions
It is possible to specify an
[XML file with suppressions](http://checkstyle.sourceforge.net/config_filters.html#SuppressionFilter).
The file is optional and it needs to be in `checkstyle/suppressions.xml`.
Example file to ignore magic numbers and multiple string literals in unit tests:
```xml
```
It is also possible to suppress violations using the `@SuppressWarnings`
annotation.
[checkstyle]: https://checkstyle.sourceforge.io/