## Documentation ¶

### Overview ¶

Package gocyclo calculates the cyclomatic complexities of functions and methods in Go source code.

### Index ¶

### Constants ¶

This section is empty.

### Variables ¶

This section is empty.

### Functions ¶

#### func Complexity ¶

Complexity calculates the cyclomatic complexity of a function. The 'fn' node is either a *ast.FuncDecl or a *ast.FuncLit.

### Types ¶

#### type Stat ¶

Stat holds the cyclomatic complexity of a function, along with its package and and function name and its position in the source code.

#### type Stats ¶

type Stats []Stat

Stats hold the cyclomatic complexities of many functions.

#### func Analyze ¶

Analyze calculates the cyclomatic complexities of the functions and methods in the Go source code files in the given paths. If a path is a directory all Go files under that directory are analyzed recursively. Files with paths matching the 'ignore' regular expressions are skipped. The 'ignore' parameter can be nil, meaning that no files are skipped.

#### func AnalyzeASTFile ¶ added in v0.3.0

AnalyzeASTFile calculates the cyclomatic complexities of the functions and methods in the abstract syntax tree (AST) of a parsed Go file and appends the results to the given Stats slice.

#### func (Stats) AverageComplexity ¶

AverageComplexity calculates the average cyclomatic complexity of the cyclomatic complexities in s.

#### func (Stats) SortAndFilter ¶

SortAndFilter sorts the cyclomatic complexities in s in descending order and returns a slice of s limited to the 'top' N entries with a cyclomatic complexity greater than 'over'. If 'top' is negative, i.e. -1, it does not limit the result. If 'over' is <= 0 it does not limit the result either, because a function has a base cyclomatic complexity of at least 1.

#### func (Stats) TotalComplexity ¶

TotalComplexity calculates the total sum of all cyclomatic complexities in s.