dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.11k stars 1.57k forks source link

Analyzer `--fatal-infos` flag issues #56562

Open sgrekhov opened 1 month ago

sgrekhov commented 1 month ago

It's not clear how --fatal-infos analyzer flag works. If to ask for a help we will see the following:

$dart analyze --help
Analyze Dart code in a directory.

Usage: dart analyze [arguments] [<directory>]
-h, --help                   Print this usage information.
    --fatal-infos            Treat info level issues as fatal.
    --[no-]fatal-warnings    Treat warning level issues as fatal.
                             (defaults to on)

Run "dart help" to see global options.

My first intuitive understanding was that with this flag all info level messages should be turned into errors. But, after some research with @eernstg it was found that this flag affects exit code only. If it is true and intended, please update the help message to reflect this fact.

The second. I have the following test.

// SharedOptions=--fatal-infos

@deprecated
String variable = "x";

main() {
  print(variable);
}

I would expect that test runner should report an error here (use of the deprecated varianle is an info-level issue, but with // SharedOptions=--fatal-infos the test runner should report this test as a failing. But it doesn't (there is no actual test from below in co19 repositiry, it just my local sandbox).

$ python3 tools/test.py -n analyzer-asserts-linux co19/LanguageFeatures/Augmentation-libraries/metadata_A01_t01
No build targets found.
Test configuration:
    analyzer-asserts-linux(architecture: x64, compiler: dart2analyzer, mode: release, runtime: none, system: linux, enable-asserts, use-sdk)
Suites tested: co19
[00:03 | 100% | +    1 | -    0]

=== All 1 test passed ===

Please clarify how --fatal-infos is intended to work? Should the test runner report an error in some test contain --fatal-info and info-level issue?

srawlins commented 1 month ago

When I run your script through dart analyze --fatal-infos, I get an exit code of 1. So the second part of this issue is not with the analyzer, but with the test runner. Please open a separate issue.

For the first part, it would be good to clarify what 'fatal' means, in our help text.

sgrekhov commented 1 month ago

When I run your script through dart analyze --fatal-infos, I get an exit code of 1. So the second part of this issue is not with the analyzer, but with the test runner. Please open a separate issue.

https://github.com/dart-lang/sdk/issues/56575