Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DetachHead opened this issue Apr 30, 2024 · 1 comment
Open

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

DetachHead opened this issue Apr 30, 2024 · 1 comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@DetachHead
Copy link

i originally raised Dart-Code/Dart-Code#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
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.

@DanTup DanTup added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Apr 30, 2024
@bwilkerson bwilkerson added the P3 A lower priority bug or feature request label Apr 30, 2024
@bwilkerson
Copy link
Member

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.

@srawlins srawlins added the type-enhancement A request for a change that isn't a bug label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants