Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cascade_invocations false positives #1797

Closed
davidmorgan opened this issue Oct 29, 2019 · 2 comments
Closed

cascade_invocations false positives #1797

davidmorgan opened this issue Oct 29, 2019 · 2 comments
Labels
customer-google3 false-positive type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@davidmorgan
Copy link
Contributor

cascade_invocations currently fires for:

import 'dart:async';

void main() {
  var stream = StreamController().stream;
  var subscription = stream.listen(null);
  subscription.onData((value) { print(subscription); });
}

But it's impossible to use the cascade operator here because of the reference to subscriptions inside the lambda.

I see two paths forward:

#1 don't fire when there is a reference like this
#2 simpler: never fire when the first line is a variable declaration

My personal preference is for #2; I think splitting the declaration from operations on the variable is often beneficial to readability, and should be treated as a special case.

WDYT, please?

Thanks!

@pq pq added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) customer-google3 false-positive labels Oct 29, 2019
@jamesderlin
Copy link

jamesderlin commented Aug 13, 2020

This looks like the same thing I complained about in #1534.

Edit:
Looking again, similar, but not quite the same. There's a more general potential problem with mixing the cascade operator with assignments, but declarations are a more specialized (and probably more easily identifiable) situation.

@asashour
Copy link
Contributor

Is this still valid, I am unable to reproduce.

@pq pq closed this as completed Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-google3 false-positive type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants