Skip to content

Commit 9c2d25c

Browse files
authored
docs: clean (#996)
1 parent 8fe6c06 commit 9c2d25c

File tree

1 file changed

+46
-42
lines changed

1 file changed

+46
-42
lines changed

RULES_DESCRIPTIONS.md

+46-42
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ Example:
135135
[rule.banned-characters]
136136
arguments = ["Ω","Σ","σ"]
137137
```
138+
138139
## bare-return
139140

140141
_Description_: Warns on bare (a.k.a. naked) returns
@@ -175,6 +176,7 @@ Example:
175176
[rule.cognitive-complexity]
176177
arguments = [7]
177178
```
179+
178180
## comment-spacings
179181

180182
_Description_: Spots comments of the form:
@@ -195,6 +197,7 @@ Example:
195197
[rule.comment-spacings]
196198
arguments = ["mypragma:", "+optional"]
197199
```
200+
198201
## comments-density
199202

200203
_Description_: Spots files not respecting a minimum value for the [_comments lines density_](https://docs.sonarsource.com/sonarqube/latest/user-guide/metric-definitions/) metric = _comment lines / (lines of code + comment lines) * 100_
@@ -259,6 +262,7 @@ Example:
259262
[rule.cyclomatic]
260263
arguments = [3]
261264
```
265+
262266
## datarace
263267

264268
_Description_: This rule spots potential dataraces caused by go-routines capturing (by-reference) particular identifiers of the function from which go-routines are created. The rule is able to spot two of such cases: go-routines capturing named return values, and capturing `for-range` values.
@@ -310,7 +314,6 @@ Example:
310314
arguments = [{ allowedPackages = ["github.com/onsi/ginkgo/v2","github.com/onsi/gomega"] }]
311315
```
312316

313-
314317
## duplicated-imports
315318

316319
_Description_: It is possible to unintentionally import the same package twice. This rule looks for packages that are imported two or more times.
@@ -361,32 +364,6 @@ _Description_: Sometimes `gofmt` is not enough to enforce a common formatting of
361364

362365
_Configuration_: N/A
363366

364-
## error-naming
365-
366-
_Description_: By convention, for the sake of readability, variables of type `error` must be named with the prefix `err`.
367-
368-
_Configuration_: N/A
369-
370-
## error-return
371-
372-
_Description_: By convention, for the sake of readability, the errors should be last in the list of returned values by a function.
373-
374-
_Configuration_: N/A
375-
376-
## error-strings
377-
378-
_Description_: By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline.
379-
380-
More information [here](https://github.com/golang/go/wiki/CodeReviewComments#error-strings)
381-
382-
_Configuration_: N/A
383-
384-
## errorf
385-
386-
_Description_: It is possible to get a simpler program by replacing `errors.New(fmt.Sprintf())` with `fmt.Errorf()`. This rule spots that kind of simplification opportunities.
387-
388-
_Configuration_: N/A
389-
390367
## enforce-map-style
391368

392369
_Description_: This rule enforces consistent usage of `make(map[type]type)` or `map[type]type{}` for map initialization. It does not affect `make(map[type]type, size)` constructions as well as `map[type]type{k1: v1}`.
@@ -458,6 +435,32 @@ Example:
458435
arguments = ["make"]
459436
```
460437

438+
## error-naming
439+
440+
_Description_: By convention, for the sake of readability, variables of type `error` must be named with the prefix `err`.
441+
442+
_Configuration_: N/A
443+
444+
## error-return
445+
446+
_Description_: By convention, for the sake of readability, the errors should be last in the list of returned values by a function.
447+
448+
_Configuration_: N/A
449+
450+
## error-strings
451+
452+
_Description_: By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline.
453+
454+
More information [here](https://github.com/golang/go/wiki/CodeReviewComments#error-strings)
455+
456+
_Configuration_: N/A
457+
458+
## errorf
459+
460+
_Description_: It is possible to get a simpler program by replacing `errors.New(fmt.Sprintf())` with `fmt.Errorf()`. This rule spots that kind of simplification opportunities.
461+
462+
_Configuration_: N/A
463+
461464
## exported
462465

463466
_Description_: Exported function and methods should have comments. This warns on undocumented exported functions and methods.
@@ -500,32 +503,32 @@ This rule warns on boolean parameters that create a control coupling.
500503

501504
_Configuration_: N/A
502505

503-
## function-result-limit
506+
## function-length
504507

505-
_Description_: Functions returning too many results can be hard to understand/use.
508+
_Description_: Functions too long (with many statements and/or lines) can be hard to understand.
506509

507-
_Configuration_: (int) the maximum allowed return values
510+
_Configuration_: (int,int) the maximum allowed statements and lines. Must be non-negative integers. Set to 0 to disable the check
508511

509512
Example:
510513

511514
```toml
512-
[rule.function-result-limit]
513-
arguments = [3]
515+
[rule.function-length]
516+
arguments = [10, 0]
514517
```
518+
Will check for functions exceeding 10 statements and will not check the number of lines of functions
515519

516-
## function-length
520+
## function-result-limit
517521

518-
_Description_: Functions too long (with many statements and/or lines) can be hard to understand.
522+
_Description_: Functions returning too many results can be hard to understand/use.
519523

520-
_Configuration_: (int,int) the maximum allowed statements and lines. Must be non-negative integers. Set to 0 to disable the check
524+
_Configuration_: (int) the maximum allowed return values
521525

522526
Example:
523527

524528
```toml
525-
[rule.function-length]
526-
arguments = [10, 0]
529+
[rule.function-result-limit]
530+
arguments = [3]
527531
```
528-
Will check for functions exceeding 10 statements and will not check the number of lines of functions
529532

530533
## get-return
531534

@@ -644,7 +647,7 @@ _Configuration_: (int) maximum accepted nesting level of control structures (def
644647
Example:
645648

646649
```toml
647-
[max-control-nesting]
650+
[rule.max-control-nesting]
648651
arguments = [3]
649652
```
650653

@@ -695,7 +698,9 @@ Example:
695698
```go
696699
if isGenerated(content) && !config.IgnoreGeneratedHeader {
697700
```
701+
698702
Swap left and right side :
703+
699704
```go
700705
if !config.IgnoreGeneratedHeader && isGenerated(content) {
701706
```
@@ -869,9 +874,10 @@ _Configuration_: function names regexp patterns to ignore
869874
Example:
870875
871876
```toml
872-
[unhandled-error]
877+
[rule.unhandled-error]
873878
arguments = ["os\.(Create|WriteFile|Chmod)", "fmt\.Print", "myFunction", "net\..*", "bytes\.Buffer\.Write"]
874879
```
880+
875881
## unnecessary-stmt
876882
877883
_Description_: This rule suggests to remove redundant statements like a `break` at the end of a case block, for improving the code's readability.
@@ -973,5 +979,3 @@ _Description_: Function parameters that are passed by value, are in fact a copy
973979
This rule warns when a `sync.WaitGroup` expected as a by-value parameter in a function or method.
974980
975981
_Configuration_: N/A
976-
977-

0 commit comments

Comments
 (0)