Chap | Standard | Rule name | Description | Fix | Tests | Config | FixMe |
---|---|---|---|---|---|---|---|
1 | 1.3 | PACKAGE_NAME_MISSING | Check: warns if package name is missing in a file Fix: automatically adds package directive with the name that starts from the domain name (in example - com.huawei) and contains the real directory |
yes | PackageNamingWarnTest missing package name (check)PackageNamingFixTest missing company name (fix) |
no | Domain name should not be hardcoded. It should be moved to extra configuration.Recursively fix all imports in project.Fix the directory where the code is stored.Make this check isolated from domain name addition |
1 | 1.3 | PACKAGE_NAME_INCORRECT_CASE | Check: warns if package name is in incorrect (non-lower) case Fix: automatically update the case in package name |
yes | PackageNamingWarnTest package name should be in a lower case (check)PackageNamingFixTest incorrect case of package name (fix) |
no | Recursively update all imports in the project. |
1 | 1.3 | PACKAGE_NAME_INCORRECT_PREFIX | Check: warns if package name does not start with the company's domain Fix: automatically update the prefix in the package name |
yes | PackageNamingWarnTest package name should start from domain namePackageNamingFixTest fixing incorrect domain name (fix) |
no | Fix the directory where the code is stored.Recursively update all imports in the project.Domain name should not be hardcoded. It should be moved to extra configuration. |
1 | 1.3 | PACKAGE_NAME_INCORRECT_SYMBOLS | Check: warns if package name has incorrect symbols like underscore or non-ASCII letters/digits.Exception: underscores that are used for differentiating of keywords in a name. Fix: no but will be |
no | PackageNamingWarnTest underscore exceptions - incorrect underscore case incorrect symbol in package name underscore exceptions - positive case - keyword |
no | Add autofix for at least converting underscore to a dot or replacing itFix the directory where the code is stored.Cover autofix with tests |
1 | 1.3 | PACKAGE_NAME_INCORRECT_PATH | Check: warns if the path for a file does not match with a package name Fix: replacing incorrect package name with the name constructed from a path to the file. |
yes | PackageNamingWarnTest missing package name (check) package name should be in a lower case (check) package name should start from domain name (check) underscore exceptions - incorrect underscore case incorrect symbol in package name underscore exceptions - positive case - keyword regression - incorrect warning on file under test directory PackagePathFixTest fixing package name that differs from a path (fix) fix missing package name with a proper location (fix) fixing package name that differs from a path without domain (fix) fix missing package name with a proper location without domain (fix) |
no | Make this check isolated from domain name creationRecursively update all imports in the project.Fix the directory where the code is stored.Add test mechanism to test checker |
1 | 1.3 | INCORRECT_PACKAGE_SEPARATOR | Check: warns if underscore is incorrectly used to split package naming Fix: fixing all nodes in AST and the package name to remove all underscores |
no | PackageNamingFixTest incorrect usage of package separator (fix) |
no | Recursively update usages of this class in the project |
1 | 1.4 | CLASS_NAME_INCORRECT | Check: warns if the Class/Enum/Interface name does not match Pascal case ("([A-Z][a-z0-9]+)+") Fix: fixing the case: if the it is some fixed case (like snake/camel) - with word saving. If not - will restore PascalCase as is. |
yes | IdentifierNamingWarnTest check class name (check) check identifiers case format (check - negative)IdentifierNamingFixTest incorrect class name (fix) |
no | Recursively update usages of this class in the projectCheck and decide the better way on converting identifier to PascalCaseNeed to add checks using natural language processing to check that class name contains only nouns |
1 | 1.2 | OBJECT_NAME_INCORRECT | Check: warns if the object does not match Pascal case ("([A-Z][a-z0-9]+)+") Fix: fixing the case in the same way as for classes |
yes | IdentifierNamingWarnTest check case for object (check - negative) IdentifierNamingFixTest incorrect object name (fix) |
no | Recursively update usages of this class in the project |
1 | 1.2 | VARIABLE_NAME_INCORRECT_FORMAT | Check: warns if the name of variable is not in lowerCamelCase or contains non-ASCII letters Fix: fixing the case format to lowerCamelCase |
IdentifierNamingWarnTest check identifiers case format (check - negative) |
no | - | |
1 | 1.2 | BACKTICKS_PROHIBITED | Check: warns if backticks (``) are used in the identifier name, except the case when it is test method (marked with @Test annotation) | no | IdentifierNamingWarnTest | no | - |
1 | 1.7 | VARIABLE_NAME_INCORRECT | Check: warns if variable contains one single letter, only exceptions are fixed names that used in industry like {i, j} Fix: no fix as we are not able to imagine good name by machine |
no | IdentifierNamingWarnTest check identifiers case format (check - negative) |
no | Recursively update usages of this class in the projectMake exceptions configurable |
1 | 1.6 | CONSTANT_UPPERCASE | Check: warns if CONSTANT (treated as const val from companion object or class level) is in non UPPER_SNAKE_CASE Fix: name is changed to UPPER_SNAKE_CASE |
yes | IdentifierNamingWarnTest check identifiers case format (check - negative) |
no | Recursively update usages of this identifier in the project |
1 | 1.5 | VARIABLE_HAS_PREFIX | Check: warns if variable has prefix (like mVariable or M_VARIABLE), generally it is a bad code style (Android - is the only exception Fix: no fix as we are not able to imagine good name by machine |
no | IdentifierNamingWarnTest checking that there should be no prefixes in variable name |
no | may be we can fix it, but I do not see any sense for it |
1 | 1.2 | IDENTIFIER_LENGTH | Check: identifier length should be in range [2,64] except names that used in industry like {i, j} and 'e' for catching exceptions. Fix: no fix as we are not able to imagine good name by machine |
no | IdentifierNamingWarnTest check variable length (check - negative) regression - function argument type exception case for identifier naming in catch statements exception case for identifier naming in catch statements with catch body exception case for identifier naming - catching exception with type e |
no | May be make this rule configurable (length) |
1 | 1.4 | ENUM_VALUE | Check: warns if enum value is in non UPPER_SNAKE_CASE Fix: automatically converting case to UPPER_SNAKE_CASE |
yes | IdentifierNamingWarnTest check case for enum values (check - negative)IdentifierNamingFixTest incorrect enum values case (fix) |
no | Recursively update usages of this identifier in the project |
1 | 1.2 | GENERIC_NAME | Check: warns if generic name contains more than 1 letter (capital). It can be followed by numbers, example: T12, T Fix: |
yes | IdentifierNamingWarnTest generic class - single capital letter, can be followed by a number (check - negative1) generic class - single capital letter, can be followed by a number (check - negative2) |
no | Recursively update usages of this identifier in the project |
1 | 1.5 | FUNCTION_NAME_INCORRECT_CASE | Check: function/method name should be in lowerCamelCase: Fix: |
yes | MethodNamingWarnTest method name incorrect, part 1 method name incorrect, part 2 method name incorrect, part 3 method name incorrect, part 4 method name incorrect, part 5 |
no | Recursively update usages of this function in the project |
1 | 1.5 | FUNCTION_BOOLEAN_PREFIX | Check: functions/methods that return boolean should have special prefix like "is/should/e.t.c" Fix: |
yes | MethodNamingWarnTest boolean method name incorrect IdentifierNamingWarnTest FUNCTION_BOOLEAN_PREFIX - positive example FUNCTION_BOOLEAN_PREFIX - negative example |
no | Recursively update usages of this function in the projectAggressive fix - what if new name will not be valid |
1 | 1.2 | FILE_NAME_INCORRECT | Check: warns if file name does not have extension .kt/.kts Fix: no |
no | ? | no | Extensions should be configurableIt can be aggressively autofixed |
1 | 1.2 | FILE_NAME_MATCH_CLASS | Check: warns Fix: no |
no | ? | no | Probably it can be autofixed, but it will be aggressive fix |
1 | 1.2 | EXCEPTION_SUFFIX | Check: warns if class that extends any Exception class does not have Exception suffix Fix: Adding suffix "Exception" to a class name |
yes | IdentifierNamingWarnTest check exception case and suffix (with type call entry) - negative check exception case and suffix (only parent name inheritance) - negative |
no | Need to add tests for this |
2 | 2.1 | MISSING_KDOC_TOP_LEVEL | Check: warns on file level internal or public class or function has missing KDoc Fix: no |
no | KdocWarnTest all public classes should be documented with KDoc all internal classes should be documented with KDoc all internal and public functions on top-level should be documented with Kdoc all internal and public functions on top-level should be documented with Kdoc (positive case) positive Kdoc case with private class |
no | Support extension for setters/gettersSupport extension for method "override" |
2 | 2.1 | MISSING_KDOC_CLASS_ELEMENTS | Check: warns if accessible internal elements (protected, public, internal) in a class are not documented Fix: no |
no | KdocWarnTest Kdoc should present for each class element Kdoc should present for each class element (positive) |
no | May be need to add exception cases for setters and getters. There is no sense in adding KDoc to them. |
2 | 2.1 | MISSING_KDOC_ON_FUNCTION | Check: warns if accessible function doesn't have KDoc Fix: adds KDoc template if it is not empty |
yes | - | - | |
2 | 2.2 | KDOC_WITHOUT_PARAM_TAG | Check: warns if accessible method has parameters and they are not documented in KDoc Fix: If accessible method has no KDoc, KDoc template is added |
yes | KdocSignatureTest Accessible methods with parameters, return type and throws should have proper KDoc (positive example) Warning should not be triggered for private functions Empty parameter list should not trigger warning about @param All methods with parameters should have @param KDoc for each parameter Rule should suggest KDoc template for missing KDocs |
no | Should also make separate fix, even if there is already some Kdoc in place |
2 | 2.2 | KDOC_WITHOUT_RETURN_TAG | Check: warns if accessible method has explicit return type they it is not documented in KDoc Fix: If accessible method has no KDoc, KDoc template is added |
yes | KdocSignatureTest All methods with explicit return type excluding Unit should have @return KDoc |
Should also make separate fix, even if there is already some Kdoc in place | |
2 | 2.2 | KDOC_WITHOUT_THROWS_TAG | Check: warns if accessible method has throw keyword and it is not documented in KDoc Fix: If accessible method has no KDoc, KDoc template is added |
yes | KdocSignatureTest All methods with throw in method body should have @throws KDoc, throw in comments is ignored |
Should also make separate fix, even if there is already some Kdoc in place | |
2 | 2.3 | BLANK_LINE_AFTER_KDOC | Check: warns if Kdoc is incorrectly separated with newlines Fix: removing incorrect newlines between Kdoc and it's declaration |
yes | KdocFormattingTest There should be no blank line between kdoc and it's declaration codeKdocFormattingFixTest There should be no blank line between kdoc and it's declaration code |
- | |
2 | 2.3 | KDOC_EMPTY_KDOC | Check: warns if KDoc is empty Fix: no |
no | KdocFormattingTest empty KDocs are not allowed - example with empty KDOC_SECTION empty KDocs are not allowed - example with no KDOC_SECTION empty KDocs are not allowed - without bound identifier empty KDocs are not allowed - with anonymous entity |
- | |
2 | 2.3 | KDOC_WRONG_SPACES_AFTER_TAG | Check: warns if there is more than one space after KDoc tag Fix: removes redundant spaces |
yes | KdocFormattingTest KDocs should contain only one white space between tag and its content (positive example) KDocs should contain only one white space between tag and its contentKdocFormattingFixTest There should be exactly one white space after tag name |
||
2 | 2.3 | KDOC_WRONG_TAGS_ORDER | Check: warns if basic KDoc tags are not oredered properly Fix: reorders them @param , @return , @throws |
yes | KdocFormattingTest tags should be ordered in KDocs (positive example) tags should be ordered in KDocsKdocFormattingFixTest Tags should be ordered in KDocs |
Ensure basic tags are at the end of KDoc | |
2 | 2.3 | KDOC_NEWLINES_BEFORE_BASIC_TAGS | Check: warns if block of tags @param, @return, @throws is not separated from previous part of KDoc by exactly one empty line Fix: adds empty line or removes redundant |
yes | KdocFormattingTest basic tags block shouldn't have empty line before if there is no other KDoc content basic tags block should have empty line before if there is other KDoc content |
- | |
2 | 2.3 | KDOC_NO_NEWLINES_BETWEEN_BASIC_TAGS | Check: if there is newline of empty KDoc line (with leading asterisk) between @param , @return , @throws tagsFix: removes line |
yes | KdocFormattingTest newlines are not allowed between basic tagsKdocFormattingFixTest basic tags should not have empty lines between |
||
2 | 2.3 | KDOC_NO_NEWLINE_AFTER_SPECIAL_TAG | Check: warns if special tags @apiNote , @implNote , @implSpec don't have exactly one empty line afterFix: removes redundant lines or adds one |
yes | KdocFormattingTest Special tags should have exactly one newline after them (positive example) Special tags should have exactly one newline after them (no line) Special tags should have exactly one newline after them (many lines)KdocFormattingFixTest Special tags should have newline after them |
Handle empty lines without leading asterisk | |
2 | 2.3 | KDOC_NO_EMPTY_TAG | Check: warns if KDoc tags have empty content | no | KdocFormattingTestKdoc tags should not have empty content | ||
2 | 2.3 | KDOC_NO_DEPRECATED_TAG | Check: warns if @deprecated is used in KDocFix: adds @Deprecated annotation with message, removes tag |
yes | KdocFormattingTest@deprecated tag is not allowedKdocFormattingFixTest@deprecated tag should be substituted with annotation |
Annotation's replaceWith field can be filled too |
|
2 | 2.4 | HEADER_WRONG_FORMAT | Checks: warns if there is no newline after header KDoc Fix: adds newline |
yes | HeaderCommentRuleTest file header comment (positive example) header KDoc should have newline after itHeaderCommentRuleFixTest new line should be inserted after header KDoc |
Check if header is on the very top of file. It's hard to determine when it's not. | |
2 | 2.4 | HEADER_MISSING_OR_WRONG_COPYRIGHT | Checks: copyright exists on top of file and is properly formatted (as a block comment) Fix: adds copyright if it is missing and required |
yes | HeaderCommentRuleTest copyright should not be placed inside KDoc copyright should not be placed inside single line commentHeaderCommentRuleFixTest if no copyright is present and mandatoryCopyright=true, it is added |
mandatoryCopyright | Allow setting copyright patterns via configuration |
2 | 2.4 | HEADER_CONTAINS_DATE_OR_AUTHOR | Check: warns if header KDoc contains @author tag |
no | HeaderCommentRuleTest@author tag is not allowed in header comment |
Detect author by other patterns (e.g. 'created by' etc.)Detect creation date (no standard tag even in javadoc) | |
2 | 2.4 | HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE | Check: warns if file with zero or >1 classes doesn't have header KDoc | no | HeaderCommentRuleTest file with zero classes should have header KDoc file with multiple classes should have header KDoc |
||
2 | 2.7 | COMMENTED_OUT_CODE | Check: warns if commented code is detected (when un-commented, can be parsed) | no | CommentedCodeTest Should warn if commented out import or package directive is detected (single line comments) Should warn if commented out imports are detected (block comments) Should warn if commented out code is detected (block comments) Should warn if commented out code is detected (single line comments) Should warn if commented out function is detected (single line comments) Should warn if commented out function is detected (single line comments with surrounding text) Should warn if commented out function is detected (block comment) Should warn if detects commented out code (example with indents) Should warn if detects commented out code (example with IDEA style indents) |
Offset is lost when joined EOL comments are split again | |
2 | 2.4 | HEADER_NOT_BEFORE_PACKAGE | Check: warns if header KDoc if file is located not before package directive Fix: moves this KDoc |
yes | HeaderCommentRuleTestheader KDoc should be placed before package and imports | ||
3 | 3.1 | FILE_IS_TOO_LONG | Check: warns if file has too many lines Fix: no |
no | FileSizeWarnTest | maxSize ignoreFolders |
- |
3 | 3.2 | FILE_CONTAINS_ONLY_COMMENTS | Check: warns if file contains only comments, imports and package directive. | no | FileStructureRuleTest should warn if file contains only comments |
- | - |
3 | 3.2 | FILE_INCORRECT_BLOCKS_ORDER | Check: warns if general order of code parts is wrong. Fix: rearranges them. |
yes | FileStructureRuleTest should warn if file annotations are not immediately before package directive |
- | handle other elements that could be present before package directive (other comments) |
3 | 3.2 | FILE_NO_BLANK_LINE_BETWEEN_BLOCKS | Check: warns if there is not exactly one blank line between code parts. Fix: leaves single empty line |
yes | FileStructureRuleTest should warn if blank lines are wrong between code blocks |
- | - |
3 | 3.2 | FILE_UNORDERED_IMPORTS | Check: warns if imports are not sorted alphabetically or contain empty lines among them Fix: reorders imports. |
yes | FileStructureRuleTest should warn if imports are not sorted alphabetically |
- | - |
3 | 3.2 | FILE_WILDCARD_IMPORTS | Check: warns if wildcard imports are used. | no | FileStructureRuleTest should warn if wildcard imports are used |
- | - |
3 | 3.3 | NO_BRACES_IN_CONDITIONALS_AND_LOOPS | Check: warns if braces are not used in if, else, when, for, do, and while statements. Exception: single line if statement. Fix: adds missing braces. |
yes | ? | - | - |
3 | 3.2 | WRONG_ORDER_IN_CLASS_LIKE_STRUCTURES | Check: warns if the declaration part of a class-like code structures (class/interface/etc.) is not in the proper order. Fix: restores order according to code style guide. |
yes | ClassLikeStructuresOrderRuleWarnTest should check order of declarations in classes - positive example should warn if loggers are not on top |
- | - |
3 | 3.2 | BLANK_LINE_BETWEEN_PROPERTIES | Check: warns if properties with comments are not separated by a blank line, properties without comments are Fix: fixes number of blank lines |
yes | ClassLikeStructuresOrderRuleWarnTest comments and KDocs on properties should be prepended by newline - positive example should warn if comments and KDocs on properties are not prepended by newline |
- | - |
3 | 3.4 | BRACES_BLOCK_STRUCTURE_ERROR | Check: warns if non-empty code blocks with braces don't follow the K&R style (1TBS or OTBS style) | yes | BlockStructureBracesWarnTest check all expressions that contain block | openBraceNewline closeBraceNewline | - |
3 | 3.4 | EMPTY_BLOCK_STRUCTURE_ERROR | Check: warns if empty block exist or if it's style is incorrect | yes | EmptyBlockWarnTest check all expressions with empty block | allowEmptyBlocks styleEmptyBlockWithNewline | - |
3 | 3.4 | MORE_THAN_ONE_STATEMENT_PER_LINE | Check: warns if there is more than one statement per line | yes | SingleLineStatementsRuleWarnTest warn if there is more than one statements per one line | _ | - |
3 | 3.5 | WRONG_INDENTATION | Check: warns if indentation is incorrect Fix: corrects indentation. Basic cases are covered currently. |
yes | ? | extendedIndentOfParameters alignedParameters extendedIndentAfterOperators |
- |
3 | 3.5 | LONG_LINE | Check: warns if length doesn't exceed the specified length | no | LineLengthWarnTest check all lines in any expressions except URL in KDoc | lineLength | handle json method in KDoc |
3 | 3.6 | REDUNDANT_SEMICOLON | Check: warns if semicolons are used at the end of line. Fix: removes semicolon. |
yes | NewlinesRuleWarnTest * should forbid EOL semicolons NewlineRuleFixTest |
- | - |
3 | 3.6 | WRONG_NEWLINES | Check: warns if line breaks do not follow code style guid. Fix: fixes incorrect line breaks. |
yes | NewlinesRuleWarnTest NewlineRuleFixTest |
- | - |
3 | 3.8 | STRING_CONCATENATION | Check: warns if in a single line concatenation of strings is used | yes | StringConcatenationWarnTest | - | - |
3 | 3.6 | TOO_MANY_BLANK_LINES | Check: warns if blank lines are used placed incorrectly. Fix: removes redundant blank lines. |
yes | BlankLinesWarnTest BlankLinesFixTest |
- | |
3 | 3.7 | WRONG_WHITESPACE | Check: warns if usage of horizontal spaces violates code style guide. Fix: fixes incorrect whitespaces. |
yes | WhiteSpaceRuleWarnTest WhiteSpaceRuleFixTest |
- | - |