utils

package
v0.0.0-...-1429e15 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 7

Documentation

Overview

Package utils contains shared methods that can be used by different implementations of buildifier binary

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandDirectories

func ExpandDirectories(args *[]string) ([]string, error)

ExpandDirectories takes a list of file/directory names and returns a list with file names by traversing each directory recursively and searching for relevant Starlark files.

func GetParser

func GetParser(inputType string) func(filename string, data []byte) (*build.File, error)

GetParser returns a parser for a given file type

func Lint

func Lint(f *build.File, lint string, warningsList *[]string, verbose bool) []*warn.Finding

Lint calls the linter and returns a list of unresolved findings

Types

type Diagnostics

type Diagnostics struct {
	Success bool               `json:"success"` // overall success (whether all files are formatted properly and have no warnings)
	Files   []*FileDiagnostics `json:"files"`   // diagnostics per file
}

Diagnostics contains diagnostic information returned by formatter and linter

func NewDiagnostics

func NewDiagnostics(fileDiagnostics ...*FileDiagnostics) *Diagnostics

NewDiagnostics returns a new Diagnostics object

func (*Diagnostics) Format

func (d *Diagnostics) Format(format string, verbose bool) string

Format formats a Diagnostics object either as plain text or as json

type FileDiagnostics

type FileDiagnostics struct {
	Filename  string     `json:"filename"`
	Formatted bool       `json:"formatted"`
	Valid     bool       `json:"valid"`
	Warnings  []*warning `json:"warnings"`
}

FileDiagnostics contains diagnostics information for a file

func InvalidFileDiagnostics

func InvalidFileDiagnostics(filename string) *FileDiagnostics

InvalidFileDiagnostics returns a new FileDiagnostics object for an invalid file

func NewFileDiagnostics

func NewFileDiagnostics(filename string, warnings []*warn.Finding) *FileDiagnostics

NewFileDiagnostics returns a new FileDiagnostics object

type TempFile

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

TempFile keeps track of temporary files and cleans them up in the end

func (*TempFile) Clean

func (tf *TempFile) Clean() error

Clean removes all created temporary files

func (*TempFile) WriteTemp

func (tf *TempFile) WriteTemp(data []byte) (file string, err error)

WriteTemp writes data to a temporary file and returns the name of the file.

Jump to

Keyboard shortcuts

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