Skip to content

avoid_unnecessary_return_variable triggers when type promotion is needed #226

@andrew-bekhiet-solid

Description

@andrew-bekhiet-solid
T get<T>(String key) {
  final value = _map[key];
  
  if (value is T) {
    // local variable is promoted to T
    return value;
  }

  throw Exception('value is not of type $T');
}

Expected behavior

No lint

Actual behavior

The lint rule is triggered

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions