check

package
v0.0.0-...-b5d9cbe Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Overview

Package check contains tast-lint checkers.

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
	Warning 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 DeprecatedAPIs

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

DeprecatedAPIs checks if deprecated APIs are used.

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 FixtureDeclarations

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

FixtureDeclarations checks declarations of testing.Fixture structs.

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 ForbiddenFlashromSubprocess

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

ForbiddenFlashromSubprocess checks if "flashrom" command is called.

func ForbiddenImports

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

ForbiddenImports makes sure tests don't have forbidden imports.

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 NoHardcodedUserDirs

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

NoHardcodedUserDirs ensures that as we migrate away from the /home/chronos/user* bind mount, further additions are not added.

func PackageComment

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

PackageComment checks if there is a document for given package.

func SearchFlags

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

SearchFlags checks search flags in Tast tests definitions for policy names that have been used during the testing phase. If the file is not a Tast test, then it is skipped.

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 TestDeclarations

func TestDeclarations(fs *token.FileSet, f *ast.File, path git.CommitFile, fix bool) []*Issue

TestDeclarations checks declarations of testing.Test structs.

func VerifyFirmwareAttrs

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

VerifyFirmwareAttrs checks that "group:firmware" related attributes are set correctly.

func VerifyInformationalAttr

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

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

func VerifyMainlineAttrs

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

VerifyMainlineAttrs checks that "group:mainline" related attributes are set correctly.

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 VerifyVMStableAttrs

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

VerifyVMStableAttrs checks that "vm_stable" related attributes are set correctly.

func WarningCalls

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

WarningCalls checks if any forbidden functions are called.

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