lint

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package lint runs the checks of a project in one place: the checks of taply, with the ones that depend on a module run only when the module is enabled.

Index

Constants

View Source
const DefaultMaxLines = 1000

DefaultMaxLines is the file length limit of taply.

Variables

This section is empty.

Functions

func Files

func Files(dir string, maxLines int) error

Files fails when a hand written Go file is longer than maxLines: a file that long is several files that have not been split yet. Generated files are exempt.

func Format

func Format(dir string) error

Format fails when a Go file of the project is not gofmt formatted.

func Names

func Names() []string

Names lists every check name, for flag help.

func Run

func Run(ctx context.Context, dir string, checks []Check, out io.Writer) error

Run runs the checks, reports each one and returns an error when any failed. All checks run even after a failure, so one run shows everything that needs fixing.

Types

type Check

type Check struct {
	Name string
	Run  func(ctx context.Context, dir string) error
}

Check is one named check.

func Checks

func Checks(opts Options, run Runner, verify func(ctx context.Context, dir string) error) []Check

Checks returns the checks for a project in the order they run: cheap ones first, so a formatting slip fails in a second rather than after the vulnerability scan.

type Options

type Options struct {
	Skip         []string // names of checks to skip
	MaxLines     int      // file length limit; DefaultMaxLines when zero
	ProtoAgainst string   // git branch to check proto breaking changes against; off when empty
	Modules      []string // enabled modules
}

Options select what runs.

type Runner

type Runner func(ctx context.Context, dir string, out io.Writer, env []string, name string, args ...string) error

Runner runs a command in the project. Tests replace it.

Jump to

Keyboard shortcuts

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