scopelint

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2019 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package scopelint privides a linter for scopes of variable in `for {}`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Package    *Package
	ASTFile    *ast.File
	FileSet    *token.FileSet
	Source     []byte
	Filename   string
	CommentMap ast.CommentMap
}

File represents a File being linted.

type Linter

type Linter struct{}

A Linter lints Go source code.

func (*Linter) Lint

func (l *Linter) Lint(filename string, src []byte) ([]Problem, error)

Lint lints src.

func (*Linter) LintFiles

func (l *Linter) LintFiles(files map[string][]byte) ([]Problem, error)

LintFiles lints a set of files of a single package. The argument is a map of filename to source.

type Node

type Node struct {
	File
	DangerObjects map[*ast.Object]int
	UnsafeObjects map[*ast.Object]int
	SkipFuncs     map[*ast.FuncLit]int
	Ignore        bool
}

Node represents a Node being linted.

func (*Node) Visit

func (n *Node) Visit(node ast.Node) ast.Visitor

Visit method is invoked for each node encountered by Walk. If the result visitor w is not nil, Walk visits each of the children of node with the visitor w, followed by a call of w.Visit(nil).

type Package

type Package struct {
	FileSet *token.FileSet
	Files   map[string]*File

	TypesPackage *types.Package
	TypesInfo    *types.Info

	Problems []Problem
}

Package represents a package being linted.

type Problem

type Problem struct {
	Position   token.Position // position in source file
	Text       string         // the prose that describes the problem
	Link       string         // (optional) the link to the style guide for the problem
	Confidence float64        // a value in (0,1] estimating the confidence in this problem's correctness
	LineText   string         // the source line
	Category   string         // a short name for the general category of the problem

	// If the problem has a suggested fix (the minority case),
	// ReplacementLine is a full replacement for the relevant line of the source file.
	ReplacementLine string

	Ignored bool // marks ignored issue by nolint directive
}

Problem represents a problem in some source code.

func (*Problem) String

func (p *Problem) String() string

Jump to

Keyboard shortcuts

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