Documentation ¶
Overview ¶
Package check contains tast-lint checkers.
Index ¶
- func ImportOrderAutoFix(fs *token.FileSet, f *ast.File) (*ast.File, error)
- func SortIssues(issues []*Issue)
- type Issue
- func Comments(fs *token.FileSet, f *ast.File) []*Issue
- func DeprecatedAPIs(fs *token.FileSet, f *ast.File) []*Issue
- func DropIgnoredIssues(issues []*Issue, fs *token.FileSet, f *ast.File) []*Issue
- func EmptySlice(fs *token.FileSet, f *ast.File, fix bool) []*Issue
- func Exports(fs *token.FileSet, f *ast.File) []*Issue
- func ExternalJSON(path string, in []byte) []*Issue
- func FixtureDeclarations(fs *token.FileSet, f *ast.File, fix bool) []*Issue
- func ForbiddenBundleImports(fs *token.FileSet, f *ast.File) []*Issue
- func ForbiddenCalls(fs *token.FileSet, f *ast.File, fix bool) []*Issue
- func ForbiddenFlashromSubprocess(fs *token.FileSet, f *ast.File) []*Issue
- func ForbiddenImports(fs *token.FileSet, f *ast.File) []*Issue
- func FuncParams(fs *token.FileSet, f *ast.File, fix bool) (issues []*Issue)
- func Golint(path string, code []byte, debug bool) []*Issue
- func ImportOrder(path string, in []byte) []*Issue
- func InterFileRefs(fs *token.FileSet, f *ast.File) []*Issue
- func Messages(fs *token.FileSet, f *ast.File, fix bool) []*Issue
- func NoHardcodedUserDirs(fs *token.FileSet, f *ast.File) []*Issue
- func PackageComment(fs *token.FileSet, pkg *ast.Package) []*Issue
- func SearchFlags(fs *token.FileSet, f *ast.File) (issues []*Issue)
- func SecretVarFile(path string, data []byte) (issues []*Issue)
- func TestDeclarations(fs *token.FileSet, f *ast.File, path git.CommitFile, fix bool) []*Issue
- func VerifyInformationalAttr(fs *token.FileSet, f *ast.File) []*Issue
- func VerifyTestingStateParam(fs *token.FileSet, f *ast.File) []*Issue
- func VerifyTestingStateStruct(fs *token.FileSet, f *ast.File) []*Issue
- func WarningCalls(fs *token.FileSet, f *ast.File, fix bool) []*Issue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ImportOrderAutoFix ¶
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 ¶
Issue holds an issue reported by the linter.
func Comments ¶
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 ¶
DeprecatedAPIs checks if deprecated APIs are used.
func DropIgnoredIssues ¶
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 ¶
EmptySlice warns the invalid empty slice declaration.
func Exports ¶
Exports checks that an entry file exports exactly one symbol, either a test main function or a gRPC service implementation type.
func ExternalJSON ¶
ExternalJSON checks if url in .external file has a date suffix or not.
func FixtureDeclarations ¶
FixtureDeclarations checks declarations of testing.Fixture structs.
func ForbiddenBundleImports ¶
ForbiddenBundleImports makes sure libraries in another package under bundles/ are not imported.
func ForbiddenCalls ¶
ForbiddenCalls checks if any forbidden functions are called.
func ForbiddenFlashromSubprocess ¶
ForbiddenFlashromSubprocess checks if "flashrom" command is called.
func ForbiddenImports ¶
ForbiddenImports makes sure tests don't have forbidden imports.
func FuncParams ¶
FuncParams checks function parameters and results.
func ImportOrder ¶
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 ¶
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 NoHardcodedUserDirs ¶
NoHardcodedUserDirs ensures that as we migrate away from the /home/chronos/user* bind mount, further additions are not added.
func PackageComment ¶
PackageComment checks if there is a document for given package.
func SearchFlags ¶
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 ¶
SecretVarFile checks that files defining variables follow our convention. TODO(oka): Consider checking the file is formatted with a formatter.
func TestDeclarations ¶
TestDeclarations checks declarations of testing.Test structs.
func VerifyInformationalAttr ¶
VerifyInformationalAttr checks if a newly added test has 'informational' attribute.
func VerifyTestingStateParam ¶
VerifyTestingStateParam checks if functions in support packages use *testing.State as a parameter.
func VerifyTestingStateStruct ¶
VerifyTestingStateStruct checks if testing.State is stored inside struct types.
func WarningCalls ¶
WarningCalls checks if any forbidden functions are called.
Source Files ¶
- check_informational.go
- check_lacros.go
- comments.go
- common.go
- declarations.go
- define_emptyslice.go
- deprecated_apis.go
- disallow_testingstate.go
- doc.go
- exports.go
- external_json.go
- forbidden_bundle_imports.go
- forbidden_calls.go
- forbidden_flashrom_subprocess.go
- forbidden_imports.go
- func_parameters.go
- golint.go
- import_order.go
- inter_file_refs.go
- issue.go
- messages.go
- no_hardcoded_user_dirs.go
- package_comment.go
- secret_vars.go
- tast_search_flags.go
- warnings_call.go