Webqq/Client/Util.pm

filter: Statementstmt 20.7% 11 / 53 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 33.3% 3 / 9 Podpod 0.0% 0 / 6 totaltotal 14.8% 14 / 94 CC 12 SCAR 30.8
CC
12
Cov
15%
truncate
42.0
hash
30.0
code2state
6.0
CRAP 21.6
« Webqq/Client/Method/_get_group_list_info.pm ↑ Summary Webqq/Client/Plugin.pm »
1 package Webqq::Client::Util;
2 1 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Encode::Locale;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 our @EXPORT_OK = qw(console console_stderr hash truncate code2state code2client) ;
6 0 ▶sub console{
Subroutine console: not called CC=1 SCAR=6.9
Pod undocumented
7 0 my $bytes = join "",@_;
8 0 print encode("locale",decode("utf8",$bytes));
9 }
10 0 ▶sub console_stderr{
Subroutine console_stderr: not called CC=1 SCAR=6.9
Pod undocumented
11 0 my $bytes = join "",@_;
12 0 print STDERR encode("locale",decode("utf8",$bytes));
13 }
14  
15 #获取好友列表和群列表的hash函数
16 0 ▶sub hash {
Subroutine hash: not called CC=5 SCAR=34.0
Pod undocumented
17 0 my $ptwebqq = shift;
18 0 my $uin = shift;
19  
20 0 $uin .= "";
21 0 my @N;
22 0 ▶ for(my $T =0;$T<length($ptwebqq);$T++){
Branch: 1 branch
BranchTrueFalseTotal
if ($T < length $ptwebqq) 0 0 0
23 0 $N[$T % 4] ^= ord(substr($ptwebqq,$T,1));
24 }
25 0 my @U = ("EC", "OK");
26 0 my @V;
27 0 $V[0] = $uin >> 24 & 255 ^ ord(substr($U[0],0,1));
28 0 $V[1] = $uin >> 16 & 255 ^ ord(substr($U[0],1,1));
29 0 $V[2] = $uin >> 8 & 255 ^ ord(substr($U[1],0,1));
30 0 $V[3] = $uin & 255 ^ ord(substr($U[1],1,1));
31 0 @U = ();
32 0 ▶ for(my $T=0;$T<8;$T++){
Branch: 1 branch
BranchTrueFalseTotal
if ($T < 8) 0 0 0
33 0 ▶ $U[$T] = $T%2==0?$N[$T>>1]:$V[$T>>1];
Branch: 1 branch
BranchTrueFalseTotal
$T % 2 == 0 ? : 0 0 0
34 }
35 0 @N = ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
36 0 my $V = "";
37 0 ▶ for($T=0;$T<@U;$T++){
Branch: 1 branch
BranchTrueFalseTotal
if ($T < @U) 0 0 0
38 0 $V .= $N[$U[$T] >> 4 & 15];
39 0 $V .= $N[$U[$T] & 15];
40 }
41  
42 0 return $V;
43
44 }
45  
46 0 ▶sub truncate {
Subroutine truncate: not called CC=6 SCAR=37.4
Pod undocumented
47 0 my $out_and_err = shift;
48 0 my %p = @_;
49 0 ▶ my $max_bytes = $p{max_bytes} || 200;
Condition0%0/2
$p{'max_bytes'} || 200
l!l
00
MC/DC0%0/1
$p{'max_bytes'} || 200
$p{'max_bytes'}
Truth table0%0/2
A
A= $p{'max_bytes'}
Aresult
11
00
50 0 ▶ my $max_lines = $p{max_lines} || 10;
Condition0%0/2
$p{'max_lines'} || 10
l!l
00
MC/DC0%0/1
$p{'max_lines'} || 10
$p{'max_lines'}
Truth table0%0/2
A
A= $p{'max_lines'}
Aresult
11
00
51 0 my $is_truncated = 0;
52 0 ▶ if(length($out_and_err)>$max_bytes){
Branch: 1 branch
BranchTrueFalseTotal
if (length $out_and_err > $max_bytes) 0 0 0
53 0 $out_and_err = substr($out_and_err,0,$max_bytes);
54 0 $is_truncated = 1;
55 }
56 0 my @l =split /\n/,$out_and_err,$max_lines+1;
57 0 ▶ if(@l>$max_lines){
Branch: 1 branch
BranchTrueFalseTotal
if (@l > $max_lines) 0 0 0
58 0 $out_and_err = join "\n",@l[0..$max_lines-1];
59 0 $is_truncated = 1;
60 }
61 0 ▶ return $out_and_err. ($is_truncated?"\n(已截断)":"");
Branch: 1 branch
BranchTrueFalseTotal
$is_truncated ? : 0 0 0
62 }
63 0 ▶sub code2state {
Subroutine code2state: not called CC=2 SCAR=17.9
Pod undocumented
64 0 my %c = qw(
65 10 online
66 20 offline
67 30 away
68 40 hidden
69 50 busy
70 60 callme
71 70 silent
72 );
73 0 ▶ return $c{$_[0]} || "online";
Condition0%0/2
$c{$_[0]} || 'online'
l!l
00
MC/DC0%0/1
$c{$_[0]} || 'online'
$c{$_[0]}
Truth table0%0/2
A
A= $c{$_[0]}
Aresult
11
00
74 }
75 0 ▶sub code2client {
Subroutine code2client: not called CC=2 SCAR=17.9
Pod undocumented
76 0 my %c = qw(
77 1 pc
78 21 mobile
79 24 iphone
80 41 web
81 );
82 0 ▶ return $c{$_[0]} || 'unknown';
Condition0%0/2
$c{$_[0]} || 'unknown'
l!l
00
MC/DC0%0/1
$c{$_[0]} || 'unknown'
$c{$_[0]}
Truth table0%0/2
A
A= $c{$_[0]}
Aresult
11
00
83 }
84  
85 1 1;
86  
87 __END__
« Webqq/Client/Method/_get_group_list_info.pm ↑ Summary Webqq/Client/Plugin.pm »