lintcmd

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: MIT Imports: 35 Imported by: 4

Documentation

Overview

Package lintcmd implements the frontend of an analysis runner. It serves as the entry-point for the staticcheck command, and can also be used to implement custom linters that behave like staticcheck.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command added in v0.2.0

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

Command represents a linter command line tool.

func NewCommand added in v0.2.0

func NewCommand(name string) *Command

NewCommand returns a new Command.

func (*Command) AddAnalyzers added in v0.2.0

func (cmd *Command) AddAnalyzers(as ...*lint.Analyzer)

AddAnalyzers adds analyzers to the command. These are lint.Analyzer analyzers, which wrap analysis.Analyzer analyzers, bundling them with structured documentation.

To add analysis.Analyzer analyzers without providing structured documentation, use AddBareAnalyzers.

func (*Command) AddBareAnalyzers added in v0.2.0

func (cmd *Command) AddBareAnalyzers(as ...*analysis.Analyzer)

AddBareAnalyzers adds bare analyzers to the command.

func (*Command) FlagSet added in v0.2.0

func (cmd *Command) FlagSet() *flag.FlagSet

FlagSet returns the command's flag set. This can be used to add additional command line arguments.

func (*Command) ParseFlags added in v0.2.0

func (cmd *Command) ParseFlags(args []string)

ParseFlags parses command line flags. It must be called before calling Run. After calling ParseFlags, the values of flags can be accessed.

Example:

cmd.ParseFlags(os.Args[1:])

func (*Command) Run added in v0.2.0

func (cmd *Command) Run()

Run runs all registered analyzers and reports their findings. It always calls os.Exit and does not return.

func (*Command) SetVersion added in v0.2.0

func (cmd *Command) SetVersion(human, machine string)

SetVersion sets the command's version. It is divided into a human part and a machine part. For example, Staticcheck 2020.2.1 had the human version "2020.2.1" and the machine version "v0.1.1". If you only use Semver, you can set both parts to the same value.

Calling this method is optional. Both versions default to "devel", and we'll attempt to deduce more version information from the Go module.

Directories

Path Synopsis
Package runner implements a go/analysis runner.
Package runner implements a go/analysis runner.

Jump to

Keyboard shortcuts

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