Documentation
¶
Overview ¶
Package errcheck implements the `glutter-gen errcheck` subcommand, which reads the whole module and reports what breaks the rules of github.com/rm4n0s/errors (its AI_GUIDE.md, summarized in CLAUDE.md, "Error handling", and SPEC §14.4).
Flutter: no counterpart.
Index ¶
Constants ¶
const ( // RuleStdErrors says that the standard library's errors package is not imported under // the name errors; rm4n0s/errors re-exports Is, As and Unwrap (R6). RuleStdErrors = "std-errors" // RuleFmtErrorf says that fmt.Errorf is not called; errors.NewErrf is its counterpart. RuleFmtErrorf = "fmt-errorf" // RuleMetadataChain says that the metadata of a new error is given in one call: to // errors.New itself, or in one SetMetadata after NewErr and NewErrf (R2). RuleMetadataChain = "metadata-chain" // RuleMetadataPairs says that metadata is alternating string keys and values (R2). RuleMetadataPairs = "metadata-pairs" // RuleSentinelCtor says that a package-level variable is not made by errors.New, // NewErr or NewErrf, which would capture the stack of init (R5). RuleSentinelCtor = "sentinel-ctor" // RuleErrorHelper says that a function that only builds an error and returns it is not // written: the constructor is called in the function that fails, so that the route is // right (R4). RuleErrorHelper = "error-helper" // RuleErrorRewrap says that an error that comes from a function of the module is // returned as it is, not wrapped again by NewErr or NewErrf (R3, case A). RuleErrorRewrap = "error-rewrap" // RuleErrorUntagged says that an error that comes from outside the module is tagged by // NewErr where it first appears, not returned as it is (R3, case B). RuleErrorUntagged = "error-untagged" // RuleTagBranch says that code does not compare the Tag of an error with a string // literal, or branch on its message; it uses a tag constant or errors.Is (R5). Tests are // not checked: a test pins the string that is the contract (a public tag, or the text of a // message that a ported Flutter test asserts). RuleTagBranch = "tag-branch" // RuleTagLiteral says that the tag given to errors.New, NewErr or NewErrf is a constant // or an expression, not a string literal (R5). RuleTagLiteral = "tag-literal" // RuleErrorToJson says that an error is logged with slog as "err", err, not through // ToJson (guide §5). Tests may call ToJson to replay an error. RuleErrorToJson = "error-tojson" )
The rules, as they are named in a report and in an allow file.
const ( // TagErrCheckAndroidNDKNotFound is the tag of the error for a missing Android NDK; the // metadata "install" has the sdkmanager command. TagErrCheckAndroidNDKNotFound = "ErrCheckAndroidNDKNotFound" )
The tags of the errors that this file makes (rm4n0s/errors, R5).
Variables ¶
var AndroidPass = Pass{GOOS: "android", GOARCH: "arm64"}
AndroidPass is the build for Android. The module is built with cgo and the NDK's clang there (SPEC §24.2), so that the *_android.go files of internal/platform/android are read.
Flutter: no counterpart.
var DarwinPass = Pass{GOOS: "darwin", GOARCH: "arm64", Tags: []string{"glutter_display", "glutter_audio"}}
DarwinPass is the build for macOS with the tags of the display and audio tests, so that the *_darwin.go files and the tests that open real windows are read (SPEC §29.13). It needs no toolchain besides the go command: macOS is built without cgo.
Flutter: no counterpart.
var DefaultPasses = []Pass{ {GOOS: "linux", GOARCH: "amd64"}, {GOOS: "js", GOARCH: "wasm"}, {GOOS: "linux", GOARCH: "amd64", Tags: []string{"glutter_display", "glutter_browser", "glutter_wine"}}, AndroidPass, WindowsPass, DarwinPass, }
DefaultPasses are the builds that together cover every file of the module: Linux, the web, Linux with the tags of the display, browser and Wine tests (the host-side tests that start Wine), Android (SPEC §24.13), Windows with the tag of the Wine tests (SPEC §25.13) and macOS with the tags of the display and audio tests (SPEC §29.13).
Flutter: no counterpart.
var WindowsPass = Pass{GOOS: "windows", GOARCH: "amd64", Tags: []string{"glutter_wine"}}
WindowsPass is the build for Windows with the tag of the Wine tests, so that the *_windows.go files and the tests that run inside Wine are read (SPEC §25.13). It needs no toolchain besides the go command: Windows is built without cgo.
Flutter: no counterpart.
Functions ¶
Types ¶
type Pass ¶
Pass is one way of building the module: a platform and a set of build tags.
Flutter: no counterpart.
func WithoutAndroid ¶
WithoutAndroid returns the passes with the Android one left out: for a machine that has no NDK, where the *_android.go files cannot be read (the owner's Linux machine runs them, SPEC §21).
Flutter: no counterpart.
type Violation ¶
type Violation struct {
// Rule is one of the Rule constants.
Rule string
// File is the path of the file below the root, with slashes.
File string
// Func is the function that holds the code: "Name", "Type.Name", or "-" outside any.
Func string
// Line is where the problem is.
Line int
// Message says what is wrong.
Message string
}
Violation is one place where the code breaks a rule.
Flutter: no counterpart.
func CheckModule ¶
CheckModule checks every package of the module below root for each pass and returns the violations, without duplicates, in the order of their files and lines.
Flutter: no counterpart.