14
14
// -f format string the format to use (default "{{.PkgName}}.{{.FuncName}}:{{.Complexity}}:{{.Pos}}")
15
15
//
16
16
// The (default) output fields for each line are:
17
- // <complexity> <package> <function> <file:row:column>
17
+ //
18
+ // <complexity> <package> <function> <file:row:column>
19
+ //
20
+ // The (default) output fields for each line are:
21
+ //
22
+ // {{.Complexity}} {{.PkgName}} {{.FuncName}} {{.Pos}}
23
+ //
24
+ // or equal to <complexity> <package> <function> <file:row:column>
25
+ //
26
+ // The struct being passed to the template is:
27
+ //
28
+ // type Stat struct {
29
+ // PkgName string
30
+ // FuncName string
31
+ // Complexity int
32
+ // Pos token.Position
33
+ // }
18
34
package main
19
35
20
36
import (
@@ -36,35 +52,40 @@ import (
36
52
)
37
53
38
54
const usageDoc = `Calculate cognitive complexities of Go functions.
55
+
39
56
Usage:
40
57
41
- gocognit [flags ] <Go file or directory> ...
58
+ gocognit [<flag> ... ] <Go file or directory> ...
42
59
43
60
Flags:
44
61
45
- -over N show functions with complexity > N only and
46
- return exit code 1 if the set is non-empty
47
- -top N show the top N most complex functions only
48
- -avg show the average complexity over all functions,
49
- not depending on whether -over or -top are set
50
- -json encode the output as JSON
51
- -f format string the format to use (default "{{.PkgName}}.{{.FuncName}}:{{.Complexity}}:{{.Pos}}")
52
- -ignore expr ignore files matching the given regexp
62
+ -over N show functions with complexity > N only
63
+ and return exit code 1 if the output is non-empty
64
+ -top N show the top N most complex functions only
65
+ -avg show the average complexity over all functions,
66
+ not depending on whether -over or -top are set
67
+ -json encode the output as JSON
68
+ -f format string the format to use
69
+ (default "{{.PkgName}}.{{.FuncName}}:{{.Complexity}}:{{.Pos}}")
70
+
71
+ The (default) output fields for each line are:
72
+
73
+ <complexity> <package> <function> <file:row:column>
53
74
54
75
The (default) output fields for each line are:
55
76
56
- {{.Complexity}} {{.PkgName}} {{.FuncName}} {{.Pos}}
57
-
77
+ {{.Complexity}} {{.PkgName}} {{.FuncName}} {{.Pos}}
78
+
58
79
or equal to <complexity> <package> <function> <file:row:column>
59
80
60
81
The struct being passed to the template is:
61
82
62
- type Stat struct {
63
- PkgName string
64
- FuncName string
65
- Complexity int
66
- Pos token.Position
67
- }
83
+ type Stat struct {
84
+ PkgName string
85
+ FuncName string
86
+ Complexity int
87
+ Pos token.Position
88
+ }
68
89
`
69
90
70
91
const (
0 commit comments