Skip to content

Add a lint for expect when the expected and actual arguments don't have compatible types #58384

@bwilkerson

Description

@bwilkerson

It would be nice to have a lint to catch uses of the expect from package:test where the expected and actual arguments do not have compatible types. Right now both parameters are typed as dynamic so the type system doesn't really help. But it's uncommon for the objects to be equal if the types are not at least assignable. For example,

expect(3, ''); // LINT

When omitting types from local variables it's easy for changes elsewhere to cause the variable's type to change, which can lead to test failures. It would be nice to find these during analysis rather than during test execution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagelinter-lint-proposaltype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions