v2check

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: Apache-2.0, BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Is

func Is[T any](ctx context.Context, n ast.Node, pass *analysis.Pass) (context.Context, bool)

Is returns true if the node is of type T. The type use in the generic signature is stored in the context as "type".

func IsFuncCall

func IsFuncCall(ctx context.Context, n ast.Node, pass *analysis.Pass) (context.Context, bool)

IsFuncCall returns true if the node is a function call. The function call expression is stored in the context as "fn". The package path of the function is stored as "pkg_path". The parameters of the function are stored as "args".

func IsImport

func IsImport(ctx context.Context, n ast.Node, pass *analysis.Pass) (context.Context, bool)

IsImport returns true if the node is an import statement. The import path is stored in the context as "pkg_path".

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

func NewChecker

func NewChecker(knownChanges ...KnownChange) *Checker

func (Checker) Run

func (c Checker) Run(handler func(*analysis.Analyzer))

type DDTraceTypes

type DDTraceTypes struct {
	// contains filtered or unexported fields
}

func (DDTraceTypes) End

func (d DDTraceTypes) End() token.Pos

func (DDTraceTypes) Fixes

func (c DDTraceTypes) Fixes() []analysis.SuggestedFix

func (DDTraceTypes) Pos

func (d DDTraceTypes) Pos() token.Pos

func (DDTraceTypes) Probes

func (DDTraceTypes) Probes() []Probe

func (DDTraceTypes) String

func (DDTraceTypes) String() string

type KnownChange

type KnownChange interface {
	fmt.Stringer

	// Context returns the context associated with the known change.
	Context() context.Context

	// Fixes returns a list of fixes that can be applied to the analyzed expression.
	Fixes() []analysis.SuggestedFix

	// Probes returns a list of probes that must be true to report the analyzed expression.
	Probes() []Probe

	// SetContext updates the context with the given value.
	SetContext(context.Context)

	// SetNode updates the node with the given value.
	SetNode(ast.Node)
}

KnownChange models code expressions that must be changed to migrate to v2. It is defined by a set of probes that must be true to report the analyzed expression. It also contains a message function that returns a string describing the change. The probes are evaluated in order, and the first one that returns false will cause the expression to be ignored. A probe can store information in the context, which is available to the following ones. It is possible to declare fixes that will be suggested to the user or applied automatically.

type Probe

func DeclaresType

func DeclaresType[T any]() Probe

DeclaresType returns true if the node declares a type of the given generic type. The type use in the generic signature is stored in the context as "type". The reflected type is stored in the context as "declared_type".

func HasPackagePrefix

func HasPackagePrefix(prefix string) Probe

HasPackagePrefix returns true if the selector expression has a package prefix. The package path is expected in the context as "pkg_path".

func ImportedFrom

func ImportedFrom(pkgPath string) Probe

ImportedFrom returns true if the value is imported from the given package path prefix.

func Not

func Not(p Probe) Probe

Not returns the inverse of the given probe.

func Or

func Or(ps ...Probe) Probe

Or returns a probe that is true if at least one of the given probes is true.

func WithFunctionName

func WithFunctionName(name string) Probe

type TraceIDString

type TraceIDString struct {
	// contains filtered or unexported fields
}

func (TraceIDString) End

func (d TraceIDString) End() token.Pos

func (TraceIDString) Fixes

func (c TraceIDString) Fixes() []analysis.SuggestedFix

func (TraceIDString) Pos

func (d TraceIDString) Pos() token.Pos

func (TraceIDString) Probes

func (c TraceIDString) Probes() []Probe

func (TraceIDString) String

func (c TraceIDString) String() string

type TracerStructs

type TracerStructs struct {
	// contains filtered or unexported fields
}

func (TracerStructs) End

func (d TracerStructs) End() token.Pos

func (TracerStructs) Fixes

func (c TracerStructs) Fixes() []analysis.SuggestedFix

func (TracerStructs) Pos

func (d TracerStructs) Pos() token.Pos

func (TracerStructs) Probes

func (TracerStructs) Probes() []Probe

func (TracerStructs) String

func (TracerStructs) String() string

type V1ImportURL

type V1ImportURL struct {
	// contains filtered or unexported fields
}

func (V1ImportURL) End

func (d V1ImportURL) End() token.Pos

func (V1ImportURL) Fixes

func (c V1ImportURL) Fixes() []analysis.SuggestedFix

func (V1ImportURL) Pos

func (d V1ImportURL) Pos() token.Pos

func (V1ImportURL) Probes

func (V1ImportURL) Probes() []Probe

func (V1ImportURL) String

func (V1ImportURL) String() string

type WithServiceName

type WithServiceName struct {
	// contains filtered or unexported fields
}

func (WithServiceName) End

func (d WithServiceName) End() token.Pos

func (WithServiceName) Fixes

func (WithServiceName) Pos

func (d WithServiceName) Pos() token.Pos

func (WithServiceName) Probes

func (c WithServiceName) Probes() []Probe

func (WithServiceName) String

func (c WithServiceName) String() string

Jump to

Keyboard shortcuts

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