Skip to content

Commit 3d34f90

Browse files
Fix/prefer is empty lint (#510)
* make sure the session terminates * fix prefer_is_empty lint rule warnings --------- Co-authored-by: Victor Uvarov <victoruvarov23@gmail.com>
1 parent 04a7652 commit 3d34f90

File tree

8 files changed

+7
-8
lines changed

8 files changed

+7
-8
lines changed

analysis_options.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ analyzer:
4545
library_prefixes: ignore
4646
unused_field: ignore
4747
avoid_init_to_null: ignore
48-
prefer_is_empty: ignore
4948
unused_element: ignore
5049
curly_braces_in_flow_control_structures: ignore
5150
unnecessary_null_in_if_null_operators: ignore

lib/src/config.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Checks {
8585
* List of Objects and Socket: [{socket: socket1}, socket2]
8686
*/
8787
List<SIPUASocketInterface> copy = <SIPUASocketInterface>[];
88-
if (sockets is List && sockets!.length > 0) {
88+
if (sockets is List && sockets!.isNotEmpty) {
8989
for (SIPUASocketInterface socket in sockets) {
9090
copy.add(socket);
9191
}

lib/src/name_addr_header.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class NameAddrHeader {
8989

9090
@override
9191
String toString() {
92-
String body = (_display_name != null && _display_name!.length > 0)
92+
String body = (_display_name != null && _display_name!.isNotEmpty)
9393
? '"${_quote(_display_name!)}" '
9494
: '';
9595

lib/src/rtc_session/dtmf.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class DTMF extends EventManager {
120120
if (request.body != null) {
121121
List<String> body = request.body!.split('\n');
122122

123-
if (body.length >= 1) {
123+
if (body.isNotEmpty) {
124124
if (body[0].contains(RegExp(reg_tone))) {
125125
_tone = body[0].replaceAll(reg_tone, '\$2');
126126
}

lib/src/socket_transport.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class SocketTransport {
4646
_recovery_options = recovery_options;
4747

4848
// We must recieve at least 1 socket
49-
if (sockets!.length == 0) {
49+
if (sockets!.isEmpty) {
5050
throw Exceptions.TypeError(
5151
'invalid argument: Must recieve atleast 1 web socket');
5252
}

lib/src/transports/tcp_socket.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class SIPUATcpSocket extends SIPUASocketInterface {
166166
void _onMessage(dynamic data) {
167167
logger.d('Received TcpSocket data');
168168
if (data != null) {
169-
if (data.toString().trim().length > 0) {
169+
if (data.toString().trim().isNotEmpty) {
170170
ondata!(data);
171171
} else {
172172
logger.d('Received and ignored empty packet');

lib/src/transports/web_socket.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class SIPUAWebSocket extends SIPUASocketInterface {
175175
void _onMessage(dynamic data) {
176176
logger.d('Received WebSocket message');
177177
if (data != null) {
178-
if (data.toString().trim().length > 0) {
178+
if (data.toString().trim().isNotEmpty) {
179179
ondata!(data);
180180
} else {
181181
logger.d('Received and ignored empty packet');

lib/src/uri.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class URI {
181181
});
182182
});
183183

184-
if (headers.length > 0) {
184+
if (headers.isNotEmpty) {
185185
uri += '?${headers.join('&')}';
186186
}
187187

0 commit comments

Comments
 (0)