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

Generated mocks should ignore deprecatedmember_use #565

Closed
noinskit opened this issue Aug 19, 2022 · 4 comments · Fixed by #676
Closed

Generated mocks should ignore deprecatedmember_use #565

noinskit opened this issue Aug 19, 2022 · 4 comments · Fixed by #676

Comments

@noinskit
Copy link

It can make sense to create a mock of a class that has deprecated members, uses deprecated libraries (with the class itself not being deprecated).

For example, I need to mock PeopleResource from package:googleapis/people/v1.dart which uses deprecated fields in its implementation (although I'm not using any of them directly) and I'm getting the following analyzer warning that I can't get rid of:

info: 'package:googleapis/shared.dart' is deprecated and shouldn't be used. Avoid importing this library. Use the members defined in the target API library instead.. (deprecated_member_use at [lifepal_app] test/services/google_people_test.mocks.dart:11)
@cubuspl42
Copy link

I like this idea! In general, in my personal opinion, it would be great if Dart code generators would generate code with good support for restrictive Analyzer configuration.

@fzyzcjy
Copy link
Contributor

fzyzcjy commented Aug 29, 2022

+1 Is there any updates?

@srawlins
Copy link
Member

No updates

@srawlins srawlins reopened this Aug 29, 2022
@Merrit
Copy link

Merrit commented Jun 29, 2023

Is there a workaround so this doesn't show up as a warning in a project, without having to edit generated code?

copybara-service bot pushed a commit that referenced this issue Jul 14, 2023
People might want to mock classes that use some deprecated libraries
or classes. Mocked class itself could also be deprecated. Deprecated
member findings for the generated code are not very useful:

1. They are dubbing the finding in the actual code.
2. They are hard to disable (have to edit generated code).

So disable `deprecated_member_use` and `deprecated_member_use_from_same_package`
findings in the generated code.

Fixes #565

PiperOrigin-RevId: 548076155
copybara-service bot pushed a commit that referenced this issue Jul 14, 2023
People might want to mock classes that use some deprecated libraries
or classes. Mocked class itself could also be deprecated. Deprecated
member findings for the generated code are not very useful:

1. They are dubbing the finding in the actual code.
2. They are hard to disable (have to edit generated code).

So disable `deprecated_member_use` and `deprecated_member_use_from_same_package`
findings in the generated code.

Fixes #565

PiperOrigin-RevId: 548076155
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.

5 participants