Browse Source

Merge pull request #1109 from nextcloud/feat/dynamite/config_add_linelength

feat(dynamite): allow to configure the pageWidth for the dart formatter
pull/1111/head
Nikolas Rimikis 1 year ago committed by GitHub
parent
commit
7a6742e7b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      packages/dynamite/dynamite/README.md
  2. 3
      packages/dynamite/dynamite/lib/src/models/dynamite_config/config.dart
  3. 30
      packages/dynamite/dynamite/lib/src/models/dynamite_config/config.g.dart
  4. 2
      packages/dynamite/dynamite/lib/src/openapi_builder.dart
  5. 1
      packages/dynamite/dynamite_end_to_end_test/build.yaml
  6. 1
      packages/nextcloud/build.yaml

1
packages/dynamite/dynamite/README.md

@ -15,6 +15,7 @@ targets:
# Options configure how source code is generated. # Options configure how source code is generated.
# #
# The following are sensible default values that ignores the schemas for the coverage. # The following are sensible default values that ignores the schemas for the coverage.
pageWidth: 120
analyzer_ignores: analyzer_ignores:
- camel_case_types - camel_case_types
- discarded_futures - discarded_futures

3
packages/dynamite/dynamite/lib/src/models/dynamite_config/config.dart

@ -30,6 +30,9 @@ abstract class DynamiteConfig implements Built<DynamiteConfig, DynamiteConfigBui
/// All matches will be wrapped in `// coverage:ignore-start` and `// coverage:ignore-end` blocks. /// All matches will be wrapped in `// coverage:ignore-start` and `// coverage:ignore-end` blocks.
@BuiltValueField(wireName: 'coverage_ignores') @BuiltValueField(wireName: 'coverage_ignores')
BuiltSet<String>? get coverageIgnores; BuiltSet<String>? get coverageIgnores;
/// The specified line with the formatter should use.
int? get pageWidth;
} }
@SerializersFor([ @SerializersFor([

30
packages/dynamite/dynamite/lib/src/models/dynamite_config/config.g.dart

@ -36,6 +36,12 @@ class _$DynamiteConfigSerializer implements StructuredSerializer<DynamiteConfig>
..add('coverage_ignores') ..add('coverage_ignores')
..add(serializers.serialize(value, specifiedType: const FullType(BuiltSet, [FullType(String)]))); ..add(serializers.serialize(value, specifiedType: const FullType(BuiltSet, [FullType(String)])));
} }
value = object.pageWidth;
if (value != null) {
result
..add('pageWidth')
..add(serializers.serialize(value, specifiedType: const FullType(int)));
}
return result; return result;
} }
@ -58,6 +64,9 @@ class _$DynamiteConfigSerializer implements StructuredSerializer<DynamiteConfig>
result.coverageIgnores.replace(serializers.deserialize(value, result.coverageIgnores.replace(serializers.deserialize(value,
specifiedType: const FullType(BuiltSet, [FullType(String)]))! as BuiltSet<Object?>); specifiedType: const FullType(BuiltSet, [FullType(String)]))! as BuiltSet<Object?>);
break; break;
case 'pageWidth':
result.pageWidth = serializers.deserialize(value, specifiedType: const FullType(int)) as int?;
break;
} }
} }
@ -70,11 +79,13 @@ class _$DynamiteConfig extends DynamiteConfig {
final BuiltSet<String>? analyzerIgnores; final BuiltSet<String>? analyzerIgnores;
@override @override
final BuiltSet<String>? coverageIgnores; final BuiltSet<String>? coverageIgnores;
@override
final int? pageWidth;
factory _$DynamiteConfig([void Function(DynamiteConfigBuilder)? updates]) => factory _$DynamiteConfig([void Function(DynamiteConfigBuilder)? updates]) =>
(DynamiteConfigBuilder()..update(updates))._build(); (DynamiteConfigBuilder()..update(updates))._build();
_$DynamiteConfig._({this.analyzerIgnores, this.coverageIgnores}) : super._(); _$DynamiteConfig._({this.analyzerIgnores, this.coverageIgnores, this.pageWidth}) : super._();
@override @override
DynamiteConfig rebuild(void Function(DynamiteConfigBuilder) updates) => (toBuilder()..update(updates)).build(); DynamiteConfig rebuild(void Function(DynamiteConfigBuilder) updates) => (toBuilder()..update(updates)).build();
@ -87,7 +98,8 @@ class _$DynamiteConfig extends DynamiteConfig {
if (identical(other, this)) return true; if (identical(other, this)) return true;
return other is DynamiteConfig && return other is DynamiteConfig &&
analyzerIgnores == other.analyzerIgnores && analyzerIgnores == other.analyzerIgnores &&
coverageIgnores == other.coverageIgnores; coverageIgnores == other.coverageIgnores &&
pageWidth == other.pageWidth;
} }
@override @override
@ -95,6 +107,7 @@ class _$DynamiteConfig extends DynamiteConfig {
var _$hash = 0; var _$hash = 0;
_$hash = $jc(_$hash, analyzerIgnores.hashCode); _$hash = $jc(_$hash, analyzerIgnores.hashCode);
_$hash = $jc(_$hash, coverageIgnores.hashCode); _$hash = $jc(_$hash, coverageIgnores.hashCode);
_$hash = $jc(_$hash, pageWidth.hashCode);
_$hash = $jf(_$hash); _$hash = $jf(_$hash);
return _$hash; return _$hash;
} }
@ -103,7 +116,8 @@ class _$DynamiteConfig extends DynamiteConfig {
String toString() { String toString() {
return (newBuiltValueToStringHelper(r'DynamiteConfig') return (newBuiltValueToStringHelper(r'DynamiteConfig')
..add('analyzerIgnores', analyzerIgnores) ..add('analyzerIgnores', analyzerIgnores)
..add('coverageIgnores', coverageIgnores)) ..add('coverageIgnores', coverageIgnores)
..add('pageWidth', pageWidth))
.toString(); .toString();
} }
} }
@ -119,6 +133,10 @@ class DynamiteConfigBuilder implements Builder<DynamiteConfig, DynamiteConfigBui
SetBuilder<String> get coverageIgnores => _$this._coverageIgnores ??= SetBuilder<String>(); SetBuilder<String> get coverageIgnores => _$this._coverageIgnores ??= SetBuilder<String>();
set coverageIgnores(SetBuilder<String>? coverageIgnores) => _$this._coverageIgnores = coverageIgnores; set coverageIgnores(SetBuilder<String>? coverageIgnores) => _$this._coverageIgnores = coverageIgnores;
int? _pageWidth;
int? get pageWidth => _$this._pageWidth;
set pageWidth(int? pageWidth) => _$this._pageWidth = pageWidth;
DynamiteConfigBuilder(); DynamiteConfigBuilder();
DynamiteConfigBuilder get _$this { DynamiteConfigBuilder get _$this {
@ -126,6 +144,7 @@ class DynamiteConfigBuilder implements Builder<DynamiteConfig, DynamiteConfigBui
if ($v != null) { if ($v != null) {
_analyzerIgnores = $v.analyzerIgnores?.toBuilder(); _analyzerIgnores = $v.analyzerIgnores?.toBuilder();
_coverageIgnores = $v.coverageIgnores?.toBuilder(); _coverageIgnores = $v.coverageIgnores?.toBuilder();
_pageWidth = $v.pageWidth;
_$v = null; _$v = null;
} }
return this; return this;
@ -149,7 +168,10 @@ class DynamiteConfigBuilder implements Builder<DynamiteConfig, DynamiteConfigBui
_$DynamiteConfig _$result; _$DynamiteConfig _$result;
try { try {
_$result = _$v ?? _$result = _$v ??
_$DynamiteConfig._(analyzerIgnores: _analyzerIgnores?.build(), coverageIgnores: _coverageIgnores?.build()); _$DynamiteConfig._(
analyzerIgnores: _analyzerIgnores?.build(),
coverageIgnores: _coverageIgnores?.build(),
pageWidth: pageWidth);
} catch (_) { } catch (_) {
late String _$failedField; late String _$failedField;
try { try {

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

@ -86,7 +86,7 @@ class OpenAPIBuilder implements Builder {
} }
} }
final formatter = DartFormatter(pageWidth: 120); final formatter = DartFormatter(pageWidth: buildConfig.pageWidth);
await buildStep.writeAsString( await buildStep.writeAsString(
outputId, outputId,
formatter.format(outputString), formatter.format(outputString),

1
packages/dynamite/dynamite_end_to_end_test/build.yaml

@ -5,6 +5,7 @@ targets:
enabled: true enabled: true
dynamite: dynamite:
options: options:
pageWidth: 120
analyzer_ignores: analyzer_ignores:
- camel_case_types - camel_case_types
- discarded_futures - discarded_futures

1
packages/nextcloud/build.yaml

@ -5,6 +5,7 @@ targets:
enabled: true enabled: true
dynamite: dynamite:
options: options:
pageWidth: 120
analyzer_ignores: analyzer_ignores:
- camel_case_types - camel_case_types
- discarded_futures - discarded_futures

Loading…
Cancel
Save