luci: go.chromium.org/luci/lucicfg/buildifier Index | Files

package buildifier

import "go.chromium.org/luci/lucicfg/buildifier"

Package buildifier implements processing of Starlark files via buildifier.

Buildifier is primarily intended for Bazel files. We try to disable as much of Bazel-specific logic as possible, keeping only generally useful Starlark rules.

Index

Package Files

buildifier.go

Variables

var (
    // ErrActionableFindings is returned by Lint if there are actionable findings.
    ErrActionableFindings = errors.New("some *.star files have linter warnings, please fix them")
)

func Visit Uses

func Visit(loader interpreter.Loader, paths []string, v Visitor) errors.MultiError

Visit parses Starlark files using Buildifier and calls the callback for each parsed file, in parallel.

Collects all errors from all callbacks in a single joint multi-error.

type Finding Uses

type Finding struct {
    Path       string    `json:"path"`
    Start      *Position `json:"start,omitempty"`
    End        *Position `json:"end,omitempty"`
    Category   string    `json:"string,omitempty"`
    Message    string    `json:"message,omitempty"`
    Actionable bool      `json:"actionable,omitempty"`
}

Finding is information about one linting or formatting error.

Implements error interface. Non-actionable findings are assumed to be non-blocking errors.

func Lint Uses

func Lint(loader interpreter.Loader, paths []string, lintChecks []string) (findings []*Finding, err error)

Lint appliers linting and formatting checks to the given files.

Returns all findings and a non-nil error (usually a MultiError) if some findings are blocking.

func (*Finding) Error Uses

func (f *Finding) Error() string

Error returns a short summary of the finding.

func (*Finding) Format Uses

func (f *Finding) Format() string

Format returns a detailed reported that can be printed to stderr.

type Position Uses

type Position struct {
    Line   int `json:"line"`   // starting from 1
    Column int `json:"column`  // in runes, starting from 1
    Offset int `json:"offset"` // absolute offset in bytes
}

Position indicates a position within a file.

type Visitor Uses

type Visitor func(path string, body []byte, f *build.File) errors.MultiError

Visitor processes a parsed Starlark file, returning all errors encountered when processing it.

Package buildifier imports 12 packages (graph) and is imported by 6 packages. Updated 2020-10-28. Refresh now. Tools for package owners.