revive: Index | Files

package lint

import ""


Package Files

config.go failure.go file.go formatter.go linter.go package.go rule.go utils.go


const (
    // SeverityWarning declares failures of type warning
    SeverityWarning = "warning"
    // SeverityError declares failures of type error.
    SeverityError = "error"

func Name Uses

func Name(name string, whitelist, blacklist []string) (should string)

Name returns a different name if it should be different.

type AbstractRule Uses

type AbstractRule struct {
    Failures []Failure

AbstractRule defines an abstract rule.

type Arguments Uses

type Arguments = []interface{}

Arguments is type used for the arguments of a rule.

type Config Uses

type Config struct {
    IgnoreGeneratedHeader bool `toml:"ignoreGeneratedHeader"`
    Confidence            float64
    Severity              Severity
    Rules                 RulesConfig      `toml:"rule"`
    ErrorCode             int              `toml:"errorCode"`
    WarningCode           int              `toml:"warningCode"`
    Directives            DirectivesConfig `toml:"directive"`

Config defines the config of the linter.

type DirectiveConfig Uses

type DirectiveConfig struct {
    Severity Severity

DirectiveConfig is type used for the linter directive configuration.

type DirectivesConfig Uses

type DirectivesConfig = map[string]DirectiveConfig

DirectivesConfig defines the config for all directives.

type DisabledInterval Uses

type DisabledInterval struct {
    From     token.Position
    To       token.Position
    RuleName string

DisabledInterval contains a single disabled interval and the associated rule name.

type Failure Uses

type Failure struct {
    Failure    string
    RuleName   string
    Category   string
    Position   FailurePosition
    Node       ast.Node `json:"-"`
    Confidence float64
    // For future use
    ReplacementLine string

Failure defines a struct for a linting failure.

func (*Failure) GetFilename Uses

func (f *Failure) GetFilename() string

GetFilename returns the filename.

type FailurePosition Uses

type FailurePosition struct {
    Start token.Position
    End   token.Position

FailurePosition returns the failure position

func ToFailurePosition Uses

func ToFailurePosition(start token.Pos, end token.Pos, file *File) FailurePosition

ToFailurePosition returns the failure position.

type File Uses

type File struct {
    Name string
    Pkg  *Package

    AST *ast.File
    // contains filtered or unexported fields

File abstraction used for representing files.

func NewFile Uses

func NewFile(name string, content []byte, pkg *Package) (*File, error)

NewFile creates a new file

func (*File) CommentMap Uses

func (f *File) CommentMap() ast.CommentMap

CommentMap builds a comment map for the file.

func (*File) Content Uses

func (f *File) Content() []byte

Content returns the file's content.

func (*File) IsTest Uses

func (f *File) IsTest() bool

IsTest returns if the file contains tests.

func (*File) IsUntypedConst Uses

func (f *File) IsUntypedConst(expr ast.Expr) (defType string, ok bool)

IsUntypedConst reports whether expr is an untyped constant, and indicates what its default type is. scope may be nil.

func (*File) Render Uses

func (f *File) Render(x interface{}) string

Render renters a node.

func (*File) ToPosition Uses

func (f *File) ToPosition(pos token.Pos) token.Position

ToPosition returns line and column for given position.

type Formatter Uses

type Formatter interface {
    Format(<-chan Failure, Config) (string, error)
    Name() string

Formatter defines an interface for failure formatters

type FormatterMetadata Uses

type FormatterMetadata struct {
    Name        string
    Description string
    Sample      string

FormatterMetadata configuration of a formatter

type Linter Uses

type Linter struct {
    // contains filtered or unexported fields

Linter is used for linting set of files.

func New Uses

func New(reader ReadFile) Linter

New creates a new Linter

func (*Linter) Lint Uses

func (l *Linter) Lint(packages [][]string, ruleSet []Rule, config Config) (<-chan Failure, error)

Lint lints a set of files with the specified rule.

type Package Uses

type Package struct {
    TypesPkg  *types.Package
    TypesInfo *types.Info

    // sortable is the set of types in the package that implement sort.Interface.
    Sortable map[string]bool
    // contains filtered or unexported fields

Package represents a package in the project.

func (*Package) IsMain Uses

func (p *Package) IsMain() bool

IsMain returns if that's the main package.

func (*Package) TypeCheck Uses

func (p *Package) TypeCheck() error

TypeCheck performs type checking for given package.

func (*Package) TypeOf Uses

func (p *Package) TypeOf(expr ast.Expr) types.Type

TypeOf returns the type of an expression.

type ReadFile Uses

type ReadFile func(path string) (result []byte, err error)

ReadFile defines an abstraction for reading files.

type Rule Uses

type Rule interface {
    Name() string
    Apply(*File, Arguments) []Failure

Rule defines an abstract rule interaface

type RuleConfig Uses

type RuleConfig struct {
    Arguments Arguments
    Severity  Severity

RuleConfig is type used for the rule configuration.

type RulesConfig Uses

type RulesConfig = map[string]RuleConfig

RulesConfig defines the config for all rules.

type Severity Uses

type Severity string

Severity is the type for the failure types.

Package lint imports 15 packages (graph) and is imported by 21 packages. Updated 2019-08-11. Refresh now. Tools for package owners.