gocognit

command
v0.0.0-...-c35c6a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

GoCognitive calculates the cognitive complexities of functions and methods in Go source code.

Usage:

gocognit [<flag> ...] <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 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>

The (default) output fields for each line are:

{{.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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL