Merge branch 'krille/update-pedantic' into 'main'

refactor: Update pedantic

See merge request famedly/famedlysdk!665
This commit is contained in:
Sorunome 2021-03-09 17:28:04 +00:00
commit 3f2ced692f
14 changed files with 41 additions and 41 deletions

View File

@ -24,8 +24,8 @@ coverage:
- chmod +x ./prepare.sh
- chmod +x ./test.sh
- rm -r example
- su -c ./prepare.sh test
- su -c ./test.sh test
- ./prepare.sh test
- ./test.sh test
artifacts:
paths:
- coverage/

View File

@ -541,7 +541,7 @@ class OlmManager {
if (!deviceKey.checkJsonSignature(fingerprintKey, userId, deviceId)) {
continue;
}
Logs().v('[OlmManager] Starting session with ${userId}:${deviceId}');
Logs().v('[OlmManager] Starting session with $userId:$deviceId');
var session = olm.Session();
try {
session.create_outbound(_olmAccount, identityKey, deviceKey['key']);

View File

@ -401,7 +401,7 @@ class SSSS {
Future<void> request(String type, [List<DeviceKeys> devices]) async {
// only send to own, verified devices
Logs().i('[SSSS] Requesting type ${type}...');
Logs().i('[SSSS] Requesting type $type...');
if (devices == null || devices.isEmpty) {
if (!client.userDeviceKeys.containsKey(client.userID)) {
Logs().w('[SSSS] User does not have any devices');
@ -477,12 +477,12 @@ class SSSS {
final type = event.content['name'];
final secret = await getCached(type);
if (secret == null) {
Logs().i(
'[SSSS] We don\'t have the secret for ${type} ourself, ignoring');
Logs()
.i('[SSSS] We don\'t have the secret for $type ourself, ignoring');
return; // seems like we don't have this, either
}
// 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(
[device],
EventTypes.SecretSend,

View File

@ -208,7 +208,7 @@ class KeyVerification {
await Future.delayed(Duration(milliseconds: 50));
}
_handlePayloadLock = true;
Logs().i('[Key Verification] Received type ${type}: ' + payload.toString());
Logs().i('[Key Verification] Received type $type: ' + payload.toString());
try {
var thisLastStep = lastStep;
switch (type) {
@ -277,7 +277,7 @@ class KeyVerification {
if (payload['method'] == method.type) {
// same method. Determine priority
final ourEntry = '${client.userID}|${client.deviceID}';
final entries = [ourEntry, '${userId}|${deviceId}'];
final entries = [ourEntry, '$userId|$deviceId'];
entries.sort();
if (entries.first == ourEntry) {
// our start won, nothing to do
@ -584,14 +584,14 @@ class KeyVerification {
Future<void> send(String type, Map<String, dynamic> payload) async {
makePayload(payload);
Logs().i('[Key Verification] Sending type ${type}: ' + payload.toString());
Logs().i('[Key Verification] Sending type $type: ' + payload.toString());
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)) {
payload['msgtype'] = type;
payload['to'] = userId;
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;
}
final newTransactionId = await room.sendEvent(payload, type: type);
@ -600,7 +600,7 @@ class KeyVerification {
encryption.keyVerificationManager.addRequest(this);
}
} else {
Logs().i('[Key Verification] Sending to ${userId} device ${deviceId}...');
Logs().i('[Key Verification] Sending to $userId device $deviceId...');
if (deviceId == '*') {
if ({
EventTypes.KeyVerificationRequest,
@ -609,7 +609,7 @@ class KeyVerification {
await client.sendToDevicesOfUserIds({userId}, type, payload);
} else {
Logs().e(
'[Key Verification] Tried to broadcast and un-broadcastable type: ${type}');
'[Key Verification] Tried to broadcast and un-broadcastable type: $type');
}
} else {
await client.sendToDeviceEncrypted(
@ -873,7 +873,7 @@ class _KeyVerificationMethodSas extends _KeyVerificationMethod {
final ourInfo =
'${client.userID}|${client.deviceID}|${sas.get_pubkey()}|';
final theirInfo =
'${request.userId}|${request.deviceId}|${theirPublicKey}|';
'${request.userId}|${request.deviceId}|$theirPublicKey|';
sasInfo = 'MATRIX_KEY_VERIFICATION_SAS|' +
(request.startedVerification
? ourInfo + theirInfo

View File

@ -223,7 +223,7 @@ class Client extends MatrixApi {
String generateUniqueTransactionId() {
_transactionCounter++;
return '${clientName}-${_transactionCounter}-${DateTime.now().millisecondsSinceEpoch}';
return '$clientName-$_transactionCounter-${DateTime.now().millisecondsSinceEpoch}';
}
Room getRoomByAlias(String alias) {
@ -459,7 +459,7 @@ class Client extends MatrixApi {
Logs().e('Logout failed', e, s);
rethrow;
} finally {
await clear();
clear();
}
}
@ -473,7 +473,7 @@ class Client extends MatrixApi {
Logs().e('Logout all failed', e, s);
rethrow;
} finally {
await clear();
clear();
}
}
@ -770,7 +770,7 @@ class Client extends MatrixApi {
/// 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
/// get them from the database.
void init({
Future<void> init({
String newToken,
Uri newHomeserver,
String newUserID,

View File

@ -385,7 +385,7 @@ class Database extends _$Database {
final Set<String> _ensuredRooms = {};
Future<void> storeRoomUpdate(int clientId, sdk.RoomUpdate roomUpdate,
[sdk.Room oldRoom]) async {
final setKey = '${clientId};${roomUpdate.id}';
final setKey = '$clientId;${roomUpdate.id}';
if (roomUpdate.membership != api.Membership.leave) {
if (!_ensuredRooms.contains(setKey)) {
await ensureRoomExists(clientId, roomUpdate.id,
@ -620,7 +620,7 @@ class Database extends _$Database {
}
Future<void> forgetRoom(int clientId, String roomId) async {
final setKey = '${clientId};${roomId}';
final setKey = '$clientId;$roomId';
_ensuredRooms.remove(setKey);
await (delete(rooms)
..where((r) => r.roomId.equals(roomId) & r.clientId.equals(clientId)))

View File

@ -215,7 +215,7 @@ abstract class SignableKey extends MatrixSignableKey {
}
visited ??= <String>{};
onlyValidateUserIds ??= <String>{};
final setKey = '${userId};${identifier}';
final setKey = '$userId;$identifier';
if (visited.contains(setKey) ||
(onlyValidateUserIds.isNotEmpty &&
!onlyValidateUserIds.contains(userId))) {
@ -310,13 +310,14 @@ abstract class SignableKey extends MatrixSignableKey {
return false;
}
void setVerified(bool newVerified, [bool sign = true]) {
Future<void> setVerified(bool newVerified, [bool sign = true]) async {
_verified = newVerified;
if (newVerified &&
sign &&
client.encryptionEnabled &&
client.encryption.crossSigning.signable([this])) {
// sign the key!
// ignore: unawaited_futures
client.encryption.crossSigning.sign([this]);
}
}
@ -344,8 +345,8 @@ class CrossSigningKey extends SignableKey {
userId != null && publicKey != null && keys != null && ed25519Key != null;
@override
Future<void> setVerified(bool newVerified, [bool sign = true]) {
super.setVerified(newVerified, sign);
Future<void> setVerified(bool newVerified, [bool sign = true]) async {
await super.setVerified(newVerified, sign);
return client.database?.setVerifiedUserCrossSigningKey(
newVerified, client.id, userId, publicKey);
}
@ -418,8 +419,8 @@ class DeviceKeys extends SignableKey {
selfSigned;
@override
Future<void> setVerified(bool newVerified, [bool sign = true]) {
super.setVerified(newVerified, sign);
Future<void> setVerified(bool newVerified, [bool sign = true]) async {
await super.setVerified(newVerified, sign);
return client?.database
?.setVerifiedUserDeviceKey(newVerified, client.id, userId, deviceId);
}

View File

@ -162,7 +162,7 @@ class PillSyntax extends InlineSyntax {
}
final identifier = match[1];
final element = Element.text('a', identifier);
element.attributes['href'] = 'https://matrix.to/#/${identifier}';
element.attributes['href'] = 'https://matrix.to/#/$identifier';
parser.addNode(element);
return true;
}
@ -204,7 +204,7 @@ String markdown(String text, [Map<String, Map<String, String>> emotePacks]) {
};
for (final tag in otherBlockTags) {
// we check for the close tag as the opening one might have attributes
if (ret.contains('</${tag}>')) {
if (ret.contains('</$tag>')) {
stripPTags = false;
break;
}

View File

@ -30,8 +30,7 @@ dev_dependencies:
test_coverage: ^0.5.0
moor_generator: ^3.4.1
build_runner: ^1.11.1
pedantic: ^1.9.2
pedantic: ^1.11.0
dapackages: ^1.4.0
#flutter_test:
# sdk: flutter

View File

@ -99,7 +99,7 @@ void main() {
var firstSyncFuture = matrix.onFirstSync.stream.first;
var syncFuture = matrix.onSync.stream.first;
matrix.init(
await matrix.init(
newToken: 'abcd',
newUserID: '@test:fakeServer.notExisting',
newHomeserver: matrix.homeserver,
@ -520,7 +520,7 @@ void main() {
databaseBuilder: (_) => database,
);
client1.init(
await client1.init(
newToken: 'abc123',
newUserID: '@test:fakeServer.notExisting',
newHomeserver: Uri.parse('https://fakeServer.notExisting'),
@ -540,7 +540,7 @@ void main() {
databaseBuilder: (_) => database,
);
client2.init();
await client2.init();
await Future.delayed(Duration(milliseconds: 100));
expect(client2.isLogged(), true);

View File

@ -55,7 +55,7 @@ void main() {
await client.abortSync();
await otherClient.checkHomeserver('https://fakeserver.notexisting',
checkWellKnown: false);
otherClient.init(
await otherClient.init(
newToken: 'abc',
newUserID: '@othertest:fakeServer.notExisting',
newHomeserver: otherClient.homeserver,

View File

@ -88,7 +88,7 @@ void main() {
databaseBuilder: (_) => client1.database);
await client2.checkHomeserver('https://fakeserver.notexisting',
checkWellKnown: false);
client2.init(
await client2.init(
newToken: 'abc',
newUserID: '@othertest:fakeServer.notExisting',
newHomeserver: client2.homeserver,

View File

@ -470,15 +470,15 @@ void main() {
// with passphrase
var newKey = await client.encryption.ssss.createKey('test');
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.setPrivateKey(newKey.privateKey);
testKey.setPrivateKey(newKey.privateKey);
// without passphrase
newKey = await client.encryption.ssss.createKey();
expect(client.encryption.ssss.isKeyValid(newKey.keyId), true);
testKey = await client.encryption.ssss.open(newKey.keyId);
await testKey.setPrivateKey(newKey.privateKey);
testKey = client.encryption.ssss.open(newKey.keyId);
testKey.setPrivateKey(newKey.privateKey);
});
test('dispose client', () async {

View File

@ -37,7 +37,7 @@ Future<Client> getClient() async {
FakeMatrixApi.client = client;
await client.checkHomeserver('https://fakeServer.notExisting',
checkWellKnown: false);
client.init(
await client.init(
newToken: 'abcd',
newUserID: '@test:fakeServer.notExisting',
newHomeserver: client.homeserver,