Skip to content

Commit c6abf88

Browse files
authored
Sync godoc, README, cli doc (#34)
1 parent abed129 commit c6abf88

File tree

2 files changed

+60
-34
lines changed

2 files changed

+60
-34
lines changed

README.md

+21-16
Original file line numberDiff line numberDiff line change
@@ -160,35 +160,40 @@ $ go get github.com/uudashr/gocognit/cmd/gocognit
160160
```
161161
$ gocognit
162162
Calculate cognitive complexities of Go functions.
163+
163164
Usage:
164165
165-
gocognit [flags] <Go file or directory> ...
166+
gocognit [<flag> ...] <Go file or directory> ...
166167
167168
Flags:
168169
169-
-over N show functions with complexity > N only and
170-
return exit code 1 if the set is non-empty
171-
-top N show the top N most complex functions only
172-
-avg show the average complexity over all functions,
173-
not depending on whether -over or -top are set
174-
-json encode the output as JSON
175-
-f format string the format to use (default "{{.PkgName}}.{{.FuncName}}:{{.Complexity}}:{{.Pos}}")
176-
-ignore expr ignore files matching the given regexp
170+
-over N show functions with complexity > N only
171+
and return exit code 1 if the output is non-empty
172+
-top N show the top N most complex functions only
173+
-avg show the average complexity over all functions,
174+
not depending on whether -over or -top are set
175+
-json encode the output as JSON
176+
-f format string the format to use
177+
(default "{{.PkgName}}.{{.FuncName}}:{{.Complexity}}:{{.Pos}}")
177178
178179
The (default) output fields for each line are:
179180
180-
{{.Complexity}} {{.PkgName}} {{.FuncName}} {{.Pos}}
181+
<complexity> <package> <function> <file:row:column>
182+
183+
The (default) output fields for each line are:
184+
185+
{{.Complexity}} {{.PkgName}} {{.FuncName}} {{.Pos}}
181186
182187
or equal to <complexity> <package> <function> <file:row:column>
183188
184189
The struct being passed to the template is:
185190
186-
type Stat struct {
187-
PkgName string
188-
FuncName string
189-
Complexity int
190-
Pos token.Position
191-
}
191+
type Stat struct {
192+
PkgName string
193+
FuncName string
194+
Complexity int
195+
Pos token.Position
196+
}
192197
```
193198

194199
Examples:

cmd/gocognit/main.go

+39-18
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,23 @@
1414
// -f format string the format to use (default "{{.PkgName}}.{{.FuncName}}:{{.Complexity}}:{{.Pos}}")
1515
//
1616
// 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+
// }
1834
package main
1935

2036
import (
@@ -36,35 +52,40 @@ import (
3652
)
3753

3854
const usageDoc = `Calculate cognitive complexities of Go functions.
55+
3956
Usage:
4057
41-
gocognit [flags] <Go file or directory> ...
58+
gocognit [<flag> ...] <Go file or directory> ...
4259
4360
Flags:
4461
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>
5374
5475
The (default) output fields for each line are:
5576
56-
{{.Complexity}} {{.PkgName}} {{.FuncName}} {{.Pos}}
57-
77+
{{.Complexity}} {{.PkgName}} {{.FuncName}} {{.Pos}}
78+
5879
or equal to <complexity> <package> <function> <file:row:column>
5980
6081
The struct being passed to the template is:
6182
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+
}
6889
`
6990

7091
const (

0 commit comments

Comments
 (0)