refactor: Update pedantic
This enforces to NOT use curly braces in Strings where not needed and not await non-future variables.
This commit is contained in:
parent
0d8bddf708
commit
44ca96e544
|
|
@ -24,8 +24,8 @@ coverage:
|
||||||
- chmod +x ./prepare.sh
|
- chmod +x ./prepare.sh
|
||||||
- chmod +x ./test.sh
|
- chmod +x ./test.sh
|
||||||
- rm -r example
|
- rm -r example
|
||||||
- su -c ./prepare.sh test
|
- ./prepare.sh test
|
||||||
- su -c ./test.sh test
|
- ./test.sh test
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- coverage/
|
- coverage/
|
||||||
|
|
|
||||||
|
|
@ -541,7 +541,7 @@ class OlmManager {
|
||||||
if (!deviceKey.checkJsonSignature(fingerprintKey, userId, deviceId)) {
|
if (!deviceKey.checkJsonSignature(fingerprintKey, userId, deviceId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Logs().v('[OlmManager] Starting session with ${userId}:${deviceId}');
|
Logs().v('[OlmManager] Starting session with $userId:$deviceId');
|
||||||
var session = olm.Session();
|
var session = olm.Session();
|
||||||
try {
|
try {
|
||||||
session.create_outbound(_olmAccount, identityKey, deviceKey['key']);
|
session.create_outbound(_olmAccount, identityKey, deviceKey['key']);
|
||||||
|
|
|
||||||
|
|
@ -401,7 +401,7 @@ class SSSS {
|
||||||
|
|
||||||
Future<void> request(String type, [List<DeviceKeys> devices]) async {
|
Future<void> request(String type, [List<DeviceKeys> devices]) async {
|
||||||
// only send to own, verified devices
|
// only send to own, verified devices
|
||||||
Logs().i('[SSSS] Requesting type ${type}...');
|
Logs().i('[SSSS] Requesting type $type...');
|
||||||
if (devices == null || devices.isEmpty) {
|
if (devices == null || devices.isEmpty) {
|
||||||
if (!client.userDeviceKeys.containsKey(client.userID)) {
|
if (!client.userDeviceKeys.containsKey(client.userID)) {
|
||||||
Logs().w('[SSSS] User does not have any devices');
|
Logs().w('[SSSS] User does not have any devices');
|
||||||
|
|
@ -477,12 +477,12 @@ class SSSS {
|
||||||
final type = event.content['name'];
|
final type = event.content['name'];
|
||||||
final secret = await getCached(type);
|
final secret = await getCached(type);
|
||||||
if (secret == null) {
|
if (secret == null) {
|
||||||
Logs().i(
|
Logs()
|
||||||
'[SSSS] We don\'t have the secret for ${type} ourself, ignoring');
|
.i('[SSSS] We don\'t have the secret for $type ourself, ignoring');
|
||||||
return; // seems like we don't have this, either
|
return; // seems like we don't have this, either
|
||||||
}
|
}
|
||||||
// okay, all checks out...time to share this secret!
|
// okay, all checks out...time to share this secret!
|
||||||
Logs().i('[SSSS] Replying with secret for ${type}');
|
Logs().i('[SSSS] Replying with secret for $type');
|
||||||
await client.sendToDeviceEncrypted(
|
await client.sendToDeviceEncrypted(
|
||||||
[device],
|
[device],
|
||||||
EventTypes.SecretSend,
|
EventTypes.SecretSend,
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ class KeyVerification {
|
||||||
await Future.delayed(Duration(milliseconds: 50));
|
await Future.delayed(Duration(milliseconds: 50));
|
||||||
}
|
}
|
||||||
_handlePayloadLock = true;
|
_handlePayloadLock = true;
|
||||||
Logs().i('[Key Verification] Received type ${type}: ' + payload.toString());
|
Logs().i('[Key Verification] Received type $type: ' + payload.toString());
|
||||||
try {
|
try {
|
||||||
var thisLastStep = lastStep;
|
var thisLastStep = lastStep;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
@ -277,7 +277,7 @@ class KeyVerification {
|
||||||
if (payload['method'] == method.type) {
|
if (payload['method'] == method.type) {
|
||||||
// same method. Determine priority
|
// same method. Determine priority
|
||||||
final ourEntry = '${client.userID}|${client.deviceID}';
|
final ourEntry = '${client.userID}|${client.deviceID}';
|
||||||
final entries = [ourEntry, '${userId}|${deviceId}'];
|
final entries = [ourEntry, '$userId|$deviceId'];
|
||||||
entries.sort();
|
entries.sort();
|
||||||
if (entries.first == ourEntry) {
|
if (entries.first == ourEntry) {
|
||||||
// our start won, nothing to do
|
// our start won, nothing to do
|
||||||
|
|
@ -584,14 +584,14 @@ class KeyVerification {
|
||||||
|
|
||||||
Future<void> send(String type, Map<String, dynamic> payload) async {
|
Future<void> send(String type, Map<String, dynamic> payload) async {
|
||||||
makePayload(payload);
|
makePayload(payload);
|
||||||
Logs().i('[Key Verification] Sending type ${type}: ' + payload.toString());
|
Logs().i('[Key Verification] Sending type $type: ' + payload.toString());
|
||||||
if (room != null) {
|
if (room != null) {
|
||||||
Logs().i('[Key Verification] Sending to ${userId} in room ${room.id}...');
|
Logs().i('[Key Verification] Sending to $userId in room ${room.id}...');
|
||||||
if ({EventTypes.KeyVerificationRequest}.contains(type)) {
|
if ({EventTypes.KeyVerificationRequest}.contains(type)) {
|
||||||
payload['msgtype'] = type;
|
payload['msgtype'] = type;
|
||||||
payload['to'] = userId;
|
payload['to'] = userId;
|
||||||
payload['body'] =
|
payload['body'] =
|
||||||
'Attempting verification request. (${type}) Apparently your client doesn\'t support this';
|
'Attempting verification request. ($type) Apparently your client doesn\'t support this';
|
||||||
type = EventTypes.Message;
|
type = EventTypes.Message;
|
||||||
}
|
}
|
||||||
final newTransactionId = await room.sendEvent(payload, type: type);
|
final newTransactionId = await room.sendEvent(payload, type: type);
|
||||||
|
|
@ -600,7 +600,7 @@ class KeyVerification {
|
||||||
encryption.keyVerificationManager.addRequest(this);
|
encryption.keyVerificationManager.addRequest(this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logs().i('[Key Verification] Sending to ${userId} device ${deviceId}...');
|
Logs().i('[Key Verification] Sending to $userId device $deviceId...');
|
||||||
if (deviceId == '*') {
|
if (deviceId == '*') {
|
||||||
if ({
|
if ({
|
||||||
EventTypes.KeyVerificationRequest,
|
EventTypes.KeyVerificationRequest,
|
||||||
|
|
@ -609,7 +609,7 @@ class KeyVerification {
|
||||||
await client.sendToDevicesOfUserIds({userId}, type, payload);
|
await client.sendToDevicesOfUserIds({userId}, type, payload);
|
||||||
} else {
|
} else {
|
||||||
Logs().e(
|
Logs().e(
|
||||||
'[Key Verification] Tried to broadcast and un-broadcastable type: ${type}');
|
'[Key Verification] Tried to broadcast and un-broadcastable type: $type');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await client.sendToDeviceEncrypted(
|
await client.sendToDeviceEncrypted(
|
||||||
|
|
@ -873,7 +873,7 @@ class _KeyVerificationMethodSas extends _KeyVerificationMethod {
|
||||||
final ourInfo =
|
final ourInfo =
|
||||||
'${client.userID}|${client.deviceID}|${sas.get_pubkey()}|';
|
'${client.userID}|${client.deviceID}|${sas.get_pubkey()}|';
|
||||||
final theirInfo =
|
final theirInfo =
|
||||||
'${request.userId}|${request.deviceId}|${theirPublicKey}|';
|
'${request.userId}|${request.deviceId}|$theirPublicKey|';
|
||||||
sasInfo = 'MATRIX_KEY_VERIFICATION_SAS|' +
|
sasInfo = 'MATRIX_KEY_VERIFICATION_SAS|' +
|
||||||
(request.startedVerification
|
(request.startedVerification
|
||||||
? ourInfo + theirInfo
|
? ourInfo + theirInfo
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ class Client extends MatrixApi {
|
||||||
|
|
||||||
String generateUniqueTransactionId() {
|
String generateUniqueTransactionId() {
|
||||||
_transactionCounter++;
|
_transactionCounter++;
|
||||||
return '${clientName}-${_transactionCounter}-${DateTime.now().millisecondsSinceEpoch}';
|
return '$clientName-$_transactionCounter-${DateTime.now().millisecondsSinceEpoch}';
|
||||||
}
|
}
|
||||||
|
|
||||||
Room getRoomByAlias(String alias) {
|
Room getRoomByAlias(String alias) {
|
||||||
|
|
@ -459,7 +459,7 @@ class Client extends MatrixApi {
|
||||||
Logs().e('Logout failed', e, s);
|
Logs().e('Logout failed', e, s);
|
||||||
rethrow;
|
rethrow;
|
||||||
} finally {
|
} finally {
|
||||||
await clear();
|
clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -473,7 +473,7 @@ class Client extends MatrixApi {
|
||||||
Logs().e('Logout all failed', e, s);
|
Logs().e('Logout all failed', e, s);
|
||||||
rethrow;
|
rethrow;
|
||||||
} finally {
|
} finally {
|
||||||
await clear();
|
clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -770,7 +770,7 @@ class Client extends MatrixApi {
|
||||||
/// If one of [newToken], [newUserID], [newDeviceID], [newDeviceName] is set then
|
/// If one of [newToken], [newUserID], [newDeviceID], [newDeviceName] is set then
|
||||||
/// all of them must be set! If you don't set them, this method will try to
|
/// all of them must be set! If you don't set them, this method will try to
|
||||||
/// get them from the database.
|
/// get them from the database.
|
||||||
void init({
|
Future<void> init({
|
||||||
String newToken,
|
String newToken,
|
||||||
Uri newHomeserver,
|
Uri newHomeserver,
|
||||||
String newUserID,
|
String newUserID,
|
||||||
|
|
|
||||||
|
|
@ -385,7 +385,7 @@ class Database extends _$Database {
|
||||||
final Set<String> _ensuredRooms = {};
|
final Set<String> _ensuredRooms = {};
|
||||||
Future<void> storeRoomUpdate(int clientId, sdk.RoomUpdate roomUpdate,
|
Future<void> storeRoomUpdate(int clientId, sdk.RoomUpdate roomUpdate,
|
||||||
[sdk.Room oldRoom]) async {
|
[sdk.Room oldRoom]) async {
|
||||||
final setKey = '${clientId};${roomUpdate.id}';
|
final setKey = '$clientId;${roomUpdate.id}';
|
||||||
if (roomUpdate.membership != api.Membership.leave) {
|
if (roomUpdate.membership != api.Membership.leave) {
|
||||||
if (!_ensuredRooms.contains(setKey)) {
|
if (!_ensuredRooms.contains(setKey)) {
|
||||||
await ensureRoomExists(clientId, roomUpdate.id,
|
await ensureRoomExists(clientId, roomUpdate.id,
|
||||||
|
|
@ -620,7 +620,7 @@ class Database extends _$Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> forgetRoom(int clientId, String roomId) async {
|
Future<void> forgetRoom(int clientId, String roomId) async {
|
||||||
final setKey = '${clientId};${roomId}';
|
final setKey = '$clientId;$roomId';
|
||||||
_ensuredRooms.remove(setKey);
|
_ensuredRooms.remove(setKey);
|
||||||
await (delete(rooms)
|
await (delete(rooms)
|
||||||
..where((r) => r.roomId.equals(roomId) & r.clientId.equals(clientId)))
|
..where((r) => r.roomId.equals(roomId) & r.clientId.equals(clientId)))
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ abstract class SignableKey extends MatrixSignableKey {
|
||||||
}
|
}
|
||||||
visited ??= <String>{};
|
visited ??= <String>{};
|
||||||
onlyValidateUserIds ??= <String>{};
|
onlyValidateUserIds ??= <String>{};
|
||||||
final setKey = '${userId};${identifier}';
|
final setKey = '$userId;$identifier';
|
||||||
if (visited.contains(setKey) ||
|
if (visited.contains(setKey) ||
|
||||||
(onlyValidateUserIds.isNotEmpty &&
|
(onlyValidateUserIds.isNotEmpty &&
|
||||||
!onlyValidateUserIds.contains(userId))) {
|
!onlyValidateUserIds.contains(userId))) {
|
||||||
|
|
@ -310,13 +310,14 @@ abstract class SignableKey extends MatrixSignableKey {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setVerified(bool newVerified, [bool sign = true]) {
|
Future<void> setVerified(bool newVerified, [bool sign = true]) async {
|
||||||
_verified = newVerified;
|
_verified = newVerified;
|
||||||
if (newVerified &&
|
if (newVerified &&
|
||||||
sign &&
|
sign &&
|
||||||
client.encryptionEnabled &&
|
client.encryptionEnabled &&
|
||||||
client.encryption.crossSigning.signable([this])) {
|
client.encryption.crossSigning.signable([this])) {
|
||||||
// sign the key!
|
// sign the key!
|
||||||
|
// ignore: unawaited_futures
|
||||||
client.encryption.crossSigning.sign([this]);
|
client.encryption.crossSigning.sign([this]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -344,8 +345,8 @@ class CrossSigningKey extends SignableKey {
|
||||||
userId != null && publicKey != null && keys != null && ed25519Key != null;
|
userId != null && publicKey != null && keys != null && ed25519Key != null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> setVerified(bool newVerified, [bool sign = true]) {
|
Future<void> setVerified(bool newVerified, [bool sign = true]) async {
|
||||||
super.setVerified(newVerified, sign);
|
await super.setVerified(newVerified, sign);
|
||||||
return client.database?.setVerifiedUserCrossSigningKey(
|
return client.database?.setVerifiedUserCrossSigningKey(
|
||||||
newVerified, client.id, userId, publicKey);
|
newVerified, client.id, userId, publicKey);
|
||||||
}
|
}
|
||||||
|
|
@ -418,8 +419,8 @@ class DeviceKeys extends SignableKey {
|
||||||
selfSigned;
|
selfSigned;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> setVerified(bool newVerified, [bool sign = true]) {
|
Future<void> setVerified(bool newVerified, [bool sign = true]) async {
|
||||||
super.setVerified(newVerified, sign);
|
await super.setVerified(newVerified, sign);
|
||||||
return client?.database
|
return client?.database
|
||||||
?.setVerifiedUserDeviceKey(newVerified, client.id, userId, deviceId);
|
?.setVerifiedUserDeviceKey(newVerified, client.id, userId, deviceId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ class PillSyntax extends InlineSyntax {
|
||||||
}
|
}
|
||||||
final identifier = match[1];
|
final identifier = match[1];
|
||||||
final element = Element.text('a', identifier);
|
final element = Element.text('a', identifier);
|
||||||
element.attributes['href'] = 'https://matrix.to/#/${identifier}';
|
element.attributes['href'] = 'https://matrix.to/#/$identifier';
|
||||||
parser.addNode(element);
|
parser.addNode(element);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -204,7 +204,7 @@ String markdown(String text, [Map<String, Map<String, String>> emotePacks]) {
|
||||||
};
|
};
|
||||||
for (final tag in otherBlockTags) {
|
for (final tag in otherBlockTags) {
|
||||||
// we check for the close tag as the opening one might have attributes
|
// we check for the close tag as the opening one might have attributes
|
||||||
if (ret.contains('</${tag}>')) {
|
if (ret.contains('</$tag>')) {
|
||||||
stripPTags = false;
|
stripPTags = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,7 @@ dev_dependencies:
|
||||||
test_coverage: ^0.5.0
|
test_coverage: ^0.5.0
|
||||||
moor_generator: ^3.4.1
|
moor_generator: ^3.4.1
|
||||||
build_runner: ^1.11.1
|
build_runner: ^1.11.1
|
||||||
pedantic: ^1.9.2
|
pedantic: ^1.11.0
|
||||||
dapackages: ^1.4.0
|
dapackages: ^1.4.0
|
||||||
|
|
||||||
#flutter_test:
|
#flutter_test:
|
||||||
# sdk: flutter
|
# sdk: flutter
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ void main() {
|
||||||
var firstSyncFuture = matrix.onFirstSync.stream.first;
|
var firstSyncFuture = matrix.onFirstSync.stream.first;
|
||||||
var syncFuture = matrix.onSync.stream.first;
|
var syncFuture = matrix.onSync.stream.first;
|
||||||
|
|
||||||
matrix.init(
|
await matrix.init(
|
||||||
newToken: 'abcd',
|
newToken: 'abcd',
|
||||||
newUserID: '@test:fakeServer.notExisting',
|
newUserID: '@test:fakeServer.notExisting',
|
||||||
newHomeserver: matrix.homeserver,
|
newHomeserver: matrix.homeserver,
|
||||||
|
|
@ -520,7 +520,7 @@ void main() {
|
||||||
databaseBuilder: (_) => database,
|
databaseBuilder: (_) => database,
|
||||||
);
|
);
|
||||||
|
|
||||||
client1.init(
|
await client1.init(
|
||||||
newToken: 'abc123',
|
newToken: 'abc123',
|
||||||
newUserID: '@test:fakeServer.notExisting',
|
newUserID: '@test:fakeServer.notExisting',
|
||||||
newHomeserver: Uri.parse('https://fakeServer.notExisting'),
|
newHomeserver: Uri.parse('https://fakeServer.notExisting'),
|
||||||
|
|
@ -540,7 +540,7 @@ void main() {
|
||||||
databaseBuilder: (_) => database,
|
databaseBuilder: (_) => database,
|
||||||
);
|
);
|
||||||
|
|
||||||
client2.init();
|
await client2.init();
|
||||||
await Future.delayed(Duration(milliseconds: 100));
|
await Future.delayed(Duration(milliseconds: 100));
|
||||||
|
|
||||||
expect(client2.isLogged(), true);
|
expect(client2.isLogged(), true);
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ void main() {
|
||||||
await client.abortSync();
|
await client.abortSync();
|
||||||
await otherClient.checkHomeserver('https://fakeserver.notexisting',
|
await otherClient.checkHomeserver('https://fakeserver.notexisting',
|
||||||
checkWellKnown: false);
|
checkWellKnown: false);
|
||||||
otherClient.init(
|
await otherClient.init(
|
||||||
newToken: 'abc',
|
newToken: 'abc',
|
||||||
newUserID: '@othertest:fakeServer.notExisting',
|
newUserID: '@othertest:fakeServer.notExisting',
|
||||||
newHomeserver: otherClient.homeserver,
|
newHomeserver: otherClient.homeserver,
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ void main() {
|
||||||
databaseBuilder: (_) => client1.database);
|
databaseBuilder: (_) => client1.database);
|
||||||
await client2.checkHomeserver('https://fakeserver.notexisting',
|
await client2.checkHomeserver('https://fakeserver.notexisting',
|
||||||
checkWellKnown: false);
|
checkWellKnown: false);
|
||||||
client2.init(
|
await client2.init(
|
||||||
newToken: 'abc',
|
newToken: 'abc',
|
||||||
newUserID: '@othertest:fakeServer.notExisting',
|
newUserID: '@othertest:fakeServer.notExisting',
|
||||||
newHomeserver: client2.homeserver,
|
newHomeserver: client2.homeserver,
|
||||||
|
|
|
||||||
|
|
@ -470,15 +470,15 @@ void main() {
|
||||||
// with passphrase
|
// with passphrase
|
||||||
var newKey = await client.encryption.ssss.createKey('test');
|
var newKey = await client.encryption.ssss.createKey('test');
|
||||||
expect(client.encryption.ssss.isKeyValid(newKey.keyId), true);
|
expect(client.encryption.ssss.isKeyValid(newKey.keyId), true);
|
||||||
var testKey = await client.encryption.ssss.open(newKey.keyId);
|
var testKey = client.encryption.ssss.open(newKey.keyId);
|
||||||
await testKey.unlock(passphrase: 'test');
|
await testKey.unlock(passphrase: 'test');
|
||||||
await testKey.setPrivateKey(newKey.privateKey);
|
testKey.setPrivateKey(newKey.privateKey);
|
||||||
|
|
||||||
// without passphrase
|
// without passphrase
|
||||||
newKey = await client.encryption.ssss.createKey();
|
newKey = await client.encryption.ssss.createKey();
|
||||||
expect(client.encryption.ssss.isKeyValid(newKey.keyId), true);
|
expect(client.encryption.ssss.isKeyValid(newKey.keyId), true);
|
||||||
testKey = await client.encryption.ssss.open(newKey.keyId);
|
testKey = client.encryption.ssss.open(newKey.keyId);
|
||||||
await testKey.setPrivateKey(newKey.privateKey);
|
testKey.setPrivateKey(newKey.privateKey);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('dispose client', () async {
|
test('dispose client', () async {
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ Future<Client> getClient() async {
|
||||||
FakeMatrixApi.client = client;
|
FakeMatrixApi.client = client;
|
||||||
await client.checkHomeserver('https://fakeServer.notExisting',
|
await client.checkHomeserver('https://fakeServer.notExisting',
|
||||||
checkWellKnown: false);
|
checkWellKnown: false);
|
||||||
client.init(
|
await client.init(
|
||||||
newToken: 'abcd',
|
newToken: 'abcd',
|
||||||
newUserID: '@test:fakeServer.notExisting',
|
newUserID: '@test:fakeServer.notExisting',
|
||||||
newHomeserver: client.homeserver,
|
newHomeserver: client.homeserver,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue