diff --git a/cmd/cue/cmd/custom.go b/cmd/cue/cmd/custom.go index f9f7484e6..012ad5468 100644 --- a/cmd/cue/cmd/custom.go +++ b/cmd/cue/cmd/custom.go @@ -93,26 +93,20 @@ func customCommand(c *Command, typ, name string, tools *cue.Instance) (*cobra.Co // Ensure there is at least one tool file. // TODO: remove this block to allow commands to be defined in any file. - for _, v := range []cue.Value{tools.Lookup(typ), o} { - _, w := value.ToInternal(v) - hasToolFile := false - w.VisitLeafConjuncts(func(c adt.Conjunct) bool { - src := c.Source() - if src == nil { - return true - } - if strings.HasSuffix(src.Pos().Filename(), "_tool.cue") { - hasToolFile = true - return false - } + _, w := value.ToInternal(tools.Lookup(typ)) + hasToolFile := false + w.VisitLeafConjuncts(func(c adt.Conjunct) bool { + src := c.Source() + if src == nil { return true - }) - if hasToolFile { - break } - if err := v.Err(); err != nil { - return nil, err + if strings.HasSuffix(src.Pos().Filename(), "_tool.cue") { + hasToolFile = true + return false } + return true + }) + if !hasToolFile { return nil, errors.Newf(token.NoPos, "could not find command %q", name) } diff --git a/staticcheck.conf b/staticcheck.conf index f51215ce0..19d3cc78e 100644 --- a/staticcheck.conf +++ b/staticcheck.conf @@ -4,7 +4,6 @@ checks = [ "inherit", "-SA1019", # use of deprecated APIs "-SA4000", # identical expressions in && or || logic - "-SA4004", # loop broken unconditionally "-S1008", # simplify if/else to bool expression "-S1011", # simplify loop with append "-U1000", # unused code