lint

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package lint provides the core functionality of easyp lint.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRule = errors.New("invalid rule")
)

Functions

func CheckIsIgnored added in v0.6.0

func CheckIsIgnored(comments []*parser.Comment, ruleName string) bool

CheckIsIgnored check if passed ruleName has to be ignored due to ignore command in comments

func GetRuleName added in v0.6.0

func GetRuleName(rule Rule) string

GetRuleName returns rule name

func SetAllowCommentIgnores added in v0.6.0

func SetAllowCommentIgnores(val bool)

Types

type ImportPath added in v0.4.0

type ImportPath string

ImportPath type alias for path import in proto file

func ConvertImportPath added in v0.4.0

func ConvertImportPath(source string) ImportPath

type Issue added in v0.6.0

type Issue struct {
	Position   meta.Position
	SourceName string
	Message    string
	RuleName   string
}

Issue contains the information of an issue.

func AppendIssue added in v0.6.0

func AppendIssue(
	issues []Issue, lintRule Rule, pos meta.Position, sourceName string, comments []*parser.Comment,
) []Issue

AppendIssue check if lint error is ignored -> add new error to slice otherwise ignore appending

type IssueInfo added in v0.6.0

type IssueInfo struct {
	Issue
	Path string
}

IssueInfo contains the information of an issue and the path.

type Lint

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

Lint is the core functionality of easyp lint.

func New

func New(rules []Rule, ignore []string, ignoreOnly map[string][]string, deps []string) *Lint

New creates a new Lint.

func (*Lint) Lint

func (c *Lint) Lint(ctx context.Context, disk fs.FS) ([]IssueInfo, error)

Lint lints the proto file.

type OpenImportFileError added in v0.6.0

type OpenImportFileError struct {
	FileName string
}

func (*OpenImportFileError) Error added in v0.6.0

func (e *OpenImportFileError) Error() string

type ProtoInfo

type ProtoInfo struct {
	Path                 string
	Info                 *unordered.Proto
	ProtoFilesFromImport map[ImportPath]*unordered.Proto
}

ProtoInfo is the information of a proto file.

type Rule

type Rule interface {
	// Message returns the message of the rule.
	Message() string
	// Validate validates the proto rule.
	Validate(ProtoInfo) ([]Issue, error)
}

Rule is an interface for a rule checking.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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