check

package
v0.0.0-...-d046166 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImportOrderAutoFix

func ImportOrderAutoFix(fs *token.FileSet, f *ast.File) (*ast.File, error)

ImportOrderAutoFix returns ast.File node whose import was fixed from given node correctly.

func SortIssues

func SortIssues(issues []*Issue)

SortIssues sorts issues by file path and position.

Types

type Issue

type Issue struct {
	Pos     token.Position
	Msg     string
	Link    string
	Fixable bool
}

Issue holds an issue reported by the linter.

func Comments

func Comments(fs *token.FileSet, f *ast.File) []*Issue

Comments checks comments on unexported functions (if any) start with the function name. Golint examines only exported functions. This check is a complementary of it.

func Declarations

func Declarations(fs *token.FileSet, f *ast.File, fix bool) []*Issue

Declarations checks declarations of testing.Test structs.

func DropIgnoredIssues

func DropIgnoredIssues(issues []*Issue, fs *token.FileSet, f *ast.File) []*Issue

DropIgnoredIssues drops all issues that are on the same lines as NOLINT comments.

Specifically, an issue is dropped if its line number matches the starting line number of a comment group (see ast.CommentGroup) in f that contains "NOLINT".

Filtering is performed at this level rather than while walking the AST for several reasons:

  • We want to avoid making each check look for NOLINT itself.
  • We can't just skip nodes that are on the same lines as NOLINT comments, since some issues are reported with different line numbers than the position of the node from which they were reported. For example, the Declarations function inspects testing.Test composite literal nodes, but the line numbers used in its issues correspond to Desc fields that contain errors. We expect test authors to place a NOLINT comment at the end of the line containing the Desc field, not on the line containing the beginning of the testing.Test literal.

func EmptySlice

func EmptySlice(fs *token.FileSet, f *ast.File, fix bool) []*Issue

EmptySlice warns the invalid empty slice declaration.

func Exports

func Exports(fs *token.FileSet, f *ast.File) []*Issue

Exports checks that an entry file exports exactly one symbol, either a test main function or a gRPC service implementation type.

func ExternalJSON

func ExternalJSON(path string, in []byte) []*Issue

ExternalJSON checks if url in .external file has a date suffix or not.

func ForbiddenBundleImports

func ForbiddenBundleImports(fs *token.FileSet, f *ast.File) []*Issue

ForbiddenBundleImports makes sure libraries in another package under bundles/ are not imported.

func ForbiddenCalls

func ForbiddenCalls(fs *token.FileSet, f *ast.File, fix bool) []*Issue

ForbiddenCalls checks if any forbidden functions are called.

func ForbiddenImports

func ForbiddenImports(fs *token.FileSet, f *ast.File) []*Issue

ForbiddenImports makes sure blocked errors packages are not imported.

func FuncParams

func FuncParams(fs *token.FileSet, f *ast.File, fix bool) (issues []*Issue)

FuncParams checks function parameters and results.

func Golint

func Golint(path string, code []byte, debug bool) []*Issue

Golint runs Golint to find issues.

func ImportOrder

func ImportOrder(path string, in []byte) []*Issue

ImportOrder checks if the order of import entries are sorted in the following order.

  • Import entries should be split into three groups; stdlib, third-party packages, and chromiumos packages.
  • In each group, the entries should be sorted in the lexicographical order.
  • The groups should be separated by an empty line.

This order should be same as what "goimports --local chromiumos/" does.

func InterFileRefs

func InterFileRefs(fs *token.FileSet, f *ast.File) []*Issue

InterFileRefs checks that entry files do not have inter-file references. f should be one obtained from cachedParser; that is, its references within the package should have been resolved, but imports should not have been resolved.

func Messages

func Messages(fs *token.FileSet, f *ast.File, fix bool) []*Issue

Messages checks calls to logging- and error-related functions.

func PackageComment

func PackageComment(fs *token.FileSet, pkg *ast.Package) []*Issue

PackageComment checks if there is a document for given package.

func SecretVarFile

func SecretVarFile(path string, data []byte) (issues []*Issue)

SecretVarFile checks that files defining variables follow our convention. TODO(oka): Consider checking the file is formatted with a formatter.

func VerifyInformationalAttr

func VerifyInformationalAttr(fs *token.FileSet, f *ast.File) []*Issue

VerifyInformationalAttr checks if a newly added test has 'informational' attribute.

func VerifyTestingStateParam

func VerifyTestingStateParam(fs *token.FileSet, f *ast.File) []*Issue

VerifyTestingStateParam checks if functions in support packages use *testing.State as a parameter.

func VerifyTestingStateStruct

func VerifyTestingStateStruct(fs *token.FileSet, f *ast.File) []*Issue

VerifyTestingStateStruct checks if testing.State is stored inside struct types.

func (*Issue) String

func (i *Issue) String() string

Jump to

Keyboard shortcuts

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