-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Currently in the analyzer we have (approximately) the following diagnostic categories:
- CompileTimeErrorCode ("error")
- StaticWarningCode ("warning")
- HintCode ("hint")
- LintCode ("lint")
(There are others like ParserErrorCode, TodoCode, FfiCode, etc, but the 4 above are the common, user-visible ones.)
We'd like to remove the HintCode category, and move all "hints" to be either "warnings" or "lints." They will mostly be moved to "warnings."
The categories differ from each other in their default severity (one of ERROR, WARNING, or INFO), and whether they are reported by default (or must be enabled via analysis_options.yaml):
| Category | Severity | Enabled-by-default? |
|---|---|---|
| CompileTimeErrorCode | ERROR |
Yes |
| StaticWarningCode | WARNING |
Yes |
| HintCode | INFO |
Yes |
| LintCode | INFO |
No |
What do these mean, practically? The difference is primarily in the behavior of dart analyze (used in presubmit checks, continuous integration, and perhaps by humans):
- If no diagnostics are reported by
dart analyze, its exit code is0. - An
INFO-severity diagnostic report does not move the exit code away from0. - A
WARNING-severity diagnostic report does move the exit code away from0. - An
ERROR-severity diagnostic report does move the exit code away from0.
Note also:
- The fatality of
WARNING-severity diagnostics can be changed with the--[no-]fatal-warningsflag. - The fatality of
INFO-severity diagnostics can be changed with the--[no-]fatal-infosflag. - The severity of any individual diagnostic (like
DEAD_CODEorUNUSED_IMPORTor any lint rule) can be changed inanalysis_options.yamlfrom its default to any of the others, orIGNORE.
This proposal is therefore a breaking change: "Hints" which are moved to be "warnings" will become fatal (by default) when reported by dart analyze. (Behavior will not change when --fatal-infos or --no-fatal-warnings is being used.)
Another significant change: users will also no longer get the protection from a "hint" which is moved to be an opt-in "lint" unless they explicitly enable it in their analysis_options.yaml file (or include another analysis options file which does so).
Historical note: We had more "static warnings" defined by the language in previous releases of Dart, but all but a handful of those have been dropped, and the language team has confirmed that it is "fair game" for tools like the analyzer to define their own "warnings."