skillcurator: nilerr finding at skillcurator.go:110 (archie)
Implements #748
This commit is contained in:
1 parent
d6cec97de1
commit
52941d152a
2 files changed
+14
-5
No files matched your search
@@ -112,11 +112,7 @@ func (c *Curator) reviewOne(ctx context.Context, name string) ([]curator.Action,
|
||||
// batch on a non-nil error, which would stop reviewing every
|
||||
// other skill over one bad file (see skillcurator_test.go's
|
||||
// "must not abort review of the others").
|
||||
return []curator.Action{{ //nolint:nilerr
|
||||
Type: ActionInvalid,
|
||||
Detail: name,
|
||||
Reason: fail.Error(),
|
||||
}}, nil
|
||||
return invalidFinding(name, fail)
|
||||
}
|
||||
|
||||
if missing := missingField(fm); missing != "" {
|
||||
@@ -141,6 +137,16 @@ func (c *Curator) reviewOne(ctx context.Context, name string) ([]curator.Action,
|
||||
}}, nil
|
||||
}
|
||||
|
||||
// invalidFinding converts a parse error into a per-skill action. Parse
|
||||
// failures are expected findings, so they must not abort the rest of Pass.
|
||||
func invalidFinding(name string, parseErr error) ([]curator.Action, error) {
|
||||
return []curator.Action{{
|
||||
Type: ActionInvalid,
|
||||
Detail: name,
|
||||
Reason: parseErr.Error(),
|
||||
}}, nil
|
||||
}
|
||||
|
||||
// missingField returns the name of the first required frontmatter field
|
||||
// fm lacks, or "" if both are present. Order (name before description)
|
||||
// only affects which single reason is reported when both are missing;
|
||||
|
||||
@@ -60,6 +60,9 @@ func TestPassFlagsAParseFailureWithoutWriting(t *testing.T) {
|
||||
if res.Actions[0].Detail != "broken" {
|
||||
t.Errorf("Detail = %q, want the skill name", res.Actions[0].Detail)
|
||||
}
|
||||
if res.Actions[0].Reason == "" {
|
||||
t.Error("Reason is empty, want the parse failure")
|
||||
}
|
||||
|
||||
// The broken skill must be untouched: this curator never rewrites
|
||||
// content it could not parse.
|
||||
|
||||
Reference in new issue
Block a user