In the editor
assay’s rules judge your code where you write it: the analyzer plugin shows their violations in the editor and in dart analyze. Nothing is installed in the editor: the preset you include brings the plugin.
The analyzer plugin
Section titled “The analyzer plugin”The preset names the analyzer plugin, the package assay, at exactly the version of assay_lints (Getting started). The analysis server fetches the plugin the first time it starts for the project, apart from your dependencies. That first start compiles the plugin, once per project directory.
From then on an editor that uses the Dart analysis server, such as VS Code, IntelliJ or Android Studio, shows the violations of assay’s rules, and so does dart analyze. Everyone who works from one lockfile sees the same rules there (Managing versions).
What the editor shows
Section titled “What the editor shows”In the editor and in dart analyze |
In the command-line program | |
|---|---|---|
| The violations of the rules, the ten rules of security among them | yes | yes: assay check, assay gate |
| A value over the limit of a metric, as the violation of its limit rule | yes | yes |
| Fixes | at the violation, one at a time | assay fix, every available fix in one run |
| Suppression comments | honoured | honoured |
What you write under the assay: key |
applied: a rule switched off is silent, and a rule parameter or an exclude is in effect |
applied |
| Configuration errors | not shown | assay config, and every command that reads the configuration |
| The cross-file, asset and project-file checks | not shown | assay cross-file, assay assets, assay project-files |
| The metric report, with every value | not shown | assay metrics |
| The gate and the baseline | not shown | assay gate, assay baseline |
The checks run in the command-line program only: nothing of them appears in the editor or in dart analyze. The plugin does not read the baseline either, so the editor shows a violation the baseline knows like any other. 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.
Quick fixes
Section titled “Quick fixes”47 rules have a fix. The editor offers it in its menu of actions at the violation:
- VS Code:
Cmd+.on macOS,Ctrl+.elsewhere. - IntelliJ and Android Studio:
Option+Enteron macOS,Alt+Enterelsewhere.
Each fix is defined once, next to its rule, so the editor and assay fix apply the same edit. The SDK’s bulk fix command does not apply fixes that come from a plugin; assay fix applies them across the project. See Fixes.
Suppression comments
Section titled “Suppression comments”A suppression is the analyzer’s own comment, // ignore: for one place and // ignore_for_file: for a file, so the editor honours it for a rule of assay as for an SDK lint. A rule is named with the prefix, assay/<rule>, or by its name alone: the analysis server applies only the prefixed form to a plugin’s rule, and assay’s plugin applies the bare form itself, so the result is the same. The blanket form // ignore: type=lint silences every rule of assay there too.
One rule differs between the editor and the command-line program. A suppression that names suppression_requires_justification hides its violation in the editor and in dart analyze, while assay check and the gate ignore such a suppression and report it. See Suppressions.
Configuration in the editor
Section titled “Configuration in the editor”The plugin reads the assay: key of the root analysis_options.yaml itself, so a rule you switch off there reports nothing in the editor and in dart analyze.
- A configuration error is not shown. The editor and
dart analyzecannot show one. The plugin takes the preset’s value for the entry in error, and never switches a rule off because of it. Runassay configafter you edit the options file. - The analyzer’s own view differs. A rule switched off under
assay:is still on for the analyzer, and a severity written underanalyzer: errors:does not reach assay’s rules: see Differences from the analyzer.