Skip to content

Commit

Permalink
Fix/prefer is empty lint (#510)
Browse files Browse the repository at this point in the history
* make sure the session terminates

* fix prefer_is_empty lint rule warnings

---------

Co-authored-by: Victor Uvarov <[email protected]>
  • Loading branch information
victortive and VictorUvarov authored Dec 27, 2024
1 parent 04a7652 commit 3d34f90
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ analyzer:
library_prefixes: ignore
unused_field: ignore
avoid_init_to_null: ignore
prefer_is_empty: ignore
unused_element: ignore
curly_braces_in_flow_control_structures: ignore
unnecessary_null_in_if_null_operators: ignore
Expand Down
2 changes: 1 addition & 1 deletion lib/src/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Checks {
* List of Objects and Socket: [{socket: socket1}, socket2]
*/
List<SIPUASocketInterface> copy = <SIPUASocketInterface>[];
if (sockets is List && sockets!.length > 0) {
if (sockets is List && sockets!.isNotEmpty) {
for (SIPUASocketInterface socket in sockets) {
copy.add(socket);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/name_addr_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class NameAddrHeader {

@override
String toString() {
String body = (_display_name != null && _display_name!.length > 0)
String body = (_display_name != null && _display_name!.isNotEmpty)
? '"${_quote(_display_name!)}" '
: '';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/rtc_session/dtmf.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class DTMF extends EventManager {
if (request.body != null) {
List<String> body = request.body!.split('\n');

if (body.length >= 1) {
if (body.isNotEmpty) {
if (body[0].contains(RegExp(reg_tone))) {
_tone = body[0].replaceAll(reg_tone, '\$2');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/socket_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SocketTransport {
_recovery_options = recovery_options;

// We must recieve at least 1 socket
if (sockets!.length == 0) {
if (sockets!.isEmpty) {
throw Exceptions.TypeError(
'invalid argument: Must recieve atleast 1 web socket');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/transports/tcp_socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class SIPUATcpSocket extends SIPUASocketInterface {
void _onMessage(dynamic data) {
logger.d('Received TcpSocket data');
if (data != null) {
if (data.toString().trim().length > 0) {
if (data.toString().trim().isNotEmpty) {
ondata!(data);
} else {
logger.d('Received and ignored empty packet');
Expand Down
2 changes: 1 addition & 1 deletion lib/src/transports/web_socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class SIPUAWebSocket extends SIPUASocketInterface {
void _onMessage(dynamic data) {
logger.d('Received WebSocket message');
if (data != null) {
if (data.toString().trim().length > 0) {
if (data.toString().trim().isNotEmpty) {
ondata!(data);
} else {
logger.d('Received and ignored empty packet');
Expand Down
2 changes: 1 addition & 1 deletion lib/src/uri.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class URI {
});
});

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

Expand Down

0 comments on commit 3d34f90

Please sign in to comment.