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

add in unawaited_futures #26

Open
bsutton opened this issue Dec 15, 2020 · 5 comments
Open

add in unawaited_futures #26

bsutton opened this issue Dec 15, 2020 · 5 comments

Comments

@bsutton
Copy link

bsutton commented Dec 15, 2020

# Too many false positives.
# Using the pedantic package for the unawaited function doesn't make code better readable
#
# pedantic: enabled
# https://dart-lang.github.io/linter/lints/unawaited_futures.html
# - unawaited_futures

As above the doco suggest this does produce false positive.

The converse issues is that diagnosing a missing await can be a very complex issue.

I personally am happy to wear the burden of having to unawait methods to avoid bugs especially bugs that are hard to solve.

I really think this should be part of the default package.

I just added this to a small project (6000 lines) and it fixed three bugs and returned no false positives.

@passsy
Copy link
Owner

passsy commented Dec 16, 2020

Thanks for opening this issue and starting a discussion 👍

I enabled it in few bigger apps I have access to, to check if something has changed since I disabled the rule. I found 16/72 cases where the check was correct and an await was missing. 77% of the time it is a false positive though.

Most false positives are button presses that start async operations (intended) or fire and forget calls like analytics event tracking.

Another reason this check is disabled, which I haven't documented, is that the unawaited function is part of the pedantic package. To use it, lint would have to depend on pedantic and export it. It would be a bit weird to depend on something this project replaces.

I'm happy to add it as default, given proof that it is correct in ~80% of cases and enough demand from the community (Upvote the issue if you read this). For the time being, enable it manually for your project:

include: package:lint/analysis_options.yaml

linter:
  rules:
    # Always await, intentionally not await
    unawaited_futures: true

Don't forget to also add the pedantic dependency to actually be able to use the unawaited function.

@bsutton
Copy link
Author

bsutton commented Dec 16, 2020 via email

@sgehrman
Copy link

sgehrman commented Apr 4, 2021

Was this ever solved? Do we have to include lint and pendantic to get the unawaited() function?

@passsy
Copy link
Owner

passsy commented Apr 5, 2021

I let this issue sit for a while because the unawaited function was moved from pedantic to meta. I don't mind depending on meta but unfortunately, it was reverted DOH!

Screen-Shot-2021-04-05-15-36-54 60

I then checked the linter code and discovered - to my surprise - that the check is not tied to the unawaited function of pedantic. Instead, any wrapper function and extensions work! This means lint can ship its own unawaited function.

Please check the PR for the new fireAndFoget function #33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants