Skip to content

cascade_invocations false positives #58043

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

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

cascade_invocations false positives #58043

davidmorgan opened this issue Oct 29, 2019 · 2 comments
Labels
customer-google3 devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-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:

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

My personal preference is for #57148; 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 linter-false-positive labels Oct 29, 2019
@jamesderlin
Copy link
Contributor

jamesderlin commented Aug 13, 2020

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

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
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 18, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-google3 devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-false-positive type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants