The dart analyze
command (previously called dartanalyzer
)
performs the same static analysis
that you get when you use an IDE or editor that has Dart support.
Here’s an example of performing static analysis over all the Dart files under the current directory:
$ dart analyze
You can customize how the analyzer treats warnings and info-level issues.
Normally the analyzer reports failure when it finds any errors or warnings,
but not when it finds info-level issues.
You can customize this behavior using the
--fatal-infos
and --no-fatal-warnings
flags.
For example, to make the analyzer fail when any issue is found —
as you might want in continuous integration (CI) testing —
add the --fatal-infos
flag:
$ dart analyze --fatal-infos
You can add a directory argument:
$ dart analyze bin
To customize the analysis, use an analysis options file or special comments in Dart source code, as described in Customizing static analysis.
For information on command-line options, use the --help
flag:
$ dart analyze --help