diff --git a/README.md b/README.md index 77268ab..498c6b0 100644 --- a/README.md +++ b/README.md @@ -346,6 +346,7 @@ List of all available rules. The rules ported from `golint` are left unchanged a | [`bare-return`](./RULES_DESCRIPTIONS.md#bare-return) | n/a | Warns on bare returns | no | no | | [`unused-receiver`](./RULES_DESCRIPTIONS.md#unused-receiver) | n/a | Suggests to rename or remove unused method receivers | no | no | | [`unhandled-error`](./RULES_DESCRIPTIONS.md#unhandled-error) | []string | Warns on unhandled errors returned by funcion calls | no | yes | +| [`cognitive-complexity`](./RULES_DESCRIPTIONS.md#cognitive-complexity) | int | Sets restriction for maximum Cognitive complexity. | no | no | ## Configurable rules diff --git a/RULES_DESCRIPTIONS.md b/RULES_DESCRIPTIONS.md index 8121ac1..f833667 100644 --- a/RULES_DESCRIPTIONS.md +++ b/RULES_DESCRIPTIONS.md @@ -13,6 +13,7 @@ List of all available rules. - [call-to-gc](#call-to-gc) - [confusing-naming](#confusing-naming) - [confusing-results](#confusing-results) + - [cognitive-complexity](#cognitive-complexity) - [constant-logical-expr](#constant-logical-expr) - [context-as-argument](#context-as-argument) - [context-keys-type](#context-keys-type) @@ -122,6 +123,19 @@ The garbage collector can be configured through environment variables as describ _Configuration_: N/A +## cognitive-complexity + +_Description_: [Cognitive complexity](https://www.sonarsource.com/resources/white-papers/cognitive-complexity.html) is a measure of how hard code is to understand. Enforcing a maximum complexity per function helps to keep code readable and maintainable. + +_Configuration_: (int) the maximum function complexity + +Example: + +```toml +[rule.cognitive-complexity] + arguments =[7] +``` + ## confusing-naming _Description_: Methods or fields of `struct` that have names different only by capitalization could be confusing.