Skip to content

Incorrect cascade_invocations lint #35469

Closed
@zanderso

Description

@zanderso

The analyzer cascade_invocations lint asks for cascading across different references:

test.dart:

class A {
  int f;
  int g;
}

class B {
  final A a = A();
}

void main() {
  final B b1 = B();
  final B b2 = B();

  b1.a
    ..f = 1
    ..g = 1;
  b2.a.f = 2;
}

With analysis_options.yaml:

linter:
  rules:
    - cascade_invocations

Gives

$ dartanalyzer ../cascade_bug_test.dart 
Analyzing ../cascade_bug_test.dart...
  lint • Cascade consecutive method invocations on the same reference at /usr/local/google/home/zra/dart/cascade_bug_test.dart:17:3 • cascade_invocations
1 lint found.

Where line 17 is b2.a.f = 2; where b2 is a different reference and can't be cascaded with the b1.a cascade.

Metadata

Metadata

Assignees

No one assigned

    Labels

    customer-fuchsiadevexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions