From a7ee9a790281ab00802262ed4c690a173f9ec6c3 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Thu, 6 Jan 2022 07:30:04 +0100 Subject: [PATCH] add 'no critic' sections, add keepAliveCheckTime to commandref --- 82_LGTV_WebOS.pm | 50 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/82_LGTV_WebOS.pm b/82_LGTV_WebOS.pm index dcd9959..c55b4f9 100644 --- a/82_LGTV_WebOS.pm +++ b/82_LGTV_WebOS.pm @@ -54,9 +54,13 @@ my $missingModul = ""; eval { require MIME::Base64; 1 } or $missingModul .= "MIME::Base64 "; eval { require IO::Socket::INET; 1 } or $missingModul .= "IO::Socket::INET "; + +## no critic (Conditional "use" statement. Use "require" to conditionally include a module (Modules::ProhibitConditionalUseStatements)) eval { use Digest::SHA qw /sha1_hex/; 1 } or $missingModul .= "Digest::SHA "; eval { use Encode qw /encode_utf8 decode_utf8/; 1 } or $missingModul .= "Encode "; +## use critic + eval { require Blocking; 1 } or $missingModul .= "Blocking "; # try to use JSON::MaybeXS wrapper @@ -401,7 +405,8 @@ sub LGTV_WebOS_TimerStatusRequest { return; } -sub LGTV_WebOS_Set { +sub LGTV_WebOS_Set +{ ## no critic (Subroutine "LGTV_WebOS_Set" with high complexity score) my ( $hash, $name, $cmd, @args ) = @_; my ( $arg, @params ) = @args; @@ -624,10 +629,13 @@ sub LGTV_WebOS_Set { $list .= ' 3D:on,off stop:noArg play:noArg pause:noArg rewind:noArg fastForward:noArg clearInputList:noArg channel'; $list .= + ## no critic (Expression form of map. See page 169 of PBP) ' launchApp:' . join( ',', => map qq{$_} => keys %openApps ); - $list .= ' input:' - . join( ',', - => map qq{$_} => keys %{ $hash->{helper}{device}{inputs} } ) + $list .= ' input:' . join( + ',', + ## no critic (Expression form of map. See page 169 of PBP) + => map qq{$_} => keys %{ $hash->{helper}{device}{inputs} } + ) if ( defined( $hash->{helper}{device}{inputs} ) && ref( $hash->{helper}{device}{inputs} ) eq "HASH" ); @@ -754,7 +762,9 @@ sub LGTV_WebOS_Read { if ( $buf =~ /(\{"type":".+}}$)/x ) { $buf =~ /(\{"type":".+}}$)/x; + ## no critic (Capture variable used outside conditional. See page 253 of PBP) $buf = $1; + ## use critic Log3( $name, 4, "LGTV_WebOS ($name) - received correct JSON string, start response processing: $buf" @@ -1703,19 +1713,20 @@ sub LGTV_WebOS_PresenceRun { my $tmp; my $response; - $tmp = qx(ping -c 3 -w 2 $host 2>&1); + $tmp = qx(ping -c 3 -w 2 $host 2>&1); ## no critic (Backtick operator used) if ( defined($tmp) && $tmp ne "" ) { chomp $tmp; Log3( $name, 4, "LGTV_WebOS ($name) - ping command returned with output:\n$tmp" ); - $response = "$name|" - . ( - ( $tmp =~ /\d+ [Bb]ytes (from|von)/x && $tmp !~ /[Uu]nreachable/x ) - ? "present" - : "absent" - ); + $response = $name . '|' . ( + $tmp =~ + /\d+ [Bb]ytes (from|von)/ ## no critic (Regular expression without "/x") + && $tmp !~ /[Uu]nreachable/x + ? 'present' + : 'absent' + ); } else { @@ -1901,6 +1912,12 @@ sub LGTV_WebOS_WakeUp_Udp { current state of ping presence from TV. create a reading presence with values absent or present. + +