Browse Source

dynamite: Add coverage ignore comments where useful

pull/83/head
jld3103 2 years ago
parent
commit
b785a5e192
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 21
      packages/dynamite/lib/src/openapi_builder.dart

21
packages/dynamite/lib/src/openapi_builder.dart

@ -991,7 +991,7 @@ class OpenAPIBuilder implements Builder {
} }
code.write('}'); code.write('}');
} }
code.write('throw ApiException.fromResponse(response);'); code.write('throw ApiException.fromResponse(response); // coverage:ignore-line\n');
} else { } else {
b.returns = refer('Future'); b.returns = refer('Future');
} }
@ -1028,6 +1028,7 @@ class OpenAPIBuilder implements Builder {
if (registeredJsonObjects.isNotEmpty) { if (registeredJsonObjects.isNotEmpty) {
output.addAll([ output.addAll([
'// coverage:ignore-start',
'final _deserializers = <Type, dynamic Function(dynamic)>{', 'final _deserializers = <Type, dynamic Function(dynamic)>{',
for (final name in registeredJsonObjects) ...[ for (final name in registeredJsonObjects) ...[
'$name: (final data) => ${_deserializeFunctionForType( '$name: (final data) => ${_deserializeFunctionForType(
@ -1077,6 +1078,7 @@ class OpenAPIBuilder implements Builder {
'T deserialize<T>(final dynamic data) => _deserializers[T]!(data) as T;', 'T deserialize<T>(final dynamic data) => _deserializers[T]!(data) as T;',
'', '',
'dynamic serialize<T>(final T data) => _serializers[T]!(data);', 'dynamic serialize<T>(final T data) => _serializers[T]!(data);',
'// coverage:ignore-end',
]); ]);
} }
@ -1085,7 +1087,22 @@ class OpenAPIBuilder implements Builder {
); );
await buildStep.writeAsString( await buildStep.writeAsString(
outputId, outputId,
formatter.format(output.join('\n')), formatter.format(
output
.join('\n')
.replaceAll(
'Map<String, dynamic> toJson()',
' // coverage:ignore-start\nMap<String, dynamic> 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) { } catch (e, s) {
print(s); print(s);

Loading…
Cancel
Save