Skip to content

Commit

Permalink
Disable deprecated member findings in generated code
Browse files Browse the repository at this point in the history
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: 548118939
  • Loading branch information
Ilya Yanok authored and copybara-github committed Jul 14, 2023
1 parent ffbbb4c commit afa20a8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ class MockBuilder implements Builder {
b.body.add(Code('// ignore_for_file: avoid_setters_without_getters\n'));
// We don't properly prefix imported class names in doc comments.
b.body.add(Code('// ignore_for_file: comment_references\n'));
// We might import a deprecated library, or implement a deprecated class.
b.body.add(Code('// ignore_for_file: deprecated_member_use\n'));
b.body.add(Code(
'// ignore_for_file: deprecated_member_use_from_same_package\n'));
// We might import a package's 'src' directory.
b.body.add(Code('// ignore_for_file: implementation_imports\n'));
// `Mock.noSuchMethod` is `@visibleForTesting`, but the generated code is
Expand Down

0 comments on commit afa20a8

Please sign in to comment.