Skip to content

analysis_options is "everything or nothing" for generated code #59994

Open
@JCKodel

Description

@JCKodel

Generated code (through build_runner or whatever) often have analysis issues.

Usually, on our own code, we regulate those issues through analysis_options.yaml.

Since the generated code is uneditable and we cannot control how it is generated, we often need to ignore some rules just on generated code, which is impossible.

If we use the exclude key to exclude **.g.dart, then errors do not appear anymore (example: some class that is referenced in generated files and are not imported through import 'class.dart'; just doesn't appear on VSCode problems window (you will only know about them when you try to build).

So:

  1. Stop ignoring "ERRORS" just because the file is in the exclude section of analysis_options.yaml. It doesn't make sense whatsoever to ignore COMPILE errors!

  2. Allow us to use a different list of rules for some path, in analysis_options.yaml, so I can ignore unused_element (or whatever) for **.g.dart, but not for my files.

  3. Since part and part of infers that we're using multiple files as one, make // ignore_for_file: unused_element work on the root file (i.e.: the file that imports the .g.dart file through part 'some.g.dart';)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onanalyzer-analysis-optionsarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-ux

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions