Files
wehub-resource-sync bf9395e022
CI / license-header (push) Has been skipped
CI / e2e-dry-run (push) Has been skipped
CI / fast-gate (push) Failing after 0s
Test PR Label Logic / test-pr-labels (push) Failing after 1s
Skill Format Check / check-format (push) Failing after 2s
CI / security (push) Failing after 5s
CI / unit-test (push) Has been skipped
CI / lint (push) Has been skipped
CI / script-test (push) Has been skipped
CI / deterministic-gate (push) Has been skipped
CI / coverage (push) Has been skipped
CI / results (push) Has been cancelled
CI / deadcode (push) Has been cancelled
CI / e2e-live (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:22:54 +08:00

41 lines
1.8 KiB
Go

// Copyright (c) 2026 Lark Technologies Pte. Ltd.
// SPDX-License-Identifier: MIT
package errscontract
import "strings"
// RunAll executes all four checks on the given source. allowlist controls CheckDeclaredSubtype;
// pass nil to skip it. Use RunAllWithNames to enable strengthened CheckDeclaredSubtype name
// resolution.
func RunAll(path, src string, allowlist map[string]struct{}) []Violation {
return RunAllWithNames(path, src, allowlist, nil)
}
// RunAllWithNames is RunAll with the strengthened CheckDeclaredSubtype. nameset, when
// non-nil, lets CheckDeclaredSubtype reject typo'd `errs.SubtypeBogus` selectors that
// reference no declared constant.
func RunAllWithNames(path, src string, allowlist, nameset map[string]struct{}) []Violation {
var out []Violation
if strings.HasPrefix(path, "errs/") || strings.Contains(path, "/errs/") {
// CheckProblemEmbed fires on errs/ files only (caller may also enforce parity
// across directory via CheckErrsContract).
out = append(out, CheckProblemEmbed(path, src)...)
// The next three rules also scope to errs/ files internally — they
// guard the typed wrappers that live exclusively in this package.
out = append(out, CheckNilSafeError(path, src)...)
out = append(out, CheckUnwrapSymmetry(path, src)...)
out = append(out, CheckBuilderImmutable(path, src)...)
}
// CheckBuildAPIErrorArms self-scopes to internal/errclass/classify.go.
out = append(out, CheckBuildAPIErrorArms(path, src)...)
out = append(out, CheckNoRegistrar(path, src)...)
out = append(out, CheckAdHocSubtype(path, src)...)
out = append(out, CheckTypedErrorCompleteness(path, src)...)
out = append(out, CheckNoBareCommandError(path, src, nil)...)
if allowlist != nil {
out = append(out, CheckDeclaredSubtypeWithNames(path, src, allowlist, nameset)...)
}
return out
}