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

Additional lints #1584

Merged
merged 10 commits into from
Sep 11, 2022
Merged

Additional lints #1584

merged 10 commits into from
Sep 11, 2022

Conversation

TimWhiting
Copy link
Collaborator

@TimWhiting TimWhiting commented Aug 24, 2022

Working on some additional lints:

  • Finish riverpod_no_mutate_sync (don't mutate providers synchronously inside build of widget or providers).
  • Avoid read on autoDispose / use container.listen on autoDispose
  • use ref synchronously in widget callbacks (similar to BuildContext across async gaps)
  • Avoid global provider container
  • Finish riverpod_ref_escape_scope (don't pass WidgetRef between widgets, dont pass Ref except to a Notifier constructor or field initializer

@TimWhiting TimWhiting mentioned this pull request Aug 24, 2022
22 tasks
@rrousselGit
Copy link
Owner

Epic!

@rrousselGit
Copy link
Owner

By the way, it'd be nice if the lints could be made compatible with the code-generator too.

Some of them should be fine, but I'm sure some will fail

@TimWhiting
Copy link
Collaborator Author

By the way, it'd be nice if the lints could be made compatible with the code-generator too.

Some of them should be fine, but I'm sure some will fail

Yes, I was thinking the same thing. I was playing with the code generator for the first time yesterday.

@TimWhiting
Copy link
Collaborator Author

I had to increase the timeout on the test. In CI it might be even slower. Is the slowness because of the custom_lint package, or because of how the lint rules are written do you think? There are probably some caching / other optimizations I should do with some of the lints, but I just wanted to know if it is partly the custom_lint package?

@rrousselGit
Copy link
Owner

analyzer & analyzer_plugin are slow in general. But it's worth investigating if you have the time

Although if you can, I think it'd be better to look into fixing the issue where custom_lint doesn't work in release mode. It's more important.
Then there's the symlink issue with custom_lint, which end-up analyzing the entire flutter repo if the user uses fmv

@rrousselGit
Copy link
Owner

About riverpod_no_mutate_sync, a case I tought of is ref.invalidate/ref.invalidateSelf

They probably should not be allowed either, using the same reasoning.

@TimWhiting
Copy link
Collaborator Author

About riverpod_no_mutate_sync, a case I tought of is ref.invalidate/ref.invalidateSelf

They probably should not be allowed either, using the same reasoning.

What about ref.refresh?

…f.read on autoDispose lint, refactor async context detection.
@TimWhiting TimWhiting marked this pull request as ready for review August 26, 2022 04:08
@TimWhiting
Copy link
Collaborator Author

TimWhiting commented Aug 26, 2022

I think this is getting too big for one PR. I've added items on the Linter issue for improving performance, and adding support for the codegen.

@TimWhiting
Copy link
Collaborator Author

I'll try to fix the build before merging though

@codecov
Copy link

codecov bot commented Sep 10, 2022

Codecov Report

Merging #1584 (0816704) into master (dea35d2) will not change coverage.
The diff coverage is n/a.

❗ Current head 0816704 differs from pull request most recent head 3fdd124. Consider uploading reports for the commit 3fdd124 to get more accurate results

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1584   +/-   ##
=======================================
  Coverage   93.20%   93.20%           
=======================================
  Files          51       51           
  Lines        1929     1929           
=======================================
  Hits         1798     1798           
  Misses        131      131           

@TimWhiting
Copy link
Collaborator Author

TimWhiting commented Sep 10, 2022

@rrousselGit Ready for review. Compatibility with codegen, and figuring out how to speed up / optimize these lints will be next.

Tests pass locally, I'll look at the CI issue tomorrow

@rrousselGit rrousselGit merged commit 532ff9e into rrousselGit:master Sep 11, 2022
@rrousselGit
Copy link
Owner

Awesome thanks!

@TimWhiting TimWhiting deleted the additional_lints branch September 24, 2022 05:25
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 this pull request may close these issues.

2 participants