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.28k stars 1.58k forks source link

`dart fix` needs a `verbose` option #57014

Open firephreek opened 3 weeks ago

firephreek commented 3 weeks ago

Running dart fix --dry-run returns the following information, which, on its own, isn't helpful in identifying actual problems I might want to address/correct. Adding a verbose option to include the associated information found running dart analyze would be more helpful.

dart fix

$ dart fix --dry-run

Computing fixes in my_app (dry run)... 3.1s

4 proposed fixes in 3 files.

lib/blocs/trial_recorder/bloc.dart
  unused_catch_stack • 1 fix

lib/views/lab/configuration_view.dart
  annotate_overrides • 1 fix
  sized_box_for_whitespace • 1 fix

lib/views/trial/playback_controls.dart
  unused_import • 1 fix

dart analyze

$ dart analyze
Analyzing physics_workbench...         1.8s

warning • lib/blocs/trial_recorder/bloc.dart:28:17 • The stack trace variable 's' isn't used and can be removed. Try removing the stack trace variable, or using it. • unused_catch_stack
warning • lib/views/trial/playback_controls.dart:6:8 • Unused import: 'common.dart'. Try removing the import directive. • unused_import
   info • lib/views/lab/configuration_view.dart:10:10 • The member 'build' overrides an inherited member but isn't annotated with '@override'. Try adding the '@override' annotation. • annotate_overrides
   info • lib/views/lab/configuration_view.dart:15:9 • Use a 'SizedBox' to add whitespace to a layout. Try using a 'SizedBox' rather than a 'Container'. • sized_box_for_whitespace

4 issues found.

General info

Project info

Process info

Memory CPU Elapsed time Command line
63 MB 0.0% 06:45 dart devtools --machine --dtd-uri=ws:/cHfX8RemmD77FPbt
64 MB 0.0% 1-12:03:39 dart devtools --machine --dtd-uri=ws:/dVIDFBz6XYb6xGfB
21 MB 0.0% 21-01:16:57 dart devtools --machine --dtd-uri=ws:/uE8BvAql3YYrbpgR
654 MB 1.2% 1-12:03:43 dart language-server --client-id=Android-Studio --client-version=AI-242.21829.142 --protocol=analyzer
520 MB 6.0% 01:48 dart language-server --client-id=Android-Studio --client-version=AI-242.21829.142 --protocol=analyzer
20 MB 0.0% 21-01:16:57 dart tooling-daemon --machine
82 MB 0.0% 1-12:03:39 dart tooling-daemon --machine
81 MB 0.1% 06:45 dart tooling-daemon --machine
81 MB 4.1% 02:01 flutter_tools.snapshot daemon
dart-github-bot commented 3 weeks ago

Summary: The user requests a verbose option for dart fix to include the output from dart analyze, providing more context for the proposed fixes. Currently, dart fix --dry-run only shows a list of fixes without the underlying analysis information.

bwilkerson commented 3 weeks ago

If we were to implement this, one question would be whether to show diagnostics for which there is no fix. My first guess is no because the unfixable diagnostics aren't relevant to the question of whether to re-run it with an --apply flag.