Skip to content

Latest commit

 

History

History
89 lines (67 loc) · 2.61 KB

analyze-tool.md

File metadata and controls

89 lines (67 loc) · 2.61 KB

AnalyzeTool

Statically analyzes the current project by running the dartanalyzer.

Usage

This tool is included in the coreConfig and is runnable by default via ddev analyze.

// tool/dart_dev/config.dart
import 'package:dart_dev/dart_dev.dart';

final config = {
  'analyze': AnalyzeTool() // configure as necessary
};

Default behavior

By default this tool will run dartanalyzer . which will analyze all dart files in the current project.

Configuration

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.

Excluding files from analysis

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.

Command-line options

$ ddev help analyze