Skip to content

Configuration

You configure assay in one file, the project’s root analysis_options.yaml. It has two parts: include: picks a preset, and the assay: key holds your changes to it.

analysis_options.yaml
# 1. The preset: which rules are on, and their limits.
include: package:assay_lints/recommended.yaml
# 2. Your changes, all under one key.
assay:
rules:
no_magic_number: false # switch a rule off
max_function_length: {max: 80} # change a limit
  • Only the root file counts. That is the analysis_options.yaml in the directory the commands run in, with the files it includes. A nested options file in a subdirectory cannot configure assay, and there is no separate configuration file.
  • Check every edit with assay config. The editor and dart analyze cannot show a configuration error. assay config prints what is in effect, and every error.
To See
switch a rule off Configuring rules
set a rule parameter Configuring rules
change a limit Configuring metrics
make the gate judge coverage or duplication Configuring metrics
switch a check off, or tune it Configuring checks
silence one rule in some paths Excluding code
leave paths out of everything Excluding code
silence a rule at one place Suppressions
move to another preset Presets

The assay: key has six keys, and no other:

Key What goes there
exclude Paths that nothing judges. See Excluding code.
rules One entry per rule, by its name. See Configuring rules; for the limit of a limit rule, Configuring metrics.
cross_file One entry per cross-file check. See Configuring checks.
assets One entry per asset check. See Configuring checks.
project_files One entry per project-file check. See Configuring checks.
gate Thresholds on coverage and ceilings on duplication. See Gate conditions.

Every key, in one file:

include: package:assay_lints/recommended.yaml
assay:
exclude: ["lib/legacy/**"] # where no rule, metric or check judges
rules:
max_function_length: {max: 80} # a rule parameter
no_magic_number: false # a rule switched off
avoid_dynamic: {exclude: ["lib/interop/**"]}
cross_file:
unused_files: {exclude: ["tool/templates/**"]}
duplicated_code: {min_tokens: 150} # a key of its own of a check
assets:
unused_assets:
exclude: ["assets/native/**"]
oversized_assets:
max_kb: {3.0x: 2000}
missing_asset_variants:
variants: [2x]
project_files:
secret_in_shipped_file:
exclude: ["assets/fixtures/**"]
debuggable_app: false # a check of security switched off
gate:
coverage:
min_on_new_lines: 80 # a gate condition, judged only on a coverage report
duplication:
max_overall: 5 # judged only where the gate is asked to judge duplication

Keys are merged one by one (How the files combine), and the value of a key you write replaces the preset’s, or the default, as a whole: a list is never added to. The one exception is max_kb of oversized_assets, which is laid over its default resolution by resolution.

assay follows include: chains as the analyzer does, package: addresses among them.

  • The rule map, the rules the preset switches on, comes from the preset alone: no other file can add a rule to it.
  • The assay: key is merged key by key: the project’s values over the preset’s, and over those of any file in between.

assay config prints the configuration in effect, as assay reads it:

╭─ assay config ───────────────────────────────────────────────────────────────╮
│ Preset recommended │
│ Options analysis_options.yaml │
│ Versions assay_cli 0.1.0-dev = assay_lints 0.1.0-dev ✓ │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Rules ──────────────────────────── 109 on · 0 off · 38 not in the rule map ─╮
│ Rule Tier │
│ ───────────────────────────────────────────────────── │
│ ● avoid_dynamic blocking │
│ … │
│ ● max_function_length advisory │
│ exclude: ["test/**","integration_test/**","test_driver/**"] │
│ max: 60 │
│ … │
│ │
│ Not in the rule map 38 rules │
│ ○ max_cognitive_complexity advisory │
│ … │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Excluded paths ──────────────────────────────────────────────── 6 patterns ─╮
│ Engine Patterns │
│ ──────────────────────────────────────────── │
│ assay **/*.g.dart **/*.freezed.dart +4 │
│ analyzer none │
╰──────────────────────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────────────────────────╮
│ ✓ No configuration errors │
╰──────────────────────────────────────────────────────────────────────────────╯

It shows:

  • in the head box, the preset, the root options file and the two versions;
  • in the box Rules, each rule with its tier, ● for on and ○ for off (+ and - in the plain form): a rule switched off with the file that switches it off, the rules of a higher preset last, under the sub-heading Not in the rule map, and a rule parameter only where it is not at its default;
  • a box for the cross-file, asset and project-file checks where you changed one: a check switched off, with the file that does it, or a key not at its default;
  • a box for the gate conditions you set a key of;
  • a box for the excluded paths, cut short;
  • in the last box, every configuration error, or that there is none.

config exits with 0, and with 2 when the configuration is in error.

assay config --verbose prints everything, each value with the file it came from: the file of the rule map, every rule parameter of every rule, every key of every check and of the gate conditions, and every excluded pattern. assay config shows two parts of that output.

A configuration error names the options file and the key. Every command that reads the configuration stops on it with exit code 2, and judges nothing. At the gate it is one of the four ways to fail, so breaking the configuration is never a way through.

The editor and dart analyze cannot show a configuration error. There the plugin takes the preset’s value for the entry in error, and never switches a rule off because of it. Run assay config after you edit the options file.

Every configuration error, with an example of its message

The messages are shown as assay config prints them; the program writes names in backticks, left out here.

Error Example of the message
The options file is not YAML, or not a map The file is not YAML: While parsing a flow sequence, expected ',' or ']'.
An include: that cannot be read, or that includes itself The file package:assay_lints/nonesuch.yaml cannot be read. / The file … includes itself.
The project’s packages are not fetched, so the preset cannot be read The file package:assay_lints/recommended.yaml cannot be read. Run dart pub get or flutter pub get; the Next: row of every command’s console report, and at turn end the message to the agent, name them.
No preset adopted No preset is adopted, so assay judges nothing. Run assay init to adopt a preset.
A plugins.assay entry outside a preset The project's own file is not a preset and replaces the entry of the adopted preset core, which drops its rule map. Remove it, and switch a rule off or tune it under the top-level assay: key. An entry with no plugin source has its own wording: it has no effect for the analyzer, and is not allowed all the same.
A file named like a preset that is not one This file is named like the preset core but differs from package:assay_lints/core.yaml in more than the source of the plugin, so it is not a preset, and only a preset carries a plugins.assay entry. …
A file named like a preset that cannot be compared with it Where the shipped preset cannot be read, assay cannot tell whether such a file is a copy of it, and says so; it never passes silently.
A key the assay: key does not have The assay: key has no key rulez. Its keys are exclude, rules, cross_file, assets, project_files and gate.
A key assay.gate, assay.gate.coverage or assay.gate.duplication does not have The assay.gate key has no key coverge. Did you mean coverage? / The assay.gate key has no key complexity. Its keys are coverage and duplication. / The assay.gate.coverage key has no key threshold. Its keys are min_on_new_lines, min_overall and small_change. / The assay.gate.duplication key has no key min_overall. Did you mean max_overall?
A name of no rule assay has no rule named max_function_lenght. Did you mean max_function_length?
A name of no cross-file check assay has no cross-file check named unused_filez. Did you mean unused_files?
A name of no asset check assay has no asset check named unused_asset. Did you mean unused_assets?
A name of no project-file check assay has no project-file check named debugable_app. Did you mean debuggable_app?
A rule parameter the rule does not have The rule max_function_length has no rule parameter named maximum. (For a check: A cross-file check has no key maximum. Its keys are enabled and exclude., The cross-file check duplicated_code has no key max_tokens. Its keys are enabled, exclude, min_tokens and min_lines., The asset check oversized_assets has no key max_mb. Its keys are enabled, exclude, max_kb and image_extensions., A project-file check has no key allowed_hosts. Its keys are enabled and exclude., The project-file check cleartext_traffic_allowed has no key allowed_host. Its keys are enabled, exclude and allowed_hosts.)
A value of the wrong type The value has the wrong type: expected a whole number, zero or more. (For a threshold or a ceiling of a gate condition, also over 100 or negative: … expected a number from 0 to 100.; for min_tokens of duplicated_code under 20: … expected a whole number, 20 or more., for its min_lines under 1: … expected a whole number, 1 or more. A number that is not whole, such as 100.0, or a text is the wrong type too.)
enabled: true for a rule the preset does not hold The adopted preset core does not contain the rule avoid_late, so enabled: true cannot switch it on. The preset recommended contains it.

The preset’s plugins.assay entry names the plugin, its version and the complete map of the rules the preset switches on. The analyzer reads the entry nearest the project and drops the one before it whole. So an entry you write, even one meant only to switch one rule off, replaces the preset’s and takes its whole rule map with it.

That is why assay reports every such entry outside a preset as a configuration error, with or without a preset adopted. Switch a rule off under assay: instead.

A rule switched off under assay: is still on for the analyzer, because the preset’s rule map still names it.

  • What you see: nothing. The plugin reads the assay: key itself and reports nothing for that rule, in the editor and in dart analyze, and neither does assay’s own engine.
  • Where the views differ: a tool that asks the analyzer which diagnostics are on still names the rule, and a suppression that names it is still accepted. The SDK lint unnecessary_ignore does not report such a suppression as unneeded (checked on Dart 3.11.3: it reports no suppression that names a plugin’s rule).
  • assay’s view is the one that counts, and assay config prints it.
  • The gate is not affected: it takes assay’s rules from assay’s engine, which reads the same key. A rule switched off during an agent’s session is listed at turn end as a configuration change (assay.rules.no_magic_number.enabled: true -> false); it does not fail the gate.

analyzer: errors: does not reach assay’s rules, in either host. A severity written there for an assay rule, by its bare name or as assay/<rule>, ignore included, leaves its violations as they are in the editor, in dart analyze and in assay’s own engine. The analyzer warns of the key with unrecognized_error_code. (Checked on Dart 3.11.3 and 3.14.1 with max_cognitive_complexity: ignore in both forms.) Switch a rule off under assay: instead.