magus v0.4.3 is out. See what's new
¶ View markdown source · ✎ Suggest an edit
2 min read

grep-reader

An advisory by default: it explains, and blocks nothing, on a definition lookup with a context flag (grep -A40 'func X'), which uses grep to read the body.

What it catches

A definition lookup with a context flag (grep -A40 'func X'), which uses grep to read the body.

Why

A context count guesses at a declaration's length: too short cuts the body off and costs another call, too long spends lines on whatever follows. magus refs X --definition --source prints the declaration whole, numbered and checked against the index. Where the index cannot vouch for the name, the deny serves sed -n <first>,<last>p <file> instead, the declaration's own lines from a parse of the file the search reads (a named file or glob, or under a directory the files the index last saw name it). The single-file allowance symbol-search gives grep -n 'func X' f.go does not apply: with -A, -B or -C the search is the read. A deny resting on the index advises instead while the graph describes another tree, as graph-stale; one parsed from a named file does not. It fires only when every alternative is a definition lookup (func X, func (r *T) X, type X, type X struct) and a declaration of each name is found; a search for uses, a case-insensitive one, or one with any text alternative is left to the search rules. A pipe after it is named as not reproduced.

Default and override

By default this rule takes the decision advise. A workspace sets it by name, in its root magusfile, to deny, advise or off:

magus\guard.builtins({"grep-reader": "deny"})

A loosening takes effect once it is committed; a tightening applies at once.

Seeing it

A verdict names its rule in brackets, which is how you got here:

advise [grep-reader]: ...

magus describe rule grep-reader prints the same entry at a terminal, and magus describe rules lists every rule this workspace enforces.

See also

guardrulesgrep-readeradvise
Last updated (1a76274f)
Earlier changes on this page (3)

Full history ↗ · Blame source ↗

Glossary

Workspace

The magus root directory that owns a set of projects and shared config; the unit magus operates over. See workspace.

Magusfile

The magusfile.buzz that declares a project's targets (as export funs) and binds its spells. See targets.

Buzz

The language magusfiles are written in (the .buzz engine). See engines.

CI

An ordinary magusfile-defined target you compose yourself with magus\needs: magus does not hardcode its stages. Magus.RunCI treats it specially only in that it strips the rw charm, it is the anchor magus affected ci keys off, and a selected scope with no project declaring it is a load error rather than a silent no-op. See targets.

Advisor

One read-only check from the advice suite: it reads the changeset through magus and writes one titled section of findings. The same advisors run as a pull request comment in CI and inside magus diff --impact locally.

Conventions

Placeholders

Angle brackets mark a value you replace with your own; never type the brackets:

magus run <target>
magus completion <shell>    # e.g. bash, zsh, fish

<target>, <path>, <shell>, <name> and the like are stand-ins, not literal text.