-
-
Notifications
You must be signed in to change notification settings - Fork 956
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
feat(riverpod_lint): added avoid use ref inside dispose #2701
Conversation
Hello! Also we would need tests. See the |
Yes. I would write tests but I got some errors after executing the
Flutter version:
|
I got the same error on my PR and I'm stuck on this. |
Not sure how you got that error. The CI is running tests and works just fine. |
Do you run these tests only in the CI? |
Hello @rrousselGit, I am not sure that I wrote the right tests but can you check? Thanks. |
@LeonardoRosaa Did you write the golden test manually? |
Yes, I did. |
I see. |
packages/riverpod_lint_flutter_test/test/goldens/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint_flutter_test/test/goldens/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint_flutter_test/test/goldens/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
Thanks for the test! We'll probably need a few more cases to make sure we have 100% coverage. |
8e981da
to
e9db803
Compare
I did some improvements. Can you check it? |
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
Could you document this lint in the README? |
I wrote some documentation. But, can you explain in more detail why to avoid using ref in the dispose method? |
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
packages/riverpod_lint/lib/src/lints/avoid_use_ref_inside_dispose.dart
Outdated
Show resolved
Hide resolved
|
||
const disposeMethod = 'dispose'; | ||
|
||
class AvoidUseRefInsideDispose extends RiverpodLintRule { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rename the class and file name to match the lint code? avoid_ref_inside_state_dispose.dart and AvoidRefInsideStateDispose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once the lint class & filename are renamed
Thanks for this :)
Done :) |
Epic. Thanks! |
It's a good practice to avoid using the
WidgetRef
in thedispose
method to avoid some problems although it isn't every usage that creates some problems.Identifies the dispose method by name and the
@override
annotation once a time theWidgetRef
is only used in theState
class.Reference: #2542