whitespace

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 5 Imported by: 9

README

Whitespace linter

Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc.

Installation guide

To install as a standalone linter, run go install github.com/ultraware/whitespace.

Whitespace is also included in golangci-lint. Install it and enable whitespace.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAnalyzer added in v0.1.0

func NewAnalyzer(settings *Settings) *analysis.Analyzer

NewAnalyzer creates a new whitespace analyzer.

Types

type Message

type Message struct {
	// Diagnostic is what position the diagnostic should be put at. This isn't
	// always the same as the fix start, f.ex. when we fix trailing newlines we
	// put the diagnostic at the right bracket but we fix between the end of the
	// last statement and the bracket.
	Diagnostic token.Pos

	// FixStart is the span start of the fix.
	FixStart token.Pos

	// FixEnd is the span end of the fix.
	FixEnd token.Pos

	// LineNumbers represent the actual line numbers in the file. This is set
	// when finding the diagnostic to make it easier to suggest fixes in
	// golangci-lint.
	LineNumbers []int

	// MessageType represents the type of message it is.
	MessageType MessageType

	// Message is the diagnostic to show.
	Message string
}

Message contains a message and diagnostic information.

func Run

func Run(pass *analysis.Pass, settings *Settings) []Message

type MessageType added in v0.0.3

type MessageType uint8

MessageType describes what should happen to fix the warning.

const (
	MessageTypeRemove MessageType = iota + 1
	MessageTypeAdd
)

List of MessageTypes.

type RunningMode added in v0.1.0

type RunningMode uint8

RunningMode describes the mode the linter is run in. This can be either native or golangci-lint.

const (
	RunningModeNative RunningMode = iota
	RunningModeGolangCI
)

type Settings added in v0.0.3

type Settings struct {
	Mode      RunningMode
	MultiIf   bool
	MultiFunc bool
}

Settings contains settings for edge-cases.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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