Documentation ¶
Overview ¶
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 ¶
- Variables
- func Visit(loader interpreter.Loader, paths []string, v Visitor) errors.MultiError
- type Finding
- type LucicfgFmtConfig
- func (*LucicfgFmtConfig) Descriptor() ([]byte, []int)deprecated
- func (x *LucicfgFmtConfig) GetRules() []*LucicfgFmtConfig_Rules
- func (*LucicfgFmtConfig) ProtoMessage()
- func (x *LucicfgFmtConfig) ProtoReflect() protoreflect.Message
- func (x *LucicfgFmtConfig) Reset()
- func (x *LucicfgFmtConfig) String() string
- type LucicfgFmtConfig_Rules
- func (*LucicfgFmtConfig_Rules) Descriptor() ([]byte, []int)deprecated
- func (x *LucicfgFmtConfig_Rules) GetFunctionArgsSort() *LucicfgFmtConfig_Rules_FunctionArgsSort
- func (x *LucicfgFmtConfig_Rules) GetPath() []string
- func (*LucicfgFmtConfig_Rules) ProtoMessage()
- func (x *LucicfgFmtConfig_Rules) ProtoReflect() protoreflect.Message
- func (x *LucicfgFmtConfig_Rules) Reset()
- func (x *LucicfgFmtConfig_Rules) String() string
- type LucicfgFmtConfig_Rules_FunctionArgsSort
- func (*LucicfgFmtConfig_Rules_FunctionArgsSort) Descriptor() ([]byte, []int)deprecated
- func (x *LucicfgFmtConfig_Rules_FunctionArgsSort) GetArg() []string
- func (*LucicfgFmtConfig_Rules_FunctionArgsSort) ProtoMessage()
- func (x *LucicfgFmtConfig_Rules_FunctionArgsSort) ProtoReflect() protoreflect.Message
- func (x *LucicfgFmtConfig_Rules_FunctionArgsSort) Reset()
- func (x *LucicfgFmtConfig_Rules_FunctionArgsSort) String() string
- type Position
- type Visitor
Constants ¶
This section is empty.
Variables ¶
var ( // ErrActionableFindings is returned by Lint if there are actionable findings. ErrActionableFindings = errors.New("some *.star files have linter warnings, please fix them") )
var File_lucicfgfmtrc_proto protoreflect.FileDescriptor
Functions ¶
func Visit ¶
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.
Types ¶
type Finding ¶
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 ¶
func Lint(loader interpreter.Loader, paths []string, lintChecks []string, getRewriterForPath func(path string) (*build.Rewriter, error)) (findings []*Finding, err error)
Lint applies linting and formatting checks to the given files.
getRewriterForPath should return a Rewriter, given the path which needs linting. This will be used to check the 'format' lint check. If getRewriterForPath is nil, we will use vars.GetDefaultRewriter for this.
Returns all findings and a non-nil error (usually a MultiError) if some findings are blocking.
type LucicfgFmtConfig ¶
type LucicfgFmtConfig struct { Rules []*LucicfgFmtConfig_Rules `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` // contains filtered or unexported fields }
func (*LucicfgFmtConfig) Descriptor
deprecated
func (*LucicfgFmtConfig) Descriptor() ([]byte, []int)
Deprecated: Use LucicfgFmtConfig.ProtoReflect.Descriptor instead.
func (*LucicfgFmtConfig) GetRules ¶
func (x *LucicfgFmtConfig) GetRules() []*LucicfgFmtConfig_Rules
func (*LucicfgFmtConfig) ProtoMessage ¶
func (*LucicfgFmtConfig) ProtoMessage()
func (*LucicfgFmtConfig) ProtoReflect ¶
func (x *LucicfgFmtConfig) ProtoReflect() protoreflect.Message
func (*LucicfgFmtConfig) Reset ¶
func (x *LucicfgFmtConfig) Reset()
func (*LucicfgFmtConfig) String ¶
func (x *LucicfgFmtConfig) String() string
type LucicfgFmtConfig_Rules ¶
type LucicfgFmtConfig_Rules struct { // Forward-slash delimited path prefixes for which this Rules message applies. // // When loading this config, lucicfg will organize all Rules by path. Rules with // duplicate path values are not permitted (i.e. you cannot have two Rules with // a path of "something", nor can you have the path "something" duplicated within // a single Rules entry). // // When processing files, lucicfg will calculate the file's path as relative to // this .lucicfgfmtrc file, and will select a single Rules set based on the longest // matching path prefix. For example, if there are two Rules sets, one formatting // "a" and another formatting "a/folder", then for the file "a/folder/file.star", // only the second Rules set would apply. // // If NO Rules set matches the file path, then only default formatting will // occur (i.e. lucicfg will only apply formatting which is not controlled by // this Rules message. In particular, this means that formatting will not // attempt to reorder function call arguments in any way). Path []string `protobuf:"bytes,1,rep,name=path,proto3" json:"path,omitempty"` // FunctionArgsSort allows you to reorder the arguments at function call sites, // based on the name of the arguments. // // If this is set, then all functions will be sorted first by the order of its // `arg` field, and then alphanumerically. This implies that setting this message // without setting any `arg` values will sort all function call sites // alphabetically. // // If this message is completely omitted, no call site function argument reordering // will occur. // // The sorting only applies to kwarg-style arguments in files we want to format. FunctionArgsSort *LucicfgFmtConfig_Rules_FunctionArgsSort `protobuf:"bytes,2,opt,name=function_args_sort,json=functionArgsSort,proto3" json:"function_args_sort,omitempty"` // contains filtered or unexported fields }
Rules will contain paths that are associated with a specific ordering rule
func (*LucicfgFmtConfig_Rules) Descriptor
deprecated
func (*LucicfgFmtConfig_Rules) Descriptor() ([]byte, []int)
Deprecated: Use LucicfgFmtConfig_Rules.ProtoReflect.Descriptor instead.
func (*LucicfgFmtConfig_Rules) GetFunctionArgsSort ¶
func (x *LucicfgFmtConfig_Rules) GetFunctionArgsSort() *LucicfgFmtConfig_Rules_FunctionArgsSort
func (*LucicfgFmtConfig_Rules) GetPath ¶
func (x *LucicfgFmtConfig_Rules) GetPath() []string
func (*LucicfgFmtConfig_Rules) ProtoMessage ¶
func (*LucicfgFmtConfig_Rules) ProtoMessage()
func (*LucicfgFmtConfig_Rules) ProtoReflect ¶
func (x *LucicfgFmtConfig_Rules) ProtoReflect() protoreflect.Message
func (*LucicfgFmtConfig_Rules) Reset ¶
func (x *LucicfgFmtConfig_Rules) Reset()
func (*LucicfgFmtConfig_Rules) String ¶
func (x *LucicfgFmtConfig_Rules) String() string
type LucicfgFmtConfig_Rules_FunctionArgsSort ¶
type LucicfgFmtConfig_Rules_FunctionArgsSort struct { // Argument names in the order they should appear in calls. // // The ordering of an argument can be specific to a function by // specifying the argument name as <function-name>.<arg-name>, where // <function-name> is the name used at the callsite. The name the // function is defined with is not considered. This means that loading a // function with an alias will change which entries apply to calls to the // function. When the ordering for an argument is determined, if // <function-name>.<arg-name> is present, it will use the relative // ordering of that entry to determine the order of the argument in the // call. If <function-name>.<arg-name> is not present and <arg-name> is // present, it will use the relative ordering of that entry to determine // the order of the argument in the call. If neither // <function-name>.<arg-name> nor <arg-name> are present, then the // argument will appear in lexicographic order after any arguments that // are specified in the list. Arg []string `protobuf:"bytes,1,rep,name=arg,proto3" json:"arg,omitempty"` // contains filtered or unexported fields }
func (*LucicfgFmtConfig_Rules_FunctionArgsSort) Descriptor
deprecated
func (*LucicfgFmtConfig_Rules_FunctionArgsSort) Descriptor() ([]byte, []int)
Deprecated: Use LucicfgFmtConfig_Rules_FunctionArgsSort.ProtoReflect.Descriptor instead.
func (*LucicfgFmtConfig_Rules_FunctionArgsSort) GetArg ¶
func (x *LucicfgFmtConfig_Rules_FunctionArgsSort) GetArg() []string
func (*LucicfgFmtConfig_Rules_FunctionArgsSort) ProtoMessage ¶
func (*LucicfgFmtConfig_Rules_FunctionArgsSort) ProtoMessage()
func (*LucicfgFmtConfig_Rules_FunctionArgsSort) ProtoReflect ¶
func (x *LucicfgFmtConfig_Rules_FunctionArgsSort) ProtoReflect() protoreflect.Message
func (*LucicfgFmtConfig_Rules_FunctionArgsSort) Reset ¶
func (x *LucicfgFmtConfig_Rules_FunctionArgsSort) Reset()
func (*LucicfgFmtConfig_Rules_FunctionArgsSort) String ¶
func (x *LucicfgFmtConfig_Rules_FunctionArgsSort) String() string