|
| 1 | +# `dart fix` |
| 2 | + |
| 3 | +## What is it? |
| 4 | + |
| 5 | +`dart fix` is a command line tool and part of the regular `dart` tool. It is used |
| 6 | +to batch apply fixes for analysis issues. |
| 7 | + |
| 8 | +## How does it work? |
| 9 | + |
| 10 | +`dart fix` runs over your project looking for analysis issues. For each issue |
| 11 | +it checks whether there is an automated fix that can be applied. These fixes |
| 12 | +are generaly either in response to a lint or hint in your code, or part of |
| 13 | +upgrading your source to newer package APIs. |
| 14 | + |
| 15 | +For the first type of change, the fixes are generally in response to the set |
| 16 | +of lints and analysis configuration specified in your [analysis_options.yaml] |
| 17 | +file. |
| 18 | + |
| 19 | +The second type of change - upgrading to newer package APIs - is performed |
| 20 | +based on API changes defined for specific packages. This declarative definition |
| 21 | +of the API changes lives in a `fix_data.yaml` file in the package's `lib/` |
| 22 | +directory (documentation forthcoming). |
| 23 | + |
| 24 | +## Command line usage |
| 25 | + |
| 26 | +``` |
| 27 | +Fix Dart source code. |
| 28 | +
|
| 29 | +This tool looks for and fixes analysis issues that have associated automated |
| 30 | +fixes or issues that have associated package API migration information. |
| 31 | +
|
| 32 | +To use the tool, run one of: |
| 33 | +- 'dart fix --dry-run' for a preview of the proposed changes for a project |
| 34 | +- 'dart fix --apply' to apply the changes |
| 35 | +
|
| 36 | +Usage: dart fix [arguments] |
| 37 | +-h, --help Print this usage information. |
| 38 | +-n, --dry-run Show which files would be modified but make no changes. |
| 39 | + --apply Apply the proposed changes. |
| 40 | +
|
| 41 | +Run "dart help" to see global options. |
| 42 | +``` |
| 43 | + |
| 44 | +[analysis_options.yaml]: https://dart.dev/guides/language/analysis-options |
0 commit comments