Skip to content

Commands

Run every command as assay <command> from the package root: the directory of pubspec.yaml and the root analysis_options.yaml. The one exception is trend, which reads snapshots alone and runs anywhere. assay <command> --help prints what a command takes.

Command What it does
init Adopts a preset: --preset core|recommended|strict, by default the preset of assay the options file already includes, else recommended. It writes no agent hook: the agent plugin is installed in the agent (see The gate and agent setup). See also Getting started.
config The configuration in effect; --verbose says where each value came from. See also Configuration.
check [paths…] Judges the project, or the given paths, with assay’s rules only: no SDK lint. Honours the baseline; --no-baseline shows and counts every violation and removes nothing from the baseline.
gate The gate: assay’s rules, the SDK lints and the compiler, on the whole project or on a change. See also The gate and agent setup, The two judgements and CI integrations.
mark --out <file> Writes the state of the project now, for a later gate --scope changed --since <file>. The agent plugin takes one at session start.
baseline status The baseline’s size, its growth records and how many entries no longer match. Changes nothing.
baseline update Removes the entries that no longer match. With --add, also records every violation that is not in the baseline, under a new growth record, and creates the baseline where there is none. See also Baseline.
fix [paths…] Applies every available fix; --dry-run prints the edits and writes nothing; --rule <rule> limits it to one rule, repeatable. See also Fixes.
metrics [paths…] The metric report, with the code lines of each file and the duplicated code; --coverage <lcov file> adds the line coverage. See also Metrics.
trend <file or directory…> How the snapshots that gate --snapshot and metrics --snapshot wrote moved, in the console or as an HTML page. See also Snapshots and trends.
cross-file [checks…] The cross-file checks, or the named ones, on the whole project. See also Cross-file checks.
assets [checks…] The asset checks, or the named ones. See also Asset checks.
project-files [checks…] The project-file checks, or the named ones: security in the pubspec, the declared assets, the Android manifest and the Info.plist. Advisory. See also Project-file checks.
version Prints assay <version>; --json names the formats the program reads and writes.

--reporter <name>[:<file>], repeatable. Without it, console writes to standard output.

Commands Reporters
check, gate, cross-file, assets, project-files console, json, sarif, gitlab, github, markdown
metrics console, json, html
trend console, html (its own page, not the metric page)
  • A report file is named by a path absolute or relative to the package root; for trend, relative to the directory it runs in. The directories above it that do not exist are created.
  • A report file is written whole, so it replaces what the file held, $GITHUB_STEP_SUMMARY among them.
  • Standard output takes at most one of the reporters that write one document: json, sarif, gitlab, markdown, and html for metrics and trend. console and github can share it.
  • Two reporters given the same file are a usage error.

--color auto|always|never: the form of what is written for a person. auto writes colour and Unicode on a terminal (without colour where NO_COLOR is set), and the plain form, ASCII only, elsewhere; always writes colour and Unicode, never the plain form. A report file is always plain. See The console report.

Reporter What it writes
console Titled boxes for a person to read: the head, the violations by file, the grouped copies of duplicated_code, each rule once with its message and how to fix it, what the gate found besides, and the verdict with the counts and what to do next. See The console report.
json The result schema assay.result/3: one stable, versioned document that every command writes and that the other reporters are made from. The program writes this version only; assay version --json names it. Its description ships with assay_cli as lib/schema/assay_result_3.schema.json. A duplicated region carries its other copies in relatedLocations after its range: each a file and a range, at most 10, in the order of their paths and lines. No other violation has that field.
sarif SARIF 2.1.0, one run. Blocking violations and compile errors are error, advisory ones note. The fingerprint is in partialFingerprints. The other copies of a duplicated region are the relatedLocations of its result, with the ids 1, 2, … and the text another copy. No gate condition: a result is a finding at a place in the code.
gitlab GitLab code quality: blocker for a compile error, major for blocking, minor for advisory. No gate condition, for the same reason. An entry has one place, so the message of a duplicated region names its other copies, as in the GitHub and Markdown reports.
github GitHub workflow annotations. error for blocking violations and compile errors, for a gate condition that failed (title gate condition, no file) and for entries added to the baseline (title baseline growth, no file). notice for advisory violations and for every violation the baseline knows. What fails comes first, since GitHub caps the number of annotations. The verdict line comes last and counts the failed gate conditions and the entries added to the baseline.
markdown One Markdown document for the summary of a step or a comment on a pull request: the verdict, why it fails and what to do next; the violations counted by tier; the configuration and compile errors; the gate conditions with the line coverage; with gate --compare-with, how the project moved since a snapshot; what the gate found besides (the first ten of each); and the first 50 violations, blocking first. 60,000 characters at most. See The summary in Markdown.
html The metric report as one self-contained page; metrics only.

check, gate, cross-file, assets and project-files print the same report for a person: titled boxes of one width, one empty line between two boxes. assay check --no-baseline on a project with three violations:

╭─ assay check ────────────────────────────────────────────────────────────────╮
│ Preset recommended │
│ Rules 109 │
│ Files 2 │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Violations ────────────────────────────────────────────────── 3 in 2 files ─╮
│ Line Rule Tier │
│ ───────────────────────────────────────── │
│ lib/greeting.dart 2 violations │
│ ✗ 2:45 avoid_non_null_assertion blocking │
│ ✗ 5:65 avoid_non_null_assertion blocking │
│ │
│ lib/prices.dart 1 violation │
│ ✗ 14:57 avoid_non_null_assertion blocking │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Rules ──────────────────────────────────────────────────────────────────────╮
│ Rule Tier Count │
│ ───────────────────────────────────────── │
│ avoid_non_null_assertion blocking 3 │
│ The '!' operator throws at run time when the value is null. │
│ → Handle the null case: test for null, or use '??', '?.' or a null-check │
│ pattern. │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ ✗ FAIL ─────────────────────────────────────────────────────────────────────╮
│ 3 blocking · 0 advisory · 2 of 2 files │
│ → Next: fix the blocking violations, then run `assay check` again. │
╰──────────────────────────────────────────────────────────────────────────────╯

From the top, each box where it has something to say:

  1. The head box, titled with the command: the preset, the rules or the checks that ran, the files and their scope (2 in the whole project, 1 changed, 3 in the given paths), and a row Switched off for the rules or checks the configuration switches off.
  2. ✗ Configuration errors: each error by its options file and its key, with its message below. Nothing is judged then.
  3. Not judged: each file not judged, such as one that does not compile, with its reasons and its compile errors.
  4. Violations, counted on the right (3 in 2 files): a table of the place (line:column), the rule and the tier, each file a sub-heading over its rows. What the gate says of a violation (in the baseline, fix available, in the baseline; blocks because its file was changed) follows its tier. A result of a whole file, such as an asset, has — in the place of its line. A message that differs from one violation of a rule to another stands under its row.
  5. A box for each rule whose results name other places of the same code, duplicated_code: every place of the same code in one numbered group, by its file, its line range and its size, the largest group first, and how to fix it once below the groups. A place that only a listed result names, such as one in the baseline, is dim. The rule’s violations are not in Violations then. See Duplicated code.
  6. Rules, or Checks for the checks across files, of the assets and of the project files: each rule that has a violation once, with its tier and its count, and below it its message and how to fix it (→).
  7. The boxes of the gate and of the whole-project checks: the baseline with its size, what the run removed and its growth records; the entries added to the baseline; new suppressions; new coverage-ignore comments; configuration changes; the gate conditions with the line coverage; the checks that failed; the files not checked.
  8. The verdict box, ✓ PASS or ✗ FAIL: the counts; the violations the baseline knows that the report does not list, and where they are listed; what to do next (→ Next:); what the run removed from the baseline; and for the project judgement of the gate, the line on the files no change touched. Below it stand the notes of the run, such as how long the checks took and where the full report is.

A clean project is the head box and the verdict box. The full report of the gate is the same report in the plain form, 100 columns wide, with every violation listed and each one the baseline knows marked.

Width. On a terminal the boxes are as wide as the terminal, kept between 60 and 120 columns. In a pipe, a CI log or a file they are 100 columns wide. A path, a message or a name too long for its column wraps inside it, so no line is wider than its box.

Form. On a terminal the frames and marks are Unicode (✗ blocking, ! advisory, ✓, →, ·), with colour: blocking red, advisory yellow, the verdict green or red, the frames dim. Where NO_COLOR is set, the same without colour. In a pipe, a CI log or a file, and with --color never, the plain form: ASCII only and no escape code, the frames drawn with +, - and |, and the marks x, !, ok, -> and *. The same run in a pipe:

+- assay check ------------------------------------------------------------------------------------+
| Preset recommended |
| Rules 109 |
| Files 2 |
+--------------------------------------------------------------------------------------------------+
+- Violations ---------------------------------------------------------------------- 3 in 2 files -+
| Line Rule Tier |
| ----------------------------------------- |
| lib/greeting.dart 2 violations |
| x 2:45 avoid_non_null_assertion blocking |
| x 5:65 avoid_non_null_assertion blocking |
| |
| lib/prices.dart 1 violation |
| x 14:57 avoid_non_null_assertion blocking |
+--------------------------------------------------------------------------------------------------+
+- Rules ------------------------------------------------------------------------------------------+
| Rule Tier Count |
| ----------------------------------------- |
| avoid_non_null_assertion blocking 3 |
| The '!' operator throws at run time when the value is null. |
| -> Handle the null case: test for null, or use '??', '?.' or a null-check pattern. |
+--------------------------------------------------------------------------------------------------+
+- x FAIL -----------------------------------------------------------------------------------------+
| 3 blocking * 0 advisory * 2 of 2 files |
| -> Next: fix the blocking violations, then run `assay check` again. |
+--------------------------------------------------------------------------------------------------+

metrics, fix, init, config, baseline and trend draw their own output in the same boxes, at the same width and in the same forms; each command’s page shows it.

Code check, gate metrics, cross-file, assets, project-files, fix trend
0 Pass. Could run, whatever was found. Read one snapshot at least.
1 Fail. — —
2 A configuration error or a usage error, such as a --coverage report that cannot be read, or --compare-with given no path. The same. A usage error: no path, a path that names nothing or no regular file or directory, or no snapshot left to show. Only the snapshots of the latest snapshot’s package are shown; those of other packages, those of a newer version and what cannot be read are passed by and counted.
3 assay could not run, or a report file or a snapshot could not be written. The other reports are still written, and standard error names the path and shows the verdict. The same. A report file could not be written; the other reports are still written.
  • check fails on a blocking violation that is not in the baseline, or on a file that does not compile. A passing check is not a passing gate: check does not see the SDK lints.
  • init exits with 2 where it refused something it was asked for, such as an options file that is not YAML.
  • A program sent Ctrl-C ends with 130; sent the request to terminate, with 143.
  • The hooks of the agent plugin always exit with 0, whatever the gate answers: see The gate and agent setup.

Each command page has the exact cases of its codes.

The Dart files of a project are every Dart file below the package root that the configuration does not exclude, except in two kinds of directory:

  • a directory directly under the root whose name starts with a dot;
  • the directories of tools and version control, at any depth: .dart_tool, .pub-cache, .fvm, .symlinks, .plugin_symlinks, .git, .hg, .svn.

A dot directory inside a source directory, such as lib/.impl, is judged by the program but not analysed by the analyzer, so the editor shows nothing there.

v1 judges one analysis root per run: the directory the command runs in. In a pub workspace, run the commands in each member package.