base

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KubebuilderDefault = "+kubebuilder:default"
)

Variables

This section is empty.

Functions

func GetKubebuilderDefault added in v0.4.0

func GetKubebuilderDefault(field *ast.Field) (string, error)

func HasDocComment

func HasDocComment(field *ast.Field, substring string) bool

HasDocComment returns true if the field has a doc comment containting the substring

func ImportSpec

func ImportSpec(file *ast.File, pkg string) *ast.ImportSpec

func PointerType added in v0.4.0

func PointerType(type_ ast.Expr) bool

PointerType returns true if the type is a pointer

func Report

func Report(pass *analysis.Pass, pos token.Pos, analyzerName string, format string, a ...any)

Report a lint rule violation

Types

type BaseLinter

type BaseLinter struct {
	FileLinter
	*analysis.Analyzer
	Pass *analysis.Pass
	// contains filtered or unexported fields
}

func NewBaseLinter

func NewBaseLinter(Name string, Doc string, l FileLinter) *BaseLinter

func (*BaseLinter) Debug

func (l *BaseLinter) Debug(pos token.Pos, format string, a ...any)

func (*BaseLinter) ExprLastName added in v0.4.0

func (l *BaseLinter) ExprLastName(expr ast.Expr) string

ExprLastName returns the last segment of the name of the expression. I..e "a.b.c()" result in "c". If the expression is not constructed as a Selector / Ident tree then it returns "".

func (*BaseLinter) ExprName added in v0.4.0

func (l *BaseLinter) ExprName(expr ast.Expr) string

ExprName returns the expression as a name. I.e. "a.b.c()"" will result in "a.b.c" and x() will result in "x". If expression is not constructed as a Selector / Ident tree then it returns "".

func (*BaseLinter) Report

func (l *BaseLinter) Report(pos token.Pos, format string, a ...any)

Report a lint rule violation

func (*BaseLinter) TypeName added in v0.4.0

func (l *BaseLinter) TypeName(field *ast.Field) string

TypeName returns the name of the type of the field

type FileLinter

type FileLinter interface {
	LintFile(*ast.File) error
}

Jump to

Keyboard shortcuts

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