Statically analyzes the current project by running the dartanalyzer
.
This tool is included in the
coreConfig
and is runnable by default viaddev analyze
.
// tool/dart_dev/config.dart
import 'package:dart_dev/dart_dev.dart';
final config = {
'analyze': AnalyzeTool() // configure as necessary
};
By default this tool will run dartanalyzer .
which will analyze all dart files
in the current project.
AnalyzeTool
supports one configuration option which is the list of args to
pass to the dartanalyzer
process:
// tool/dart_dev/config.dart
import 'package:dart_dev/dart_dev.dart';
final config = {
'analyze': AnalyzeTool()
..analyzerArgs = ['--fatal-infos', '--fatal-warnings']
};
Always prefer configuring the analyzer via
analysis_options.yaml
when possible. This ensures that other tools that leverage the analyzer or the analysis server benefit from the configuration, as well.
The analysis_options.yaml
configuration file
supports excluding files. However, there is an
open issue with the dartanalyzer
CLI because it does
not respect this list.
If your project has files that need to be excluded from analysis (e.g. generated
files), use the TuneupCheckTool
. It uses the
tuneup
package to run analysis instead of dartanalyzer
and it properly
respects the exclude rules defined in analysis_options.yaml
.
$ ddev help analyze