dart-lang / sdk

The Dart SDK, including the VM, dart2js, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
9.98k stars 1.54k forks source link

Feature request: Add //ignore_all to ignore all warnings #43616

Open szotp opened 3 years ago

szotp commented 3 years ago

Dart already has an option for disabling one warning in a file, called //ignore_for_file. It is quite useful for generated code, since we don't care that much about readability. For example:

https://github.com/google/built_value.dart/blob/20fc5c92ceb8b31eb6bf46d6071a4c6e88af9c84/built_value_generator/lib/built_value_generator.dart#L62

https://github.com/dart-lang/protobuf/blob/870275500b2416100b852cb69854d47c44da93f5/protoc_plugin/test/goldens/service.pb#L6

But it would be much easier with //ignore_all, or perhaps //generated_code flag, that would silence all warnings.

Benefits: writing code generators would be easier. Many people don't bother about adding //ignore_for_file, but //ignore_all would be easy enough

maks commented 3 years ago

Hmm, I'm not sure about this proposal since it essentially duplicates the functionality of the existing exclude: in analysis_options.yaml expect it does so by placing the decision in the hands of the code gen package author rather than the end user of the generated code. My preference would to be to leave control with the user of the generated code, as they are the one who is running the analyzer and determining what rules are in their analysis_options.yaml config.

szotp commented 3 years ago

Personally I don't see much value in those warnings, as you can't really fix them yourself. Imagine if your own linter rules applied to all packages that you imported.

But an alternative solution would be //generated_code flag that can be then further configured in analysis_options, this could be useful for other purposes, like skipping dartfmt for these files.

srawlins commented 6 months ago

Maybe same issue as https://github.com/dart-lang/sdk/issues/53420