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.22k stars 1.57k forks source link

easy way to customize the diagnostic severity of all lint rules #55599

Open DetachHead opened 6 months ago

DetachHead commented 6 months ago

i originally raised https://github.com/Dart-Code/Dart-Code/issues/5058, @DanTup suggested that i raise it here instead:

Is your feature request related to a problem? Please describe. i have my CI set up to fail on all analyzer diagnostics, but many of them are displayed in vscode as "information":

image

"information" implies that it's not a problem, but since the CI will fail if this code is committed, i want it to show as a warning or an error.

also, information diagnostics do not show up on the file name, but warnings and errors do:

image

Describe the solution you'd like an option to change the severity of diagnostics

as discussed there, the solution ended up being to duplicate the list of rules i have enabled in my project, like so:

analysis_options.yaml ```yaml linter: rules: prefer_single_quotes: true avoid_unused_constructor_parameters: true avoid_dynamic_calls: true avoid_annotating_with_dynamic: false literal_only_boolean_expressions: true prefer_final_locals: true prefer_final_parameters: true prefer_foreach: true prefer_if_elements_to_conditional_expressions: true prefer_interpolation_to_compose_strings: true prefer_mixin: true public_member_api_docs: false require_trailing_commas: true sized_box_shrink_expand: true sort_child_properties_last: true sort_constructors_first: false sort_unnamed_constructors_first: true tighten_type_of_initializing_formals: true unawaited_futures: true unnecessary_await_in_return: true unnecessary_constructor_name: true unnecessary_lambdas: true unnecessary_late: true unnecessary_null_aware_assignments: true unnecessary_null_checks: true unnecessary_nullable_for_final_variable_declarations: true unnecessary_parenthesis: true unnecessary_raw_strings: true use_colored_box: true use_decorated_box: true use_enums: true use_if_null_to_convert_nulls_to_bools: true use_is_even_rather_than_modulo: true use_late_for_private_fields_and_variables: true use_named_constants: true use_raw_strings: true use_setters_to_change_properties: true use_string_buffers: true use_super_parameters: true use_test_throws_matchers: true use_to_and_as_if_applicable: true depend_on_referenced_packages: true secure_pubspec_urls: true sort_pub_dependencies: true avoid_void_async: true analyzer: errors: prefer_single_quotes: warning avoid_unused_constructor_parameters: warning avoid_dynamic_calls: warning literal_only_boolean_expressions: warning prefer_final_locals: warning prefer_final_parameters: warning prefer_foreach: warning prefer_if_elements_to_conditional_expressions: warning prefer_interpolation_to_compose_strings: warning prefer_mixin: warning require_trailing_commas: warning sized_box_shrink_expand: warning sort_child_properties_last: warning sort_constructors_first: false sort_unnamed_constructors_first: warning tighten_type_of_initializing_formals: warning unawaited_futures: warning unnecessary_await_in_return: warning unnecessary_constructor_name: warning unnecessary_lambdas: warning unnecessary_late: warning unnecessary_null_aware_assignments: warning unnecessary_null_checks: warning unnecessary_nullable_for_final_variable_declarations: warning unnecessary_parenthesis: warning unnecessary_raw_strings: warning use_colored_box: warning use_decorated_box: warning use_enums: warning use_if_null_to_convert_nulls_to_bools: warning use_is_even_rather_than_modulo: warning use_late_for_private_fields_and_variables: warning use_named_constants: warning use_raw_strings: warning use_setters_to_change_properties: warning use_string_buffers: warning use_super_parameters: warning use_test_throws_matchers: warning use_to_and_as_if_applicable: warning depend_on_referenced_packages: warning secure_pubspec_urls: warning sort_pub_dependencies: warning avoid_void_async: warning ```

this isn't ideal because enabling a new rule requires specifying it twice. it would be nice if there was an option to set the diagnostic severity for all lint rules.

bwilkerson commented 6 months ago

While this would be a useful feature to add, it's fairly low on our priority list at the moment so I don't know whether we'll be able to get to it.