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,
); );
const coverageIgnoreStart = ' // coverage:ignore-start';
const coverageIgnoreEnd = ' // coverage:ignore-end';
final patterns = [
RegExp(
r'factory .*\.fromJson\(Map<String, dynamic> json\) => _\$.*FromJson\(json\);',
),
RegExp(
r'Map<String, dynamic> toJson\(\) => _\$.*ToJson\(this\);',
),
RegExp(
r'factory .*\.fromJsonString\(String data\) => .*\.fromJson\(json\.decode\(data\)(?: as Map<String, dynamic>)?\);',
),
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( await buildStep.writeAsString(
outputId, outputId,
formatter.format( formatter.format(outputString),
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);

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

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