Skip to content

Commit

Permalink
Sync code format by linter
Browse files Browse the repository at this point in the history
  • Loading branch information
dab246 authored and hoangdat committed Apr 19, 2024
1 parent 8b56ae0 commit 449d5a4
Show file tree
Hide file tree
Showing 25 changed files with 60 additions and 69 deletions.
1 change: 1 addition & 0 deletions lib/jmap/identities/get/get_identity_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ class GetIdentityMethod extends GetMethod {

factory GetIdentityMethod.fromJson(Map<String, dynamic> json) => _$GetIdentityMethodFromJson(json);

@override
Map<String, dynamic> toJson() => _$GetIdentityMethodToJson(this);
}
2 changes: 1 addition & 1 deletion lib/jmap/identities/set/set_identity_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SetIdentityMethod extends SetMethod<Identity> {
writeNotNull('update', update
?.map((id, update) => SetMethodPropertiesConverter().fromMapIdToJson(id, update.toJson())));
writeNotNull('destroy', destroy
?.map((destroyId) => IdConverter().toJson(destroyId)).toList());
?.map((destroyId) => const IdConverter().toJson(destroyId)).toList());

return val;
}
Expand Down
14 changes: 1 addition & 13 deletions lib/jmap/mail/email/changes/changes_email_response.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/jmap/mail/email/set/set_email_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SetEmailMethod extends SetMethod<Email> {
?.map((id, update) => SetMethodPropertiesConverter()
.fromMapIdToJson(id, update.toJson())));
writeNotNull('destroy', destroy
?.map((destroyId) => IdConverter()
?.map((destroyId) => const IdConverter()
.toJson(destroyId)).toList());

return val;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class SetEmailSubmissionMethod extends SetMethod<EmailSubmission> with OptionalO
?.map((id, update) => SetMethodPropertiesConverter()
.fromMapIdToJson(id, update.toJson())));
writeNotNull('destroy', destroy
?.map((destroyId) => IdConverter()
?.map((destroyId) => const IdConverter()
.toJson(destroyId)).toList());
writeNotNull('onSuccessUpdateEmail', onSuccessUpdateEmail
?.map((id, update) => SetMethodPropertiesConverter()
.fromMapEmailSubmissionIdToJson(id, update)));
writeNotNull('onSuccessDestroyEmail', onSuccessDestroyEmail
?.map((destroyId) => ReferencesEmailSubmissionIdConverter()
?.map((destroyId) => const ReferencesEmailSubmissionIdConverter()
.toJson(destroyId)).toList());

return val;
Expand All @@ -66,9 +66,7 @@ mixin OptionalOnSuccessUpdateEmail {
Map<EmailSubmissionId, PatchObject>? onSuccessUpdateEmail;

void addOnSuccessUpdateEmail(Map<EmailSubmissionId, PatchObject> values) {
if (onSuccessUpdateEmail == null) {
onSuccessUpdateEmail = Map<EmailSubmissionId, PatchObject>();
}
onSuccessUpdateEmail ??= <EmailSubmissionId, PatchObject>{};
onSuccessUpdateEmail?.addAll(values);
}
}
Expand All @@ -78,9 +76,7 @@ mixin OptionalOnSuccessDestroyEmail {
Set<EmailSubmissionId>? onSuccessDestroyEmail;

void addOnSuccessDestroyEmail(Set<EmailSubmissionId> values) {
if (onSuccessDestroyEmail == null) {
onSuccessDestroyEmail = Set();
}
onSuccessDestroyEmail ??= <EmailSubmissionId>{};
onSuccessDestroyEmail?.addAll(values);
}
}
1 change: 1 addition & 0 deletions lib/jmap/mail/mailbox/get/get_mailbox_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ class GetMailboxMethod extends GetMethod {

factory GetMailboxMethod.fromJson(Map<String, dynamic> json) => _$GetMailboxMethodFromJson(json);

@override
Map<String, dynamic> toJson() => _$GetMailboxMethodToJson(this);
}
2 changes: 2 additions & 0 deletions lib/jmap/mail/mailbox/mailbox_rights.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class MailboxRights with EquatableMixin {
return _$MailboxRightsFromJson(json);
}

Map<String, dynamic> toJson() => _$MailboxRightsToJson(this);

@override
List<Object?> get props => [mayReadItems, mayAddItems, mayRemoveItems, maySetSeen,
maySetKeywords, mayCreateChild, mayRename, mayDelete, maySubmit];
Expand Down
2 changes: 1 addition & 1 deletion lib/jmap/mail/mailbox/set/set_mailbox_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SetMailboxMethod extends SetMethod<Mailbox> with OptionalOnDestroyRemoveEm
writeNotNull('update', update
?.map((id, update) => SetMethodPropertiesConverter().fromMapIdToJson(id, update.toJson())));
writeNotNull('destroy', destroy
?.map((destroyId) => IdConverter().toJson(destroyId)).toList());
?.map((destroyId) => const IdConverter().toJson(destroyId)).toList());
writeNotNull('onDestroyRemoveEmails', onDestroyRemoveEmails);

return val;
Expand Down
1 change: 1 addition & 0 deletions lib/jmap/mail/vacation/get/get_vacation_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ class GetVacationMethod extends GetMethod {
factory GetVacationMethod.fromJson(Map<String, dynamic> json) =>
_$GetVacationMethodFromJson(json);

@override
Map<String, dynamic> toJson() => _$GetVacationMethodToJson(this);
}
4 changes: 2 additions & 2 deletions lib/jmap/mdn/send/mdn_send_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class MDNSendResponse extends SendResponse<MDN> {
const AccountIdConverter().fromJson(json['accountId'] as String),
sent: (json['sent'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
IdConverter().fromJson(key),
const IdConverter().fromJson(key),
MDN.fromJson(value as Map<String, dynamic>))),
notSent: (json['notSent'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
IdConverter().fromJson(key),
const IdConverter().fromJson(key),
SetError.fromJson(value))),
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/jmap/push/get/get_push_subscription_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ class GetPushSubscriptionMethod extends GetMethodNoNeedAccountId {

factory GetPushSubscriptionMethod.fromJson(Map<String, dynamic> json) => _$GetPushSubscriptionMethodFromJson(json);

@override
Map<String, dynamic> toJson() => _$GetPushSubscriptionMethodToJson(this);
}
2 changes: 1 addition & 1 deletion lib/jmap/push/set/set_push_subscription_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SetPushSubscriptionMethod extends SetMethodNoNeedAccountId<PushSubscriptio
writeNotNull('update', update
?.map((id, update) => SetMethodPropertiesConverter().fromMapIdToJson(id, update.toJson())));
writeNotNull('destroy', destroy
?.map((destroyId) => IdConverter().toJson(destroyId)).toList());
?.map((destroyId) => const IdConverter().toJson(destroyId)).toList());

return val;
}
Expand Down
12 changes: 6 additions & 6 deletions lib/jmap/push/set/set_push_subscription_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ class SetPushSubscriptionResponse extends SetResponseNoAccount<PushSubscription>
return SetPushSubscriptionResponse(
created: (json['created'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
IdConverter().fromJson(key),
const IdConverter().fromJson(key),
PushSubscription.fromJson(value as Map<String, dynamic>))),
updated: (json['updated'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
IdConverter().fromJson(key),
const IdConverter().fromJson(key),
value != null ? PushSubscription.fromJson(value as Map<String, dynamic>) : null)),
destroyed: (json['destroyed'] as List<dynamic>?)
?.map((id) => IdConverter().fromJson(id)).toSet(),
?.map((id) => const IdConverter().fromJson(id)).toSet(),
notCreated: (json['notCreated'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
IdConverter().fromJson(key),
const IdConverter().fromJson(key),
SetError.fromJson(value))),
notUpdated: (json['notUpdated'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
IdConverter().fromJson(key),
const IdConverter().fromJson(key),
SetError.fromJson(value))),
notDestroyed: (json['notDestroyed'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
IdConverter().fromJson(key),
const IdConverter().fromJson(key),
SetError.fromJson(value))),
);
}
Expand Down
4 changes: 1 addition & 3 deletions lib/jmap/push/state_change.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class StateChange with EquatableMixin {
StateChange(this.type, this.changed);

factory StateChange.fromJson(Map<String, dynamic> json, {TypeStateConverter? converter}) {
if (converter == null) {
converter = TypeStateConverter.defaultConverter;
}
converter ??= TypeStateConverter.defaultConverter;
return StateChange(
json['@type'] as String,
(json['changed'] as Map<String, dynamic>).map((key, value) => converter!.convert(key, value)),
Expand Down
1 change: 1 addition & 0 deletions lib/jmap/quotas/get/get_quota_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ class GetQuotaMethod extends GetMethod {

factory GetQuotaMethod.fromJson(Map<String, dynamic> json) => _$GetQuotaMethodFromJson(json);

@override
Map<String, dynamic> toJson() => _$GetQuotaMethodToJson(this);
}
6 changes: 3 additions & 3 deletions lib/util/options_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'package:dio/dio.dart';

extension OptionsExtension on Options {
Options appendHeaders(Map<String, dynamic> additionalHeaders) {
if (this.headers != null) {
this.headers?.addAll(additionalHeaders);
if (headers != null) {
headers?.addAll(additionalHeaders);
} else {
this.headers = additionalHeaders;
headers = additionalHeaders;
}
return this;
}
Expand Down
4 changes: 3 additions & 1 deletion lib/util/util.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Iterable<int> get positiveIntegers sync* {
int i = 0;
while (true) yield i++;
while (true) {
yield i++;
}
}
40 changes: 20 additions & 20 deletions test/jmap/core/session/session_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import 'test_capability.dart';
void main() {
group('get session with default capabilities', () {
test('get should parsing correctly session', () {
final sessionString = '''{
const sessionString = '''{
"capabilities": {
"urn:ietf:params:jmap:submission": {
"maxDelayedSend": 0,
Expand Down Expand Up @@ -159,8 +159,8 @@ void main() {
supportsPush: true,
url: Uri.parse('ws://domain.com/jmap/ws')
),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(Map<String, dynamic>()),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(Map<String, dynamic>()),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier.jmapVacationResponse: VacationCapability(),
CapabilityIdentifier.jmapMdn: MdnCapability()
},
Expand Down Expand Up @@ -195,8 +195,8 @@ void main() {
emailQuerySortOptions: {"receivedAt", "sentAt", "size", "from", "to", "subject"},
mayCreateTopLevelMailbox: true
),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(Map<String, dynamic>()),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(Map<String, dynamic>()),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier.jmapVacationResponse: VacationCapability(),
CapabilityIdentifier.jmapMdn: MdnCapability()
}
Expand Down Expand Up @@ -226,7 +226,7 @@ void main() {
});

test('get should parsing correctly session with some limit capabilities', () {
final sessionString = '''{
const sessionString = '''{
"capabilities": {
"urn:ietf:params:jmap:submission": {
"maxDelayedSend": 0,
Expand Down Expand Up @@ -392,7 +392,7 @@ void main() {
});

test('get should parsing correctly session with some capabilities miss property', () {
final sessionString = '''{
const sessionString = '''{
"capabilities": {
"urn:ietf:params:jmap:submission": {
"maxDelayedSend": 0,
Expand Down Expand Up @@ -538,7 +538,7 @@ void main() {

group('get session with unknown capability', () {
test('get should parsing correctly session with default converter', () {
final sessionString = '''{
const sessionString = '''{
"capabilities": {
"urn:tmail:custom:params:mailbox": {
"param1": 1,
Expand Down Expand Up @@ -693,8 +693,8 @@ void main() {
supportsPush: true,
url: Uri.parse('ws://domain.com/jmap/ws')
),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(Map<String, dynamic>()),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(Map<String, dynamic>()),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier.jmapVacationResponse: VacationCapability(),
CapabilityIdentifier.jmapMdn: MdnCapability()
},
Expand Down Expand Up @@ -730,8 +730,8 @@ void main() {
emailQuerySortOptions: {"receivedAt", "sentAt", "size", "from", "to", "subject"},
mayCreateTopLevelMailbox: true
),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(Map<String, dynamic>()),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(Map<String, dynamic>()),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier.jmapVacationResponse: VacationCapability(),
CapabilityIdentifier.jmapMdn: MdnCapability()
}
Expand Down Expand Up @@ -768,7 +768,7 @@ void main() {

group('get session with custom capability', () {
test('get should parsing correctly with relevant custom converter', () {
final sessionString = '''{
const sessionString = '''{
"capabilities": {
"urn:test:tmail:params:custom": {
"testParam1": 100,
Expand Down Expand Up @@ -931,8 +931,8 @@ void main() {
supportsPush: true,
url: Uri.parse('ws://domain.com/jmap/ws')
),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(Map<String, dynamic>()),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(Map<String, dynamic>()),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier.jmapVacationResponse: VacationCapability(),
CapabilityIdentifier.jmapMdn: MdnCapability()
},
Expand Down Expand Up @@ -968,8 +968,8 @@ void main() {
emailQuerySortOptions: {"receivedAt", "sentAt", "size", "from", "to", "subject"},
mayCreateTopLevelMailbox: true
),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(Map<String, dynamic>()),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(Map<String, dynamic>()),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:quota')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier(Uri.parse('urn:apache:james:params:jmap:mail:shares')): DefaultCapability(<String, dynamic>{}),
CapabilityIdentifier.jmapVacationResponse: VacationCapability(),
CapabilityIdentifier.jmapMdn: MdnCapability()
}
Expand Down Expand Up @@ -1008,7 +1008,7 @@ void main() {

group('get session with empty capability', () {
test('get should ignore parsing empty capability properties', () {
final sessionString = '''{
const sessionString = '''{
"capabilities": {
"urn:ietf:params:jmap:submission": {
"maxDelayedSend": 0,
Expand Down Expand Up @@ -1150,7 +1150,7 @@ void main() {

group('get session for CYRUS server', () {
test('get should parsing correctly session', () {
final sessionString = '''
const sessionString = '''
{
"username": "example",
"apiUrl": "/jmap/",
Expand Down Expand Up @@ -1293,7 +1293,7 @@ void main() {
CapabilityIdentifier.jmapSubmission: SubmissionCapability(),
CapabilityIdentifier.jmapVacationResponse: VacationCapability(),
CapabilityIdentifier.jmapMdn: MdnCapability(),
CapabilityIdentifier(Uri.parse('https://cyrusimap.org/ns/jmap/sieve')): DefaultCapability(Map<String, dynamic>()),
CapabilityIdentifier(Uri.parse('https://cyrusimap.org/ns/jmap/sieve')): DefaultCapability(<String, dynamic>{}),
},
{
AccountId(Id('example')): Account(
Expand Down
4 changes: 2 additions & 2 deletions test/jmap/core/utc_date_converter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import 'package:jmap_dart_client/jmap/core/utc_date.dart';

void main() {

final utcDateStringTest = '2021-10-04T04:39:56.000Z';
const utcDateStringTest = '2021-10-04T04:39:56.000Z';
final expectUTCDate = UTCDate(DateTime.parse('2021-10-04T04:39:56.000Z').toUtc());
final testUTCDate = UTCDate(DateTime.parse('2021-10-04T04:39:56.000Z').toUtc());
final expectUTCDateString = '2021-10-04T04:39:56.000Z';
const expectUTCDateString = '2021-10-04T04:39:56.000Z';

group('UTCDateConverter', () {
test('should return UTCDate when receive a properly formatted json', () {
Expand Down
4 changes: 2 additions & 2 deletions test/jmap/email/query/query_with_operator_emails_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ void main() {
})
..addFilters(LogicFilterOperator(
Operator.OR,
Set<Filter>.from([
<Filter>{
EmailFilterCondition(hasKeyword: "music"),
EmailFilterCondition(hasKeyword: "video"),
])));
}));
final queryEmailInvocation = jmapRequestBuilder
.invocation(queryEmailMethod, methodCallId: MethodCallId('c2'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void main() {
);

if (resultList != null) {
resultList..sortEmails(comparator);
resultList.sortEmails(comparator);
}

return resultList?.list;
Expand Down
Loading

0 comments on commit 449d5a4

Please sign in to comment.