From 9fe7d2d392cab974cb367a8c9124e9aac6950402 Mon Sep 17 00:00:00 2001 From: Robert Virkus Date: Fri, 8 Dec 2023 18:02:03 +0100 Subject: [PATCH] Chore: improve code style --- .../commands/smtp_auth_cram_md5_command.dart | 4 +- test/mail/mail_account_test.dart | 39 ++++++++----------- test/src/imap/fetch_parser_test.dart | 6 +-- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/lib/src/private/smtp/commands/smtp_auth_cram_md5_command.dart b/lib/src/private/smtp/commands/smtp_auth_cram_md5_command.dart index 8f8cbbf0..c011e6b7 100644 --- a/lib/src/private/smtp/commands/smtp_auth_cram_md5_command.dart +++ b/lib/src/private/smtp/commands/smtp_auth_cram_md5_command.dart @@ -1,6 +1,8 @@ import 'dart:convert'; -import 'package:crypto/crypto.dart'; import 'dart:typed_data'; + +import 'package:crypto/crypto.dart'; + import '../../../smtp/smtp_response.dart'; import '../smtp_command.dart'; diff --git a/test/mail/mail_account_test.dart b/test/mail/mail_account_test.dart index fa551846..2936300d 100644 --- a/test/mail/mail_account_test.dart +++ b/test/mail/mail_account_test.dart @@ -17,7 +17,7 @@ void main() { group('Serialization', () { test('Test ServerConfig', () async { - final originalServerConfig = ServerConfig( + const originalServerConfig = ServerConfig( type: ServerType.imap, hostname: 'imap.example.com', port: 993, @@ -37,7 +37,7 @@ void main() { }); test('serialize account', () { - final original = MailAccount( + const original = MailAccount( email: 'test@domain.com', name: 'A name with "quotes"', outgoingClientDomain: 'outgoing.com', @@ -51,9 +51,8 @@ void main() { authentication: Authentication.plain, usernameType: UsernameType.emailAddress, ), - authentication: - const PlainAuthentication('user@domain.com', 'secret'), - serverCapabilities: [const Capability('IMAP4')], + authentication: PlainAuthentication('user@domain.com', 'secret'), + serverCapabilities: [Capability('IMAP4')], pathSeparator: '/', ), outgoing: MailServerConfig( @@ -65,11 +64,10 @@ void main() { authentication: Authentication.plain, usernameType: UsernameType.emailAddress, ), - authentication: - const PlainAuthentication('user@domain.com', 'secret'), + authentication: PlainAuthentication('user@domain.com', 'secret'), ), supportsPlusAliases: true, - aliases: [const MailAddress('just tester', 'alias@domain.com')], + aliases: [MailAddress('just tester', 'alias@domain.com')], ); _compareAfterJsonSerialization(original); }); @@ -89,7 +87,7 @@ void main() { name: 'A name with "quotes"', outgoingClientDomain: 'outgoing.com', incoming: MailServerConfig( - serverConfig: ServerConfig( + serverConfig: const ServerConfig( type: ServerType.imap, hostname: 'imap.domain.com', port: 993, @@ -106,7 +104,7 @@ void main() { pathSeparator: '/', ), outgoing: MailServerConfig( - serverConfig: ServerConfig( + serverConfig: const ServerConfig( type: ServerType.smtp, hostname: 'smtp.domain.com', port: 993, @@ -152,7 +150,7 @@ void main() { test('serialize list of accounts', () { final accounts = [ - MailAccount( + const MailAccount( email: 'test@domain.com', name: 'A name with "quotes"', userName: 'Andrea Ghez', @@ -165,9 +163,8 @@ void main() { socketType: SocketType.ssl, authentication: Authentication.plain, usernameType: UsernameType.emailAddress), - authentication: - const PlainAuthentication('user@domain.com', 'secret'), - serverCapabilities: [const Capability('IMAP4')], + authentication: PlainAuthentication('user@domain.com', 'secret'), + serverCapabilities: [Capability('IMAP4')], pathSeparator: '/', ), outgoing: MailServerConfig( @@ -178,11 +175,10 @@ void main() { socketType: SocketType.ssl, authentication: Authentication.plain, usernameType: UsernameType.emailAddress), - authentication: - const PlainAuthentication('user@domain.com', 'secret'), + authentication: PlainAuthentication('user@domain.com', 'secret'), ), ), - MailAccount( + const MailAccount( email: 'test2@domain2.com', name: 'my second account', userName: 'First Last', @@ -196,11 +192,8 @@ void main() { authentication: Authentication.plain, usernameType: UsernameType.emailAddress), authentication: - const PlainAuthentication('user2@domain2.com', 'verysecret'), - serverCapabilities: [ - const Capability('IMAP4'), - const Capability('IDLE') - ], + PlainAuthentication('user2@domain2.com', 'verysecret'), + serverCapabilities: [Capability('IMAP4'), Capability('IDLE')], pathSeparator: '/', ), outgoing: MailServerConfig( @@ -212,7 +205,7 @@ void main() { authentication: Authentication.plain, usernameType: UsernameType.emailAddress), authentication: - const PlainAuthentication('user2@domain2.com', 'topsecret'), + PlainAuthentication('user2@domain2.com', 'topsecret'), ), ), ]; diff --git a/test/src/imap/fetch_parser_test.dart b/test/src/imap/fetch_parser_test.dart index 7a8bf42a..804d886e 100644 --- a/test/src/imap/fetch_parser_test.dart +++ b/test/src/imap/fetch_parser_test.dart @@ -924,7 +924,7 @@ void main() { var lastLineEndedInData = false; for (final text in responseTexts) { if (lastLineEndedInData) { - final rawData = utf8.encode(text) as Uint8List; + final rawData = utf8.encode(text); details.add(ImapResponseLine.raw(rawData)); lastLineEndedInData = false; } else { @@ -1085,7 +1085,7 @@ void main() { final details = ImapResponse() ..add(ImapResponseLine(responseText1)) - ..add(ImapResponseLine.raw(utf8.encode(responseText2) as Uint8List)) + ..add(ImapResponseLine.raw(utf8.encode(responseText2))) ..add(ImapResponseLine(responseText3)); final parser = FetchParser(isUidFetch: false); final response = Response()..status = ResponseStatus.ok; @@ -1205,7 +1205,7 @@ void main() { '''* 65300 FETCH (UID 355372 ENVELOPE ("Sat, 13 Nov 2021 09:01:57 +0100 (CET)" {108}''')) ..add(ImapResponseLine.raw(utf8 .encode('''=?UTF-8?Q?Anzeige_"K=C3=BCchenutensilien,_K=C3=A4seme?=\r - =?UTF-8?Q?sser"_erfolgreich_ver=C3=B6ffentlicht.?=''') as Uint8List)) + =?UTF-8?Q?sser"_erfolgreich_ver=C3=B6ffentlicht.?='''))) ..add(ImapResponseLine( ''' (("eBay Kleinanzeigen" NIL "noreply" "ebay-kleinanzeigen.de")) (("eBay Kleinanzeigen" NIL "noreply" "ebay-kleinanzeigen.de")) (("eBay Kleinanzeigen" NIL "noreply" "ebay-kleinanzeigen.de")) ((NIL NIL "some.one" "domain.com")) NIL NIL NIL "<709648757.77104.1636790517873@tns-consumer-app-7.tns-consumer-app.ebayk.svc.cluster.local>"))''')); final parser = FetchParser(isUidFetch: false);