Browse Source

dynamite,nextcloud: Fix coverage ignores

pull/161/head
jld3103 2 years ago
parent
commit
a4dffa0245
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 43
      packages/dynamite/lib/src/openapi_builder.dart
  2. 750
      packages/nextcloud/lib/src/nextcloud.openapi.dart

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

@ -861,24 +861,35 @@ class OpenAPIBuilder implements Builder {
final formatter = DartFormatter( final formatter = DartFormatter(
pageWidth: 120, pageWidth: 120,
); );
await buildStep.writeAsString( const coverageIgnoreStart = ' // coverage:ignore-start';
outputId, const coverageIgnoreEnd = ' // coverage:ignore-end';
formatter.format( final patterns = [
output RegExp(
.join('\n') r'factory .*\.fromJson\(Map<String, dynamic> json\) => _\$.*FromJson\(json\);',
.replaceAll( ),
'Map<String, dynamic> toJson()', RegExp(
' // coverage:ignore-start\nMap<String, dynamic> toJson()', r'Map<String, dynamic> toJson\(\) => _\$.*ToJson\(this\);',
) ),
.replaceAll( RegExp(
'ToJson(this);', r'factory .*\.fromJsonString\(String data\) => .*\.fromJson\(json\.decode\(data\)(?: as Map<String, dynamic>)?\);',
'ToJson(this);\n // coverage:ignore-end\n',
)
.replaceAll(
'dynamic toJson() => _data;',
' // coverage:ignore-start\ndynamic toJson() => _data;\n // coverage:ignore-end\n',
), ),
RegExp(
r'static String toJsonString\(.* data\) => json\.encode\(data(?:\.toJson\(\))?\);',
), ),
RegExp(
r'dynamic toJson\(\) => _data;',
),
];
var outputString = output.join('\n');
for (final pattern in patterns) {
outputString = outputString.replaceAllMapped(
pattern,
(final match) => '$coverageIgnoreStart\n${match.group(0)}\n$coverageIgnoreEnd',
);
}
await buildStep.writeAsString(
outputId,
formatter.format(outputString),
); );
} catch (e, s) { } catch (e, s) {
print(s); print(s);

750
packages/nextcloud/lib/src/nextcloud.openapi.dart

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save