Revise dartanalyzer docs to indicate that it is not for general

consumption.

Change-Id: Iec112f13ddeaa2fa43650bfc614ea786b2fff2bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250768
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Janice Collins <jcollins@google.com>
This commit is contained in:
Janice Collins 2022-07-06 19:27:50 +00:00 committed by Commit Bot
parent b27709f1b8
commit 1c45191c89
2 changed files with 18 additions and 86 deletions

View file

@ -1,16 +0,0 @@
# Changelog
## 1.1.1
- Removed outmoded `--url-mapping` command line option.
## 1.1.0
- New `--lints` command line option.
## 0.0.
## 0.0.1
- Initial version

View file

@ -1,79 +1,27 @@
# dartanalyzer
Use _dartanalyzer_ to statically analyze your code at the command line,
checking for errors and warnings that are specified in the
[Dart Language Specification](https://dart.dev/guides/language/spec).
DartPad, code editors, and IDEs such as Android Studio and VS Code
use the same analysis engine that dartanalyzer uses.
_dartanalyzer_ used to be the tool for statically analyzing dart code
at the command line. However, this tool has been replaced with
`dart analyze` for this purpose in current SDKs and will no longer
be published on pub.
Do not depend on the command line interface or other semantics in
this directory as it is now an internal tool for SDK development, used
as the `dart2analyzer` "compiler" for `tools/test.py` in the SDK.
It is configured as part of the test runner,
[here](https://github.com/dart-lang/sdk/blob/main/pkg/test_runner/lib/src/compiler_configuration.dart).
## Basic usage
Run the analyzer from the top directory of the package.
Here's an example of analyzing a Dart file.
Run `dartanalyzer` from the test tool to validate analysis
conclusions on language samples in the testing directory.
From the root of the SDK:
```
dartanalyzer bin/test.dart
tools/test.py --build --use-sdk -c dart2analyzer co19_2 language_2
```
## Options
The following are the most commonly used options for dartanalyzer:
* `--packages=`
Specify the path to the package resolution configuration file.
For more information see
[Package Resolution Configuration File](https://github.com/lrhn/dep-pkgspec/blob/master/DEP-pkgspec.md).
* `--package-warnings`
Show warnings not only for code in the specified .dart file and
others in its library, but also for libraries imported with `package:`.
* `--options=`
Specify the path to an analysis options file.
* `--[no-]lints`
Show the results from the linter.
* `--[no-]hints`
Don't show hints for improving the code.
* `--version`
Show the analyzer version.
* `-h` _or_ `--help`
Show all of the command-line options.
See the[Customizing static analysis
guide](https://dart.dev/guides/language/analysis-options) for further ways to
customize how dartanalyzer performs static analysis, and how it reports its
findings.
The following are advanced options to use with dartanalyzer:
* `--dart-sdk=`
Specify the directory that contains the Dart SDK.
* `--fatal-warnings`
Except for type warnings, treat warnings as fatal.
* `--format=machine`
Produce output in a format suitable for parsing.
* `--ignore-unrecognized-flags`
Rather than printing the help message, ignore any unrecognized command-line
flags.
* `--url-mapping=libraryUri,/path/to/library.dart`
Use the specified library as the source for that particular import.
This will build the Dart VM and compile dartanalyzer into a snapshot, then use
that snapshot while analyzing those directories under `testing/`. Without
`--use-sdk`, test.py will use the source code version of `dartanalyzer`
instead of the compiled one, which can be useful for debugging.