Skip to content

avoid_unnecessary_return_variable incorrectly triggers for variables used in multiple return paths #225

@xJac0b

Description

@xJac0b
String test() {
  final someCondition = 1 == 1;
  final a = 'test';
  if (someCondition) return a;

  return 'something $a';
}

Expected behavior:
No lint - the variable a is used in multiple return statements, so it is not unnecessary.

Actual behavior:
The lint triggers on return a; incorrectly suggesting that the variable is only used in a single return.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions