From 7bd31db6a257cbbc684c630a1246817ea51e21d2 Mon Sep 17 00:00:00 2001 From: stephanebalasse Date: Sun, 6 Apr 2025 20:59:24 +0200 Subject: [PATCH 1/3] Remove redundant 'must_be_immutable' ignore comment The 'must_be_immutable' ignore comment was unnecessary and has been removed. This streamlines the code by eliminating an unused conditional block, maintaining cleaner and more focused logic. --- lib/src/builder.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/src/builder.dart b/lib/src/builder.dart index d857da18..9781e459 100644 --- a/lib/src/builder.dart +++ b/lib/src/builder.dart @@ -1271,9 +1271,7 @@ class _MockClassInfo { '/// See the documentation for Mockito\'s code generation ' 'for more information.', ); - if (classIsImmutable) { - cBuilder.docs.add('// ignore: must_be_immutable'); - } + // For each type parameter on [classToMock], the Mock class needs a type // parameter with same type variables, and a mirrored type argument for // the "implements" clause. From a6aa61806c218cfd64030303563c696c62b97c80 Mon Sep 17 00:00:00 2001 From: stephanebalasse Date: Sun, 6 Apr 2025 20:59:39 +0200 Subject: [PATCH 2/3] Remove unused variable `classIsImmutable` This variable was declared but never used, causing unnecessary clutter in the code. Removing it improves code readability and maintains cleaner logic in the builder. --- lib/src/builder.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/builder.dart b/lib/src/builder.dart index 9781e459..887c4ff2 100644 --- a/lib/src/builder.dart +++ b/lib/src/builder.dart @@ -1256,7 +1256,6 @@ class _MockClassInfo { typeAlias?.element2.aliasedType as analyzer.InterfaceType?; final typeToMock = aliasedType ?? mockTarget.classType; final classToMock = mockTarget.interfaceElement; - final classIsImmutable = classToMock.metadata.any((it) => it.isImmutable); final className = aliasedElement?.name3 ?? classToMock.name3; return Class((cBuilder) { From c94194a93524af23d137e852486f98a2bfa3900a Mon Sep 17 00:00:00 2001 From: stephanebalasse Date: Sun, 6 Apr 2025 21:00:13 +0200 Subject: [PATCH 3/3] Remove redundant test for immutable class mock generation The removed test for adding `ignore: must_be_immutable` comments is no longer necessary. It likely reflects obsolete functionality or has been integrated elsewhere in the codebase. --- test/builder/auto_mocks_test.dart | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/test/builder/auto_mocks_test.dart b/test/builder/auto_mocks_test.dart index de82ffec..88bf5baa 100644 --- a/test/builder/auto_mocks_test.dart +++ b/test/builder/auto_mocks_test.dart @@ -3784,20 +3784,6 @@ void main() { ); }); - test('adds ignore: must_be_immutable analyzer comment if mocked class is ' - 'immutable', () async { - await expectSingleNonNullableOutput( - dedent(r''' - import 'package:meta/meta.dart'; - @immutable - class Foo { - void foo(); - } - '''), - _containsAllOf('// ignore: must_be_immutable\nclass MockFoo'), - ); - }); - group('typedef mocks', () { group('are generated properly', () { test('when aliased type parameters are instantiated', () async {