model

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package model describes basic linter entities.

Index

Constants

View Source
const SuffixRecursive = "..."

SuffixRecursive is a path suffix which enables recursive directories discovering.

Variables

This section is empty.

Functions

func NewErrorSet

func NewErrorSet(errs ...error) (err error)

NewErrorSet creates error that handles many errors. It skips all nil errors.

func NewImportOrderError

func NewImportOrderError(n Node, reason Reason) error

NewImportOrderError creates new error about invalid import order.

Types

type Error

type Error string

Error is a constant like error.

func (Error) Error

func (err Error) Error() string

type Node

type Node struct {
	Kind     NodeKind
	Position token.Position
	Value    string
	// Offset out of comments.
	Offset int
}

Node describes a unit from the program.

func NewCommentNode

func NewCommentNode(
	fset *token.FileSet,
	comment *ast.Comment,
) (n Node)

NewCommentNode creates new Node for comment entity.

func NewImportNode

func NewImportNode(
	fset *token.FileSet,
	spec *ast.ImportSpec,
	pkg string,
) (n Node)

NewImportNode creates new Node for import entity.

func (Node) Index

func (n Node) Index() int

Index returns a line number subtracting offset.

type NodeKind

type NodeKind uint8

NodeKind describes a type of the node.

const (
	// KindUnknown is a undeterminated kind.
	KindUnknown NodeKind = iota
	// KindImportSTD is a standart library import kind.
	KindImportSTD
	// KindImportInternal is a current package import kind.
	KindImportInternal
	// KindImportVendor is a external package import kind.
	KindImportVendor
	// KindComment is a regular comment kind.
	KindComment
	// KindImportUnused is an unused package. For example SQL driver.
	KindImportUnused
	// KindImportC is a "C" package.
	// More details: https://pkg.go.dev/cmd/cgo.
	KindImportC
)

Possible node Kinds.

type Reason

type Reason string

Reason of an error.

const (
	ReasonUnknown      Reason = ""
	ReasonExtraLine    Reason = "extra line before"
	ReasonMissingLine  Reason = "missing line after"
	ReasonTooManyLines Reason = "too many lines after"
)

Possible reasons

func ReasonFromError

func ReasonFromError(err error) Reason

ReasonFromError extracts reason from the error.

Jump to

Keyboard shortcuts

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