Weixin/Model/Remote/_webwxgetcontact.pm

filter: Statementstmt 15.9% 7 / 44 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 66.6% 2 / 3 Podpod n/a totaltotal 11.3% 9 / 79 CC 18 SCAR 57.3
CC
18
Cov
10%
_webwxgetcontact
342.0
BEGIN
1.0
BEGIN
1.0
CRAP 307.9
« Weixin/Plugin/FmPush.pm ↑ Summary Weixin/Model/Remote/_webwxinit.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use Mojo::Weixin::Const qw(%KEY_MAP_USER %KEY_MAP_GROUP %KEY_MAP_GROUP_MEMBER %KEY_MAP_FRIEND);
Subroutine BEGIN: called CC=1 SCAR=0.0
3 0 ▶sub Mojo::Weixin::_webwxgetcontact {
Subroutine _webwxgetcontact: not called CC=18 SCAR=58.3
4 0 my $self = shift;
5 0 my $api = "https://".$self->domain . "/cgi-bin/mmwebwx-bin/webwxgetcontact";
6 0 my $flag = 0;
7 0 my $seq = 0;
8 0 my @friends;
9 my @groups;
10 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$flag and do { do { my(@query_string) = ("r", $self->now, "seq", $seq, "skey", $self->skey); push @query_string, ("pass_ticket", $self->url_escape($self->pass_ticket)) if $self->pass_ticket; my $json = $self->http_get($self->gen_url($api, @query_string), {"Referer", 'https://' . $self->domain . '/', "json", 1}); return unless defined $json; return if $json->{"BaseResponse"}{"Ret"} != 0; return if $json->{"MemberCount"} == 0; if ($self->is_update_all_friend and defined $json->{"Seq"} and $json->{"Seq"} != 0) { $flag = 1; $seq = $json->{"Seq"}; } else { $flag = 0; } ; foreach my $e (@{$$json{"MemberList"};}) { if ($self->is_group_id($e->{"UserName"})) { my $group = {}; foreach $_ (keys %Mojo::Weixin::Model::KEY_MAP_GROUP) { $group->{$_} = $$e{$Mojo::Weixin::Model::KEY_MAP_GROUP{$_}} // ""; } ; foreach my $m (@{$$e{"MemberList"};}) { my $member = {}; foreach $_ (keys %Mojo::Weixin::Model::KEY_MAP_GROUP_MEMBER) { $member->{$_} = $$m{$Mojo::Weixin::Model::KEY_MAP_GROUP_MEMBER{$_}} // ""; } ; $member->{"sex"} = $self->code2sex($member->{"sex"}); push @{$$group{"member"};}, $member; } ; push @groups, $group; } else { my $friend = {}; foreach $_ (keys %Mojo::Weixin::Model::KEY_MAP_FRIEND) { $friend->{$_} = $$e{$Mojo::Weixin::Model::KEY_MAP_FRIEND{$_}} // ""; } ; $friend->{"sex"} = $self->code2sex($friend->{"sex"}); push @friends, $friend; } ; } } } 0 0 0
11 0 my @query_string = (
12 r => $self->now(),
13 seq => $seq,
14 skey => $self->skey,
15 );
16 0 ▶ push @query_string,(pass_ticket=>$self->url_escape($self->pass_ticket)) if $self->pass_ticket;
Branch: 1 branch
BranchTrueFalseTotal
if $self->pass_ticket 0 0 0
17  
18 0 my $json = $self->http_get($self->gen_url($api,@query_string),{Referer=>'https://'.$self->domain . '/',json=>1});
19 #return [\@friends,\@groups] if not defined $json;
20 0 ▶ return if not defined $json;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $json 0 0 0
21 0 ▶ return if $json->{BaseResponse}{Ret}!=0;
Branch: 1 branch
BranchTrueFalseTotal
if $json->{"BaseResponse"}{"Ret"} != 0 0 0 0
22 0 ▶ return if $json->{MemberCount} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $json->{"MemberCount"} == 0 0 0 0
23 0 ▶ if ($self->is_update_all_friend and defined $json->{Seq} and $json->{Seq} != 0){#获取的不全,需要继续获取其余部分
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_update_all_friend and defined $json->{'Seq'} and $json->{'Seq'} != 0) { } 0 0 0
Condition0%0/6
$self->is_update_all_friend and defined $json->{"Seq"} and $json->{"Seq"} != 0
!ll&&!rl&&r
000
$self->is_update_all_friend and defined $json->{"Seq"}
!ll&&!rl&&r
000
MC/DC0%0/3
$self->is_update_all_friend and defined $json->{"Seq"} and $json->{"Seq"} != 0
$self->is_update_all_friend defined $json->{"Seq"} $json->{"Seq"} != 0
Truth table0%0/4
A and B and C
A= $self->is_update_all_friendB= defined $json->{"Seq"}C= $json->{"Seq"} != 0
ABCresult
0XX0
10X0
1100
1111
24 0 $flag = 1 ;
25 0 $seq = $json->{Seq};
26 }
27 else{
28 0 $flag = 0;
29 }
30 0 for my $e ( @{ $json->{MemberList} } ){
31 0 ▶ if($self->is_group_id($e->{UserName})){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_group_id($e->{'UserName'})) { } 0 0 0
32 0 my $group = {};
33 0 for(keys %KEY_MAP_GROUP){
34 0 ▶ $group->{$_} = $e->{$KEY_MAP_GROUP{$_}} // "";
Condition0%0/2
$$e{$Mojo::Weixin::Model::KEY_MAP_GROUP{$_}} // ""
l!l
00
MC/DC0%0/1
$$e{$Mojo::Weixin::Model::KEY_MAP_GROUP{$_}} // ""
$$e{$Mojo::Weixin::Model::KEY_MAP_GROUP{$_}}
Truth table0%0/2
A
A= $$e{$Mojo::Weixin::Model::KEY_MAP_GROUP{$_}}
Aresult
11
00
35 }
36 0 for my $m (@{$e->{MemberList}}){
37 0 my $member = {};
38 0 for(keys %KEY_MAP_GROUP_MEMBER){
39 0 ▶ $member->{$_} = $m->{$KEY_MAP_GROUP_MEMBER{$_}} // "";
Condition0%0/2
$$m{$Mojo::Weixin::Model::KEY_MAP_GROUP_MEMBER{$_}} // ""
l!l
00
MC/DC0%0/1
$$m{$Mojo::Weixin::Model::KEY_MAP_GROUP_MEMBER{$_}} // ""
$$m{$Mojo::Weixin::Model::KEY_MAP_GROUP_MEMBER{$_}}
Truth table0%0/2
A
A= $$m{$Mojo::Weixin::Model::KEY_MAP_GROUP_MEMBER{$_}}
Aresult
11
00
40 }
41 0 $member->{sex} = $self->code2sex($member->{sex});
42 0 push @{$group->{member}},$member;
43 }
44 0 push @groups,$group;
45 }
46 else{
47 0 my $friend = {};
48 0 for(keys %KEY_MAP_FRIEND){
49 0 ▶ $friend->{$_} = $e->{$KEY_MAP_FRIEND{$_}} // "" ;
Condition0%0/2
$$e{$Mojo::Weixin::Model::KEY_MAP_FRIEND{$_}} // ""
l!l
00
MC/DC0%0/1
$$e{$Mojo::Weixin::Model::KEY_MAP_FRIEND{$_}} // ""
$$e{$Mojo::Weixin::Model::KEY_MAP_FRIEND{$_}}
Truth table0%0/2
A
A= $$e{$Mojo::Weixin::Model::KEY_MAP_FRIEND{$_}}
Aresult
11
00
50 }
51 0 $friend->{sex} = $self->code2sex($friend->{sex});
52 0 push @friends,$friend;
53 }
54 }
55 } while $flag;
56 0 return [\@friends,\@groups];
57 }
58
59 1 1;
« Weixin/Plugin/FmPush.pm ↑ Summary Weixin/Model/Remote/_webwxinit.pm »