consider

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package consider provides the core of a linter that helps to avoid certain phrases in code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatting

type Formatting struct {
	// WithReferences indicates whether the long-form of references shall be added.
	// This is not done by default as this is done in separate lines.
	WithReferences *bool `yaml:"withReferences"`
}

Formatting descries how messages shall be formatted.

type Linter

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

Linter is the main type of the linting functionality.

func NewLinter

func NewLinter(settings Settings, reporter Reporter) *Linter

NewLinter returns a new instance for given parameters.

func (*Linter) CheckFile

func (l *Linter) CheckFile(file *ast.File, rawFile *token.File)

CheckFile runs the analysis on given file.

type Phrase

type Phrase struct {
	// Synonyms are one or more expressions that have the same meaning and proposed alternatives.
	Synonyms []string `yaml:"synonyms"`
	// Alternatives are zero, one, or more expressions that are provided as replacement.
	Alternatives []string `yaml:"alternatives"`
	// References is a list of either direct, or keyed references into the global map of references.
	References []string `yaml:"references"`
}

Phrase describes an expression, with optional alternatives, that the linter flags.

type Reporter

type Reporter interface {
	// Report is called for each detected issue.
	Report(pos token.Pos, message string)
}

Reporter is the outgoing interface for detected issues.

type Settings

type Settings struct {
	// References is a key-value map of short keys to a reference, typically a stable link.
	// They indicate resources that can help understand why phrases are flagged, or
	// at least give examples of other (larger) peer groups that considered rewording.
	References map[string]string `yaml:"references"`
	// Phrases describe all the texts the linter should look for.
	Phrases []Phrase `yaml:"phrases"`
	// Formatting describes how the messages shall be formatted.
	Formatting Formatting `yaml:"formatting"`
}

Settings contain all the parameters for the analysis.

Jump to

Keyboard shortcuts

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