Skip to content

Proposal: unnecessary_pattern lintΒ #59616

@HosseinYousefi

Description

@HosseinYousefi

Consider this:

final foo = int.parse('1') == 1 ? '1' : null;
if (foo case final bar) {
  print(bar);
}

What we wanted to do is to check for foo's nullity, but actually we forgot to type ?. foo case final bar is unnecessary as it basically matches everything, it'd be good if we have a lint to warn us here.

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 packagetype-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