Branch Coverage

blib/lib/MediaWiki/Bot.pm
Criterion Covered Total %
branch 294 602 48.8


line true false branch
38 43 0 if (ref $_[0] eq 'HASH') { }
50 0 0 if @_
63 1 42 if $assert
64 4 39 if $operator
66 0 43 if (not $agent || $operator) { }
3 80 elsif (not $agent and $operator) { }
73 3 0 defined 'MediaWiki::Bot'->VERSION ? :
83 1 42 if $assert
86 0 43 defined $maxlag ? :
94 43 0 if defined $agent
104 0 43 if ($login_data)
106 0 0 if ($success) { }
110 0 0 if $self->{'debug'}
125 43 0 if (ref $_[0] eq 'HASH') { }
138 43 0 unless defined $protocol
139 1 42 unless defined $host
140 42 1 unless defined $path
144 0 43 if ($host =~ m[^(http|https)(://)?] and not $protocol)
152 0 43 if (defined $self->{'host'} and $self->{'host'} ne $host or defined $self->{'path'} and $self->{'path'} ne $path or defined $self->{'protocol'} and $self->{'protocol'} ne $protocol)
156 0 0 if $self->{'ns_data'}
157 0 0 if $self->{'ns_alias_data'}
164 42 1 $path ? :
167 0 43 if $self->{'debug'} > 1
181 1 0 if (ref $_[0] eq 'HASH') { }
184 0 1 defined $_[0]{'autoconfig'} ? :
205 0 1 unless $self->{'protocol'} eq 'https'
208 0 1 if ($basic_auth)
209 0 0 if $self->{'debug'} > 1
218 0 1 if ($self->{'host'} eq 'secure.wikimedia.org')
224 0 1 if ($do_sul)
226 0 0 if $self->{'debug'} > 1 and not $sul_success
230 0 1 if (-r $cookies)
235 0 0 if ($self->_is_loggedin)
236 0 0 if $autoconfig
237 0 0 if $self->{'debug'} > 1
242 0 1 unless ($password)
243 0 0 if $self->{'debug'}
251 0 2 unless $res = $self->{'api'}->api({'action', 'query', 'meta', 'tokens', 'type', 'login'})
261 0 2 unless $res = $self->{'api'}->api({'action', 'login', 'lgname', $self->{'login_username'}, 'lgpassword', $password, 'lgdomain', $lgdomain, 'lgtoken', $token})
266 0 2 if $res->{'login'}{'result'} eq 'Success'
270 1 0 if -w $cookies or -w '.'
272 0 1 if ($res->{'login'}{'result'} eq 'Success')
273 0 0 if ($res->{'login'}{'lgusername'} eq $self->{'username'})
274 0 0 if $autoconfig
275 0 0 if $self->{'debug'} > 1
311 0 0 if $debug > 1
321 0 0 $success ? :
0 0 if $debug > 1
323 0 0 if $debug > 1 and not $success
334 0 0 if $debug > 1
361 1 0 if (ref $_[0] eq 'HASH') { }
385 1 0 unless $summary
386 1 0 if ($assert) { }
392 1 0 unless defined $is_minor
393 1 0 unless defined $markasbot
397 0 1 if defined $captcha_id and not defined $captcha_solution or defined $captcha_solution and not defined $captcha_id
402 0 1 unless $edittoken
411 0 1 $section ? :
1 0 $assert ? :
1 0 $is_minor ? :
0 1 $captcha_id ? :
0 1 $captcha_solution ? :
430 1 0 unless $res
432 0 0 if ($res->{'edit'}{'result'} and $res->{'edit'}{'result'} eq 'Failure')
436 0 0 if (exists $res->{'edit'}{'captcha'})
463 0 0 if defined $opts->{'movetalk'}
464 0 0 if defined $opts->{'noredirect'}
465 0 0 if defined $opts->{'movesubpages'}
468 0 0 unless $res
488 0 2 if $rvstartid
489 0 2 if $direction
492 0 2 unless $res
530 0 10 if $revid
531 1 9 if $section
534 0 10 unless $res
537 2 8 if $id == -1
552 0 1 unless $res
554 0 1 if $id == -1
561 1 1 ref $_[0] eq 'ARRAY' ? :
575 0 2 unless $res
579 6 2 if ($$diff{$page->{'title'}}) { }
586 2 4 if (defined $page->{'missing'})
590 4 0 if (defined $page->{'revisions'})
592 0 4 if (not defined $revisions) { }
0 4 elsif (length $revisions < 150 and $revisions =~ /\#REDIRECT\s\[\[([^\[\]]+)\]\]/) { }
609 2 6 if ($diff->{$title} == 1)
611 2 0 if (@pieces > 1)
614 0 2 if $self->{'debug'} > 1
617 0 2 if (defined $v and $v =~ /\#REDIRECT\s\[\[([^\[\]]+)\]\]/)
634 0 0 if $options->{'width'}
635 0 0 if $options->{'height'}
644 0 0 unless $ref
646 0 0 unless defined $pageref->{'imageinfo'}
649 0 0 unless $url =~ m[^https?://]
652 0 0 unless $response->code == 200
680 0 0 if defined $after
695 0 0 unless $res
713 1 2 unless $res
735 1 0 unless $options->{'max'}
738 0 1 unless $res
739 0 1 unless ref $res
764 2 3 if (ref $_[0] eq 'HASH') { }
770 0 2 if (ref $args{'show'} eq 'HASH') { }
788 2 3 if ref $ns eq 'ARRAY'
797 0 5 if defined $user
798 0 5 if defined $show
800 5 0 unless $options->{'max'}
802 0 5 unless my $res = $self->{'api'}->list($hash, $options)
804 2 3 unless ref $res
816 0 2 if ref $ns eq 'ARRAY'
817 2 0 if (defined $filter and $filter =~ /(all|redirects|nonredirects)/)
828 1 1 if defined $ns
829 2 0 if $filter
830 0 2 unless $options->{'max'}
833 0 2 unless $res
834 1 1 unless ref $res
853 0 2 if ref $ns eq 'ARRAY'
854 2 0 if (defined $filter and $filter =~ /(all|redirects|nonredirects)/)
865 2 0 if $filter
866 0 2 if defined $ns
867 0 2 unless $options->{'max'}
870 0 2 unless $res
871 1 1 unless ref $res
888 14 0 if ($category =~ /:/) { }
890 0 14 if ($cat ne 'Category')
893 0 0 if ($cat ne $cat_ns_name)
901 0 14 if $self->{'debug'} > 1
909 0 14 unless defined $options->{'max'}
910 1 13 if $options->{'max'} == 0
913 1 13 unless ref $res
914 0 13 unless $res
927 1 13 unless defined $options->{'max'}
930 3 11 unless $_[0]
940 18 2114 if ($page =~ /^$cat_ns_name:/) { }
941 11 7 if (not exists $data{$page}) { }
970 1 1 if (defined $options and $options->{'max'} == '0')
975 0 2 unless $res
988 0 2 if ref $ns eq 'ARRAY'
997 0 2 if defined $ns
998 0 2 if $prot
999 0 2 unless $options->{'max'}
1002 0 2 unless $res
1003 1 1 unless ref $res
1018 0 0 if (ref $page eq 'ARRAY') { }
1032 0 0 unless $res
1035 0 0 if exists $hashref->{'purged'}
1048 0 5 unless $res
1061 0 3 unless ($image =~ /^File:|Image:/)
1067 0 0 unless ($image =~ /^\Q$file_ns_name\E:/)
1072 1 2 unless defined $options->{'max'}
1073 0 3 if $options->{'max'} == 0
1075 0 3 if ref $ns eq 'ARRAY'
1083 0 3 if defined $ns
1084 1 2 if (defined $filter and $filter =~ /(all|redirects|nonredirects)/)
1088 0 3 unless $res
1089 1 2 unless ref $res
1100 2 1 defined $limit ? :
1102 1 2 unless ($image =~ /^File:|Image:/)
1105 1 0 unless ($image =~ /^\Q$image_ns_name\E:/)
1112 3 0 $limit ? :
1120 1 2 if $filterlocal
1121 0 3 if $cont
1124 0 3 unless $res
1127 0 3 if $cont and $self->{'debug'} > 1
1131 3 0 unless $cont
1134 1 2 @data > $limit ? :
1161 0 4 unless $res
1164 2 2 if ($number == 1) { }
2 0 elsif ($number == 0) { }
1188 1 6 if (ref $image eq 'ARRAY')
1199 0 7 unless $res
1202 1 6 if ($multi) { }
1215 3 6 if ($res->{'query'}{'pages'}{$id}{'imagerepository'} eq 'shared') { }
3 3 elsif (exists $res->{'query'}{'pages'}{$id}{'missing'}) { }
0 3 elsif ($res->{'query'}{'pages'}{$id}{'imagerepository'} eq '') { }
3 0 elsif ($res->{'query'}{'pages'}{$id}{'imagerepository'} eq 'local') { }
1216 1 2 if ($multi) { }
1224 1 2 if ($multi) { }
1232 0 0 if ($multi) { }
1240 1 2 if ($multi) { }
1265 3 1 unless defined $options->{'max'}
1266 1 3 if exists $options->{'max'} and $options->{'max'} == 0
1269 1 3 unless $res
1270 0 3 unless ref $res
1287 0 2 unless $res
1304 0 0 unless $res
1312 1 1 unless $username =~ /User:/i
1320 0 2 unless $res
1335 0 1 unless $res
1349 0 1 if ($limit > 50)
1361 0 1 if $rvstartid
1362 0 1 if $direction
1365 0 1 unless $res
1388 0 4 unless $res
1391 2 2 if ($number == 1) { }
2 0 elsif ($number == 0) { }
1415 1 1 unless ($text)
1416 0 1 unless $page
1420 1 1 $page ? :
1427 0 2 unless $res
1431 0 2 exists $res->{'expandtemplates'}{'*'} ? :
1446 1 1 if defined $group
1447 2 0 unless exists $opts->{'max'}
1448 0 2 if exists $opts->{'max'} and $opts->{'max'} == 0
1450 0 2 unless $res
1451 0 2 unless ref $res
1461 1 0 unless ($self->{'sitematrix'})
1465 1 0 if (ref $wiki eq 'ARRAY') { }
1470 3 3 if defined $domain
1478 0 0 if defined $domain
1488 0 1 unless ($self->{'sitematrix'})
1492 1 0 if (ref $wiki eq 'ARRAY') { }
1495 6 0 unless $w =~ m[^https\:/]
1502 0 0 unless $wiki =~ m[^https\:/]
1515 1 0 if (ref $_[0] eq 'HASH') { }
1531 0 1 if ($title) { }
1 0 elsif ($revid) { }
1540 0 1 unless $res
1555 0 1 if (defined $filter and $filter =~ /(all|redirects|nonredirects)/)
1559 1 0 if (not defined $ns and $prefix =~ /:/)
1560 0 1 if $self->{'debug'} > 1
1565 0 1 if $self->{'debug'} > 1
1574 1 0 if defined $ns
1575 0 1 if $filter
1576 1 0 unless $options->{'max'}
1580 0 1 unless $res
1581 0 1 unless ref $res
1595 0 2 if (ref $ns eq 'ARRAY')
1610 2 0 unless $options->{'max'}
1613 0 2 unless $res
1614 0 2 unless ref $res
1629 1 0 if ($user)
1640 1 0 if $log_type
1641 1 0 if $user
1642 1 0 if $target
1643 1 0 unless $options->{'max'}
1646 0 1 unless $res
1647 0 1 unless ref $res
1667 0 1 unless $res
1668 1 0 unless $res->{'query'}{'globalblocks'}[0]
1680 0 2 unless ($self->{'host'} eq 'meta.wikimedia.org')
1681 0 0 if $self->{'debug'}
1694 0 2 unless $res
1697 1 1 if ($number == 1) { }
1 0 elsif ($number == 0) { }
1714 2 0 unless ($self->{'api'}{'config'}{'api_url'} =~ m[ http\:\/\/meta\.wikimedia\.org\/w\/api\.php | https\:\/\/secure\.wikimedia\.org\/wikipedia\/meta\/w\/api\.php ]x)
1722 0 2 if $self->{'debug'}
1735 0 2 unless $res
1737 1 1 if ($number == 1) { }
1 0 elsif ($number == 0) { }
1752 1 2 if (ref $page eq 'ARRAY')
1763 0 3 unless $res
1771 3 1 if (@$protection == 0)
1777 2 1 if (scalar keys %$out_data == 1) { }
1798 0 0 if (ref $rcid eq 'ARRAY') { }
1815 0 0 if not $res or $self->{'error'}{'details'} and $self->{'error'}{'details'} =~ /^(?:permissiondenied|badtoken)/
1828 0 0 if (ref $user eq 'ARRAY')
1838 0 0 if ($user =~ /:/)
1851 0 0 unless $res
1863 0 0 unless defined $options->{'max'}
1864 0 0 if $options->{'max'} == 0
1873 0 0 unless $res
1874 0 0 unless ref $res
1889 1 2 if (ref $user eq 'ARRAY') { }
1895 0 3 if ref $ns eq 'ARRAY'
1898 3 0 unless defined $opts->{'max'}
1899 0 3 if $opts->{'max'} == 0
1901 1 2 defined $ns ? :
1910 0 3 unless $res->[0]
1911 0 3 unless ref $res
1922 0 0 if (not defined $data and defined $args->{'file'})
1923 0 0 unless open my $in, '<:raw', $args->{'file'}
1925 0 0 unless (defined $data)
1930 0 0 unless (defined $args->{'file'} or defined $args->{'title'})
1952 0 0 unless (defined $url)
1987 0 1 unless $res
1990 0 1 unless $res_user->{'name'} eq $user
2016 0 1 unless my $res = $self->{'api'}->api({'action', 'query', 'meta', 'siteinfo|tokens', 'titles', $page, 'prop', 'revisions', 'rvprop', 'timestamp', 'type', $type})
2041 0 3 if $self->{'debug'}
2045 0 3 defined $error && ref $error eq 'HASH' && exists $error->{'code'} && exists $error->{'details'} ? :
2055 0 0 if $self->{'debug'} > 1
2063 0 0 unless my $res = $self->{'api'}->api({'action', 'query', 'meta', 'userinfo'})
2080 0 0 unless $res
2081 0 0 unless $res->{'query'}
2082 0 0 unless $res->{'query'}{'userinfo'}
2083 0 0 unless $res->{'query'}{'userinfo'}{'name'}
2089 0 0 if $is ne $ought
2091 0 0 unless $res->{'query'}{'userinfo'}{'rights'}
2095 0 0 if ($right eq 'bot')
2101 0 0 unless $res->{'query'}{'userinfo'}{'groups'}
2104 0 0 if ($group eq 'sysop')
2109 0 0 unless ($has_bot and not $is_sysop)
2110 0 0 if $self->{'debug'} > 1
2112 0 0 unless $self->{'assert'}
2121 0 1 unless $res
2128 297 293 if (ref $hashref ne 'HASH')
2129 1 296 if ($hashref eq 'specials')
2133 36 55 if exists $special->{'private'} or exists $special->{'fishbowl'}
2162 1 0 if ($response->is_success)
2188 13 4 if exists $self->{'ns_data'}
2202 1 2 if exists $self->{'ns_alias_data'}