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.
Variables ¶
var DefaultPasses = []Pass{ {GOOS: "linux", GOARCH: "amd64"}, {GOOS: "js", GOARCH: "wasm"}, {GOOS: "linux", GOARCH: "amd64", Tags: []string{"glutter_display", "glutter_browser"}}, }
DefaultPasses are the builds that together cover every file of the module: Linux, the web, and Linux with the tags of the display and browser tests.
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.
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.