From b785a5e1921d576806089cf51f166e3fcebc147f Mon Sep 17 00:00:00 2001 From: jld3103 Date: Wed, 5 Oct 2022 15:19:47 +0200 Subject: [PATCH] dynamite: Add coverage ignore comments where useful --- .../dynamite/lib/src/openapi_builder.dart | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/lib/src/openapi_builder.dart index 59b01ddd..d5b30de4 100644 --- a/packages/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/lib/src/openapi_builder.dart @@ -991,7 +991,7 @@ class OpenAPIBuilder implements Builder { } code.write('}'); } - code.write('throw ApiException.fromResponse(response);'); + code.write('throw ApiException.fromResponse(response); // coverage:ignore-line\n'); } else { b.returns = refer('Future'); } @@ -1028,6 +1028,7 @@ class OpenAPIBuilder implements Builder { if (registeredJsonObjects.isNotEmpty) { output.addAll([ + '// coverage:ignore-start', 'final _deserializers = {', for (final name in registeredJsonObjects) ...[ '$name: (final data) => ${_deserializeFunctionForType( @@ -1077,6 +1078,7 @@ class OpenAPIBuilder implements Builder { 'T deserialize(final dynamic data) => _deserializers[T]!(data) as T;', '', 'dynamic serialize(final T data) => _serializers[T]!(data);', + '// coverage:ignore-end', ]); } @@ -1085,7 +1087,22 @@ class OpenAPIBuilder implements Builder { ); await buildStep.writeAsString( outputId, - formatter.format(output.join('\n')), + formatter.format( + output + .join('\n') + .replaceAll( + 'Map toJson()', + ' // coverage:ignore-start\nMap toJson()', + ) + .replaceAll( + 'ToJson(this);', + 'ToJson(this);\n // coverage:ignore-end\n', + ) + .replaceAll( + 'dynamic toJson() => _data;', + ' // coverage:ignore-start\ndynamic toJson() => _data;\n // coverage:ignore-end\n', + ), + ), ); } catch (e, s) { print(s);