linter

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 7 Imported by: 0

README

Linter

This package is for implementations of the Linter type in Crie, though the cli package is probably all that is needed there's no reason you can't directly call a library or service that isn't run as a command

Documentation

Overview

Package linter provides a simple interface for linting, allowing for custom implementations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Result added in v1.0.0

func Result(err error) error

Result conditionally wraps an error with a FailedResultError or otherwise passes through nil, it should be used when a linter didn't error but returned a failed result

Types

type FailedResultError added in v1.0.0

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

FailedResultError means a linter didn't error but returned a failed result

func (*FailedResultError) Error added in v1.0.0

func (e *FailedResultError) Error() string

Error implements the error interface

type Linter

type Linter interface {
	Name() string
	Setup(ctx context.Context) error
	Cleanup(ctx context.Context) error
	Run(filePath string) Report
}

Linter is a simple interface to enable a setup and check using WillRun before executing multiple Run's it is expected that Setup and Cleanup will be called exactly once given a context. It is up to the implementation to pass a context to the Run method if needed and to cancel from the cleanup.

type Report

type Report struct {
	Target string
	Err    error
	StdOut io.Reader
	StdErr io.Reader
}

Report is used to state what issues a given file has

type Reporter added in v1.0.6

type Reporter interface {
	Log(rep *Report) error
}

Reporter is used to report results to the user

func NewStandardReporter added in v1.0.6

func NewStandardReporter(showPass bool) Reporter

NewStandardReporter creates a new StandardReporter

func NewStructuredReporter added in v1.0.6

func NewStructuredReporter(showPass bool) Reporter

NewStructuredReporter creates a new StructuredReporter

type StandardReporter added in v1.0.6

type StandardReporter struct {
	ShowPass bool
	SrcOut   logFormat
	SrcErr   logFormat
	SrcInt   logFormat
	fold.Folder
}

StandardReporter is a Reporter that uses simple logging

func (*StandardReporter) Log added in v1.0.6

func (r *StandardReporter) Log(rep *Report) error

Log simple takes all fields and pushes them to our using the default logFormat

type StructuredReporter added in v1.0.6

type StructuredReporter struct {
	ShowPass bool
	SrcOut   *log.Logger
	SrcErr   *log.Logger
	SrcInt   *log.Logger
}

StructuredReporter is a Reporter that uses structured logging

func (*StructuredReporter) Log added in v1.0.6

func (r *StructuredReporter) Log(rep *Report) error

Log simple takes all fields and pushes them to our using the default logFormat

Jump to

Keyboard shortcuts

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