unused

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 16 Imported by: 156

Documentation

Overview

Package unused contains code for finding unused code.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &lint.Analyzer{
	Doc: &lint.Documentation{
		Title: "Unused code",
	},
	Analyzer: &analysis.Analyzer{
		Name:       "U1000",
		Doc:        "Unused code",
		Run:        run,
		Requires:   []*analysis.Analyzer{generated.Analyzer, directives.Analyzer},
		ResultType: reflect.TypeOf(Result{}),
	},
}
View Source
var Debug io.Writer
View Source
var DefaultOptions = Options{
	FieldWritesAreUses:     true,
	PostStatementsAreReads: false,
	ExportedIsUsed:         true,
	ExportedFieldsAreUsed:  true,
	ParametersAreUsed:      true,
	LocalVariablesAreUsed:  true,
	GeneratedIsUsed:        true,
}

Functions

This section is empty.

Types

type Node added in v0.4.0

type Node struct {
	// contains filtered or unexported fields
}

func Graph added in v0.4.0

func Graph(fset *token.FileSet,
	files []*ast.File,
	pkg *types.Package,
	info *types.Info,
	directives []lint.Directive,
	generated map[string]generated.Generator,
	opts Options,
) []Node

type NodeID added in v0.4.0

type NodeID uint64

OPT(dh): 32 bits would be plenty, but the Node struct would end up with padding, anyway.

type Object added in v0.4.0

type Object struct {
	Name      string
	ShortName string
	// OPT(dh): use an enum for the kind
	Kind            string
	Path            ObjectPath
	Position        token.Position
	DisplayPosition token.Position
}

type ObjectPath added in v0.4.0

type ObjectPath struct {
	PkgPath string
	ObjPath objectpath.Path
}

type Options added in v0.4.0

type Options struct {
	FieldWritesAreUses     bool
	PostStatementsAreReads bool
	ExportedIsUsed         bool
	ExportedFieldsAreUsed  bool
	ParametersAreUsed      bool
	LocalVariablesAreUsed  bool
	GeneratedIsUsed        bool
}

type Result

type Result struct {
	Used   []Object
	Unused []Object
	Quiet  []Object
}

TODO(dh): should we return a map instead of two slices?

type SerializedGraph added in v0.4.0

type SerializedGraph struct {
	// contains filtered or unexported fields
}

func (*SerializedGraph) Dot added in v0.4.0

func (g *SerializedGraph) Dot() string

Dot formats a graph in Graphviz dot format.

func (*SerializedGraph) Merge added in v0.4.0

func (g *SerializedGraph) Merge(nodes []Node)

func (*SerializedGraph) Results added in v0.4.0

func (g *SerializedGraph) Results() Result

Jump to

Keyboard shortcuts

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