Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update lints version #344

Merged
merged 1 commit into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/src/dbus_address.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class DBusAddress {

/// Gets this address in string format.
String get value {
return '$transport:' +
properties.keys
.map((key) => '$key=${_encodeValue(properties[key]!)}')
.join(',');
var propertyString = properties.keys
.map((key) => '$key=${_encodeValue(properties[key]!)}')
.join(',');
return '$transport:$propertyString';
}

/// Creates a new address from the given [address] string, e.g. 'unix:path=/run/user/1000/bus'.
Expand Down Expand Up @@ -149,7 +149,7 @@ class DBusAddress {
{
escapedValue += utf8.decode([byte]);
} else {
escapedValue += '%' + byte.toRadixString(16).padLeft(2, '0');
escapedValue += '%${byte.toRadixString(16).padLeft(2, '0')}';
}
}
return escapedValue;
Expand Down
13 changes: 6 additions & 7 deletions lib/src/dbus_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,11 @@ class DBusProcessCredentials {
'otherCredentials':
otherCredentials.isNotEmpty ? otherCredentials.toString() : null
};
return 'DBusProcessCredentials(' +
parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key=${parameters[key]}')
.join(', ') +
')';
var parameterString = parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key=${parameters[key]}')
.join(', ');
return 'DBusProcessCredentials($parameterString)';
}
}

Expand Down Expand Up @@ -787,7 +786,7 @@ class DBusClient {

await _openSocket();
_authClient.requests
.listen((message) => _socket?.write(utf8.encode(message + '\r\n')));
.listen((message) => _socket?.write(utf8.encode('$message\r\n')));
await _authClient.done;
_authComplete = true;
if (!_authClient.isAuthenticated) {
Expand Down
9 changes: 5 additions & 4 deletions lib/src/dbus_code_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class DBusCodeGenerator {
/// If provided [comment] is added to the top of the source.
DBusCodeGenerator(this.node, {String? comment, String? className})
: _comment = comment {
var _className = className ?? _nodeToClassName();
if (_className == null) {
var className_ = className ?? _nodeToClassName();
if (className_ == null) {
throw 'Unable to determine class name';
}
this.className = _className;
this.className = className_;
}

/// Generates Dart code for a client to access the given D-Bus interface.
Expand Down Expand Up @@ -60,7 +60,8 @@ class DBusCodeGenerator {
var source = '';

if (_comment != null) {
source += '// ' + _comment!.split('\n').join('\n// ') + '\n\n';
var escapedComment = _comment!.split('\n').join('\n// ');
source += '// $escapedComment\n\n';
}

return source;
Expand Down
76 changes: 35 additions & 41 deletions lib/src/dbus_introspect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ class DBusIntrospectNode {
'interfaces': interfaces.isNotEmpty ? interfaces.toString() : null,
'children': children.isNotEmpty ? children.toString() : null
};
return 'DBusIntrospectNode(' +
parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}')
.join(', ') +
')';
var parameterString = parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}')
.join(', ');
return 'DBusIntrospectNode($parameterString)';
}

@override
Expand Down Expand Up @@ -154,13 +153,12 @@ class DBusIntrospectInterface {
'signals': signals.isNotEmpty ? signals.toString() : null,
'properties': properties.isNotEmpty ? properties.toString() : null
};
return 'DBusIntrospectInterface(' +
["'$name'"]
.followedBy(parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}'))
.join(', ') +
')';
var parameterString = ["'$name'"]
.followedBy(parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}'))
.join(', ');
return 'DBusIntrospectInterface($parameterString)';
}

@override
Expand Down Expand Up @@ -234,13 +232,12 @@ class DBusIntrospectMethod {
'args': args.isNotEmpty ? args.toString() : null,
'annotations': annotations.isNotEmpty ? annotations.toString() : null
};
return 'DBusIntrospectMethod(' +
["'$name'"]
.followedBy(parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}'))
.join(', ') +
')';
var parameterString = ["'$name'"]
.followedBy(parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}'))
.join(', ');
return 'DBusIntrospectMethod($parameterString)';
}

@override
Expand Down Expand Up @@ -303,13 +300,12 @@ class DBusIntrospectSignal {
'args': args.isNotEmpty ? args.toString() : null,
'annotations': annotations.isNotEmpty ? annotations.toString() : null
};
return 'DBusIntrospectSignal(' +
["'$name'"]
.followedBy(parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}'))
.join(', ') +
')';
var parameterString = ["'$name'"]
.followedBy(parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}'))
.join(', ');
return 'DBusIntrospectSignal($parameterString)';
}

@override
Expand Down Expand Up @@ -391,13 +387,12 @@ class DBusIntrospectProperty {
access != DBusPropertyAccess.readwrite ? access.toString() : null,
'annotations': annotations.isNotEmpty ? annotations.toString() : null
};
return 'DBusIntrospectProperty(' +
["'$name'", type.toString()]
.followedBy(parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}'))
.join(', ') +
')';
var parameterString = ["'$name'", type.toString()]
.followedBy(parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}'))
.join(', ');
return 'DBusIntrospectProperty($parameterString)';
}

@override
Expand Down Expand Up @@ -477,13 +472,12 @@ class DBusIntrospectArgument {
'name': name != null ? "'$name'" : null,
'annotations': annotations.isNotEmpty ? annotations.toString() : null
};
return 'DBusIntrospectArgument(' +
[type.toString(), direction.toString()]
.followedBy(parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}'))
.join(', ') +
')';
var parameterString = [type.toString(), direction.toString()]
.followedBy(parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}'))
.join(', ');
return 'DBusIntrospectArgument($parameterString)';
}

@override
Expand Down
14 changes: 7 additions & 7 deletions lib/src/dbus_match_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ class DBusMatchRule {
/// Escapes a string value.
String _escapeString(String value) {
// Replace quotes with: End quotes, escaped quote, start quotes again.
return "'" + value.replaceAll("'", "'\\''") + "'";
var escapedValue = value.replaceAll("'", "'\\''");
return "'$escapedValue'";
}

/// True if the rule matches the supplied values.
Expand Down Expand Up @@ -220,11 +221,10 @@ class DBusMatchRule {
'path': path?.toString(),
'pathNamespace': pathNamespace?.toString()
};
return 'DBusMatchRule(' +
parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key=${parameters[key]}')
.join(', ') +
')';
var parameterString = parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key=${parameters[key]}')
.join(', ');
return 'DBusMatchRule($parameterString)';
}
}
11 changes: 5 additions & 6 deletions lib/src/dbus_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,10 @@ class DBusMessage {
'sender': sender?.toString(),
'values': values.isNotEmpty ? values.toString() : null
};
return 'DBusMessage(' +
parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}')
.join(', ') +
')';
var parameterString = parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}')
.join(', ');
return 'DBusMessage($parameterString)';
}
}
11 changes: 5 additions & 6 deletions lib/src/dbus_method_call.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ class DBusMethodCall {
'allowInteractiveAuthorization':
allowInteractiveAuthorization ? 'true' : null
};
return 'DBusMethodCall(' +
parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}')
.join(', ') +
')';
var parameterString = parameters.keys
.where((key) => parameters[key] != null)
.map((key) => '$key: ${parameters[key]}')
.join(', ');
return 'DBusMethodCall($parameterString)';
}
}
2 changes: 1 addition & 1 deletion lib/src/dbus_read_buffer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ class DBusReadBuffer extends DBusBuffer {
if (d >= 33 && d <= 126) {
s += String.fromCharCode(d);
} else {
s += '\\' + d.toRadixString(8);
s += '\\${d.toRadixString(8)}';
}
}
return "DBusReadBuffer('$s')";
Expand Down
2 changes: 1 addition & 1 deletion lib/src/dbus_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class _DBusRemoteClient {
_DBusRemoteClient(this.serverSocket, this._socket, this.uniqueName)
: _authServer = DBusAuthServer(serverSocket.uuid, unixFdSupported: true) {
_authServer.responses
.listen((message) => _socket.write(utf8.encode(message + '\r\n')));
.listen((message) => _socket.write(utf8.encode('$message\r\n')));
_socket.listen((event) {
if (event == RawSocketEvent.read) {
_readData();
Expand Down
Loading