signature

package module
v0.0.0-...-356d755 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 6 Imported by: 0

README

signature

pkg.go.dev

signature finds low readability functions.

package a

// func decls
func _(_, _, _, _, _ int)    {}         // OK
func _(_, _, _, _, _, _ int) {}         // want "too many params"
func _() (_, _, _ int)       { return } // OK
func _() (_, _, _, _ int)    { return } // want "too many results"

// func literals
func _() {
	_ = func(_, _, _, _, _ int) {}         // OK
	_ = func(_, _, _, _, _, _ int) {}      // want "too many params"
	_ = func() (_, _, _ int) { return }    // OK
	_ = func() (_, _, _, _ int) { return } // want "too many results"
}

Install

You can get signature by go install command (Go 1.16 and higher).

$ go install github.com/gostaticanalysis/signature/cmd/signature@latest

How to use

signature run with go vet as below when Go is 1.12 and higher.

$ go vet -vettool=$(which signature) ./...

signature accepts two options -params and -results. -params specifies max number of parameters and -results specifies max number of results. The default value of -params is 5 and -results is 3.

$ go vet -vettool=$(which signature) -signature.params 3 -signature.results 4 ./...

Analyze with golang.org/x/tools/go/analysis

You can use signature.Analyzer with unitchecker.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "signature",
	Doc:  doc,
	Run:  run,
	Requires: []*analysis.Analyzer{
		inspect.Analyzer,
	},
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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