okgo

package
v1.55.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: Apache-2.0 Imports: 8 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteErrorAsIssue

func WriteErrorAsIssue(err error, stdout io.Writer)

Types

type ByCheckerType

type ByCheckerType []CheckerType

func (ByCheckerType) Len

func (a ByCheckerType) Len() int

func (ByCheckerType) Less

func (a ByCheckerType) Less(i, j int) bool

func (ByCheckerType) Swap

func (a ByCheckerType) Swap(i, j int)

type Checker

type Checker interface {
	// Type returns the type of this Checker.
	Type() (CheckerType, error)

	// Priority returns the priority of the check. A lower number indicates a higher priority (will be run earlier).
	Priority() (CheckerPriority, error)

	// MultiCPU returns if the check uses multiple CPUs in its check command
	MultiCPU() (CheckerMultiCPU, error)

	// Check runs the check on the specified packages and writes the output to the provided io.Writer. All output
	// written to the writer must be the JSON-serialized form of Issue, where there is one issue per line. Note that
	// this function does not return an error -- if an error is encountered during execution, it should be written to
	// the provided io.Writer as an Issue (issues that aren't issues with underlying code should only populate the
	// "Content" field). If any output is written to the writer, the check is considered to have failed.
	Check(pkgPaths []string, projectDir string, stdout io.Writer)

	// RunCheckCmd runs the check command directly using the provided arguments and writes the unaltered output to the
	// provided writer.
	RunCheckCmd(args []string, stdout io.Writer)
}

type CheckerFactory

type CheckerFactory interface {
	Types() []CheckerType
	NewChecker(checkerType CheckerType, cfgYMLBytes []byte) (Checker, error)
	ConfigUpgrader(checkerType CheckerType) (ConfigUpgrader, error)
}

type CheckerMultiCPU added in v1.50.0

type CheckerMultiCPU bool

type CheckerParam

type CheckerParam struct {
	Skip     bool
	Priority *CheckerPriority
	Checker  Checker
	Filters  []Filter
	Exclude  matcher.Matcher
}

type CheckerPriority

type CheckerPriority int

type CheckerType

type CheckerType string

type ConfigUpgrader added in v1.0.0

type ConfigUpgrader interface {
	TypeName() CheckerType
	UpgradeConfig([]byte) ([]byte, error)
}

type Filter

type Filter interface {
	Filter(issue Issue) bool
}

type Issue

type Issue struct {
	Path    string `json:"path"`
	Line    int    `json:"line"`
	Col     int    `json:"col"`
	Content string `json:"content"`
}

func NewIssueFromJSON

func NewIssueFromJSON(in string) Issue

NewIssueFromJSON creates an Issue from the provided input. If the provided input is the JSON representation of an Issue, it is decoded and returned. Otherwise, a new Issue is created with the content set to the provided string and all other fields zero'd out.

func NewIssueFromLine

func NewIssueFromLine(in, wd string) Issue

NewIssueFromLine creates a new Issue from the provided input. If the provided input matches the regular expression `(.+):(\d+):(\d+): (.+)`, then a new issue is created from the corresponding components of the regular expression. Otherwise, a new issue is created where the Content of the issue is the entire input. If the Path component of the input line is an absolute path, it is converted to a relative path with the provided wd used as the base directory.

func (*Issue) String

func (issue *Issue) String() string

type ProjectParam

type ProjectParam struct {
	ReleaseTag string
	Checks     map[CheckerType]CheckerParam
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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