Skip to content

Commit

Permalink
Reformat the doc (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
uudashr committed Sep 6, 2023
1 parent 6c6087f commit 4a90dac
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,32 @@ $ gocognit
Calculate cognitive complexities of Go functions.
Usage:
gocognit [flags] <Go file or directory> ...
gocognit [flags] <Go file or directory> ...
Flags:
-over N show functions with complexity > N only and
return exit code 1 if the output is non-empty
-top N show the top N most complex functions only
-avg show the average complexity over all functions,
not depending on whether -over or -top
-f format string the format to use (default "{{.PkgName}}.{{.FuncName}}:{{.Complexity}}:{{.Pos}}")
-over N show functions with complexity > N only and
return exit code 1 if the set is non-empty
-top N show the top N most complex functions only
-avg show the average complexity over all functions,
not depending on whether -over or -top are set
-json encode the output as JSON
-f format string the format to use (default "{{.PkgName}}.{{.FuncName}}:{{.Complexity}}:{{.Pos}}")
The (default) output fields for each line are:
<complexity> <package> <function> <file:row:column>
{{.Complexity}} {{.PkgName}} {{.FuncName}} {{.Pos}}
or equal to <complexity> <package> <function> <file:row:column>
The struct being passed to the template is:
type Stat struct {
PkgName string
FuncName string
Complexity int
Pos token.Position
}
```

Examples:
Expand Down
26 changes: 16 additions & 10 deletions cmd/gocognit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,24 @@ import (

const usageDoc = `Calculate cognitive complexities of Go functions.
Usage:
gocognit [flags] <Go file or directory> ...
gocognit [flags] <Go file or directory> ...
Flags:
-over N show functions with complexity > N only and
return exit code 1 if the set is non-empty
-top N show the top N most complex functions only
-avg show the average complexity over all functions,
not depending on whether -over or -top are set
-json encode the output as JSON
-f format string the format to use (default "{{.PkgName}}.{{.FuncName}}:{{.Complexity}}:{{.Pos}}")
-over N show functions with complexity > N only and
return exit code 1 if the set is non-empty
-top N show the top N most complex functions only
-avg show the average complexity over all functions,
not depending on whether -over or -top are set
-json encode the output as JSON
-f format string the format to use (default "{{.PkgName}}.{{.FuncName}}:{{.Complexity}}:{{.Pos}}")
The (default) output fields for each line are:
{{.Complexity}} {{.PkgName}} {{.FuncName}} {{.Pos}} or equal to
<complexity> <package> <function> <file:row:column>
{{.Complexity}} {{.PkgName}} {{.FuncName}} {{.Pos}}
or equal to <complexity> <package> <function> <file:row:column>
The struct being passed to the template is:
Expand Down

0 comments on commit 4a90dac

Please sign in to comment.