Skip to content

cascade_invocations false positive when used on different class field #58944

Closed
@karabanovbs

Description

@karabanovbs

Describe the issue
In example below I have cascade_invocations warning. But method was called on different object.

To Reproduce

class ClassA {
  void method() {}
}

class ClassB {
  final ClassA field;

  ClassB(this.field);
}

void main() {
  final oldClass = ClassB(ClassA());
  final newClass = ClassB(ClassA());

  oldClass.field
    ..method()
    ..method();

  // cascade_invocations warning
  newClass.field
    ..method()
    ..method();
}

Expected behavior
no warning

Additional context
cascade_invocations warning

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work ondevexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.linter-false-positiveIssues related to lint rules that report a problem when it isn't a problem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions