Skip to content

Commit afa20a8

Browse files
Ilya Yanokcopybara-github
authored andcommitted
Disable deprecated member findings in generated code
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
1 parent ffbbb4c commit afa20a8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/src/builder.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ class MockBuilder implements Builder {
9797
b.body.add(Code('// ignore_for_file: avoid_setters_without_getters\n'));
9898
// We don't properly prefix imported class names in doc comments.
9999
b.body.add(Code('// ignore_for_file: comment_references\n'));
100+
// We might import a deprecated library, or implement a deprecated class.
101+
b.body.add(Code('// ignore_for_file: deprecated_member_use\n'));
102+
b.body.add(Code(
103+
'// ignore_for_file: deprecated_member_use_from_same_package\n'));
100104
// We might import a package's 'src' directory.
101105
b.body.add(Code('// ignore_for_file: implementation_imports\n'));
102106
// `Mock.noSuchMethod` is `@visibleForTesting`, but the generated code is

0 commit comments

Comments
 (0)