util

package
v0.0.0-...-503c688 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Directives = &analysis.Analyzer{
	Name:             "directives",
	Doc:              "extracts linter directives",
	Run:              doDirectives,
	RunDespiteErrors: true,
	ResultType:       reflect.TypeOf([]Directive{}),
}

Directives is a fact that contains a list of directives.

Functions

func FindOffset

func FindOffset(fileText string, line, column int) int

FindOffset returns the offset of a given position in a file.

func FormatCode

func FormatCode(code string) string

FormatCode is to format code for nogo.

func MakeFakeLoaderPackageInfo

func MakeFakeLoaderPackageInfo(pass *analysis.Pass) *loader.PackageInfo

MakeFakeLoaderPackageInfo creates a fake loader.PackageInfo for a given package.

func ReadFile

func ReadFile(fset *token.FileSet, filename string) ([]byte, *token.File, error)

ReadFile reads a file and adds it to the FileSet so that we can report errors against it using lineStart.

func SkipAnalyzer

func SkipAnalyzer(analyzer *analysis.Analyzer)

SkipAnalyzer updates an analyzer from `staticcheck` and `golangci-linter` to make it work on nogo. They have "lint:ignore" or "nolint" to make the analyzer ignore the code.

Types

type Directive

type Directive struct {
	Command   skipType
	Linters   []string
	Directive *ast.Comment
	Node      ast.Node
}

Directive is a comment of the form '//lint:<command> [arguments...]' and `//nolint:<command>`. It represents instructions to the static analysis tool.

func ParseDirectives

func ParseDirectives(files []*ast.File, fset *token.FileSet) []Directive

ParseDirectives extracts all directives from a list of Go files.

Jump to

Keyboard shortcuts

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