Branch Coverage

blib/lib/MediaWiki/Bot.pm
Criterion Covered Total %
branch 310 598 51.8


line true false branch
38 47 0 if (ref $_[0] eq 'HASH') { }
50 0 0 if @_
63 1 46 if $assert
64 4 43 if $operator
66 0 47 if (not $agent || $operator) { }
3 88 elsif (not $agent and $operator) { }
73 3 0 defined 'MediaWiki::Bot'->VERSION ? :
83 1 46 if $assert
86 0 47 defined $maxlag ? :
94 47 0 if defined $agent
104 0 47 if ($login_data)
106 0 0 if ($success) { }
110 0 0 if $$self{'debug'}
125 47 0 if (ref $_[0] eq 'HASH') { }
138 46 1 unless defined $protocol
139 1 46 unless defined $host
140 46 1 unless defined $path
144 0 47 if ($host =~ m[^(http|https)(://)?] and not $protocol)
152 0 47 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 46 1 $path ? :
167 0 47 if $$self{'debug'} > 1
181 1 0 if (ref $_[0] eq 'HASH') { }
184 0 1 defined $_[0]{'autoconfig'} ? :
200 0 1 if ($basic_auth)
201 0 0 if $$self{'debug'} > 1
210 0 1 if ($$self{'host'} eq 'secure.wikimedia.org')
216 0 1 if ($do_sul)
218 0 0 if $$self{'debug'} > 1 and not $sul_success
222 1 0 if (-r $cookies)
227 0 1 if ($self->_is_loggedin)
228 0 0 if $autoconfig
229 0 0 if $$self{'debug'} > 1
234 0 1 unless ($password)
235 0 0 if $$self{'debug'}
239 0 1 unless my $res = $$self{'api'}->api({'action', 'login', 'lgname', $username, 'lgpassword', $password, 'lgdomain', $lgdomain})
246 1 0 if -w $cookies or -w '.'
248 0 1 unless $$res{'login'}
249 0 1 unless $$res{'login'}{'result'}
251 1 0 if ($$res{'login'}{'result'} eq 'NeedToken')
253 0 1 unless $res = $$self{'api'}->api({'action', 'login', 'lgname', $username, 'lgpassword', $password, 'lgdomain', $lgdomain, 'lgtoken', $token})
262 1 0 if -w $cookies or -w '.'
265 0 1 if ($$res{'login'}{'result'} eq 'Success')
266 0 0 if ($$res{'login'}{'lgusername'} eq $$self{'username'})
267 0 0 if $autoconfig
268 0 0 if $$self{'debug'} > 1
306 0 0 if $debug > 1
316 0 0 $success ? :
0 0 if $debug > 1
317 0 0 if $debug > 1 and not $success
329 0 0 if $debug > 1
356 8 0 if (ref $_[0] eq 'HASH') { }
380 1 7 unless $summary
381 1 7 if ($assert) { }
387 7 1 unless defined $is_minor
388 8 0 unless defined $markasbot
392 0 8 if defined $captcha_id and not defined $captcha_solution or defined $captcha_solution and not defined $captcha_id
397 0 8 unless $edittoken
406 1 7 $section ? :
1 7 $assert ? :
8 0 $is_minor ? :
0 8 $captcha_id ? :
0 8 $captcha_solution ? :
425 1 7 unless $res
427 1 6 if ($$res{'edit'}{'result'} and $$res{'edit'}{'result'} eq 'Failure')
431 1 0 if (exists $$res{'edit'}{'captcha'})
458 0 0 if defined $$opts{'movetalk'}
459 0 0 if defined $$opts{'noredirect'}
460 0 0 if defined $$opts{'movesubpages'}
463 0 0 unless $res
483 0 5 if $rvstartid
484 0 5 if $direction
487 0 5 unless $res
525 8 14 if $revid
526 1 21 if $section
529 0 22 unless $res
532 2 20 if $id == -1
547 0 1 unless $res
549 0 1 if $id == -1
556 1 1 ref $_[0] eq 'ARRAY' ? :
570 0 2 unless $res
574 6 2 if ($$diff{$$page{'title'}}) { }
581 2 4 if (defined $$page{'missing'})
585 4 0 if (defined $$page{'revisions'})
587 0 4 if (not defined $revisions) { }
0 4 elsif (length $revisions < 150 and $revisions =~ /\#REDIRECT\s\[\[([^\[\]]+)\]\]/) { }
604 2 6 if ($$diff{$title} == 1)
606 2 0 if (@pieces > 1)
609 0 2 if $$self{'debug'} > 1
612 0 2 if (defined $v and $v =~ /\#REDIRECT\s\[\[([^\[\]]+)\]\]/)
629 0 0 if $$options{'width'}
630 0 0 if $$options{'height'}
639 0 0 unless $ref
641 0 0 unless defined $$pageref{'imageinfo'}
644 0 0 unless $url =~ m[^https?://]
647 0 0 unless $response->code == 200
675 0 1 if defined $after
690 0 1 unless $res
708 1 2 unless $res
730 1 0 unless $$options{'max'}
733 0 1 unless $res
734 0 1 unless ref $res
759 2 3 if (ref $_[0] eq 'HASH') { }
765 0 2 if (ref $args{'show'} eq 'HASH') { }
783 2 3 if ref $ns eq 'ARRAY'
792 0 5 if defined $user
793 0 5 if defined $show
795 5 0 unless $$options{'max'}
797 0 5 unless my $res = $$self{'api'}->list($hash, $options)
799 2 3 unless ref $res
811 0 2 if ref $ns eq 'ARRAY'
812 2 0 if (defined $filter and $filter =~ /(all|redirects|nonredirects)/)
823 1 1 if defined $ns
824 2 0 if $filter
825 0 2 unless $$options{'max'}
828 0 2 unless $res
829 1 1 unless ref $res
848 0 2 if ref $ns eq 'ARRAY'
849 2 0 if (defined $filter and $filter =~ /(all|redirects|nonredirects)/)
860 2 0 if $filter
861 0 2 if defined $ns
862 0 2 unless $$options{'max'}
865 0 2 unless $res
866 1 1 unless ref $res
883 12 0 if ($category =~ /:/) { }
885 0 12 if ($cat ne 'Category')
888 0 0 if ($cat ne $cat_ns_name)
896 0 12 if $$self{'debug'} > 1
904 0 12 unless defined $$options{'max'}
905 1 11 if $$options{'max'} == 0
908 1 11 unless ref $res
909 0 11 unless $res
922 1 11 unless defined $$options{'max'}
925 3 9 unless $_[0]
935 16 1942 if ($page =~ /^$cat_ns_name:/) { }
936 9 7 if (not exists $data{$page}) { }
965 1 1 if (defined $options and $$options{'max'} == '0')
970 0 2 unless $res
983 0 2 if ref $ns eq 'ARRAY'
992 0 2 if defined $ns
993 0 2 if $prot
994 0 2 unless $$options{'max'}
997 0 2 unless $res
998 1 1 unless ref $res
1013 0 0 if (ref $page eq 'ARRAY') { }
1027 0 0 unless $res
1030 0 0 if exists $$hashref{'purged'}
1043 0 5 unless $res
1056 0 3 unless ($image =~ /^File:|Image:/)
1062 0 0 unless ($image =~ /^\Q$file_ns_name\E:/)
1067 1 2 unless defined $$options{'max'}
1068 0 3 if $$options{'max'} == 0
1070 0 3 if ref $ns eq 'ARRAY'
1078 0 3 if defined $ns
1079 1 2 if (defined $filter and $filter =~ /(all|redirects|nonredirects)/)
1083 0 3 unless $res
1084 1 2 unless ref $res
1095 2 1 defined $limit ? :
1097 1 2 unless ($image =~ /^File:|Image:/)
1100 1 0 unless ($image =~ /^\Q$image_ns_name\E:/)
1107 5 0 $limit ? :
1115 1 2 if $filterlocal
1116 0 3 if $cont
1119 0 3 unless $res
1122 0 3 if $cont and $$self{'debug'} > 1
1126 1 2 unless $cont
1129 1 2 @data > $limit ? :
1156 0 4 unless $res
1159 2 2 if ($number == 1) { }
2 0 elsif ($number == 0) { }
1183 1 6 if (ref $image eq 'ARRAY')
1194 0 7 unless $res
1197 1 6 if ($multi) { }
1210 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') { }
1211 1 2 if ($multi) { }
1219 1 2 if ($multi) { }
1227 0 0 if ($multi) { }
1235 1 2 if ($multi) { }
1260 3 1 unless defined $$options{'max'}
1261 1 3 if exists $$options{'max'} and $$options{'max'} == 0
1264 1 3 unless $res
1265 0 3 unless ref $res
1282 0 2 unless $res
1299 0 0 unless $res
1307 1 1 unless $username =~ /User:/i
1315 0 2 unless $res
1330 0 1 unless $res
1344 0 1 if ($limit > 50)
1356 0 1 if $rvstartid
1357 0 1 if $direction
1360 0 1 unless $res
1383 0 4 unless $res
1386 2 2 if ($number == 1) { }
2 0 elsif ($number == 0) { }
1410 1 1 unless ($text)
1411 0 1 unless $page
1415 1 1 $page ? :
1422 0 2 unless $res
1424 0 2 exists $$res{'expandtemplates'}{'*'} ? :
1441 1 1 if defined $group
1442 2 0 unless exists $$opts{'max'}
1443 0 2 if exists $$opts{'max'} and $$opts{'max'} == 0
1445 0 2 unless $res
1446 0 2 unless ref $res
1456 1 0 unless ($$self{'sitematrix'})
1460 1 0 if (ref $wiki eq 'ARRAY') { }
1481 0 1 unless ($$self{'sitematrix'})
1485 1 0 if (ref $wiki eq 'ARRAY') { }
1506 1 0 if (ref $_[0] eq 'HASH') { }
1522 0 1 if ($title) { }
1 0 elsif ($revid) { }
1531 0 1 unless $res
1546 0 1 if (defined $filter and $filter =~ /(all|redirects|nonredirects)/)
1550 1 0 if (not defined $ns and $prefix =~ /:/)
1551 0 1 if $$self{'debug'} > 1
1556 0 1 if $$self{'debug'} > 1
1565 1 0 if defined $ns
1566 0 1 if $filter
1567 1 0 unless $$options{'max'}
1571 0 1 unless $res
1572 0 1 unless ref $res
1586 0 2 if (ref $ns eq 'ARRAY')
1601 2 0 unless $$options{'max'}
1604 0 2 unless $res
1605 0 2 unless ref $res
1620 1 0 if ($user)
1631 1 0 if $log_type
1632 1 0 if $user
1633 1 0 if $target
1634 1 0 unless $$options{'max'}
1637 0 1 unless $res
1638 0 1 unless ref $res
1658 0 1 unless $res
1659 1 0 unless $$res{'query'}{'globalblocks'}[0]
1671 0 2 unless ($$self{'host'} eq 'meta.wikimedia.org')
1672 0 0 if $$self{'debug'}
1685 0 2 unless $res
1688 1 1 if ($number == 1) { }
1 0 elsif ($number == 0) { }
1705 0 2 unless ($$self{'api'}{'config'}{'api_url'} =~ m[ http\:\/\/meta\.wikimedia\.org\/w\/api\.php | https\:\/\/secure\.wikimedia\.org\/wikipedia\/meta\/w\/api\.php ]x)
1713 0 0 if $$self{'debug'}
1726 0 2 unless $res
1728 1 1 if ($number == 1) { }
1 0 elsif ($number == 0) { }
1743 1 2 if (ref $page eq 'ARRAY')
1754 0 3 unless $res
1762 3 1 if (@$protection == 0)
1768 2 1 if (scalar keys %$out_data == 1) { }
1789 0 0 if (ref $rcid eq 'ARRAY') { }
1804 0 0 if not $res or $$self{'error'}{'details'} and $$self{'error'}{'details'} =~ /^(?:permissiondenied|badtoken)/
1819 0 0 if (ref $user eq 'ARRAY')
1829 0 0 if ($user =~ /:/)
1842 0 0 unless $res
1854 0 0 unless defined $$options{'max'}
1855 0 0 if $$options{'max'} == 0
1864 0 0 unless $res
1865 0 0 unless ref $res
1880 1 2 if (ref $user eq 'ARRAY') { }
1886 0 3 if ref $ns eq 'ARRAY'
1889 3 0 unless defined $$opts{'max'}
1890 0 3 if $$opts{'max'} == 0
1892 1 2 defined $ns ? :
1901 0 3 unless $$res[0]
1902 0 3 unless ref $res
1913 0 0 if (not defined $data and defined $$args{'file'})
1914 0 0 unless open my $in, '<:raw', $$args{'file'}
1916 0 0 unless (defined $data)
1921 0 0 unless (defined $$args{'file'} or defined $$args{'title'})
1943 0 0 unless (defined $url)
1978 0 1 unless $res
1981 0 1 unless $$res_user{'name'} eq $user
2006 0 9 unless my $res = $$self{'api'}->api({'action', 'query', 'meta', 'siteinfo|tokens', 'titles', $page, 'prop', 'revisions', 'rvprop', 'timestamp', 'type', $type})
2029 0 4 if $$self{'debug'}
2033 1 3 defined $error && ref $error eq 'HASH' && exists $$error{'code'} && exists $$error{'details'} ? :
2046 0 1 if $$self{'debug'} > 1
2053 0 1 unless my $res = $$self{'api'}->api({'action', 'query', 'meta', 'userinfo'})
2071 0 0 unless $res
2072 0 0 unless $$res{'query'}
2073 0 0 unless $$res{'query'}{'userinfo'}
2074 0 0 unless $$res{'query'}{'userinfo'}{'name'}
2080 0 0 if $is ne $ought
2082 0 0 unless $$res{'query'}{'userinfo'}{'rights'}
2086 0 0 if ($right eq 'bot')
2092 0 0 unless $$res{'query'}{'userinfo'}{'groups'}
2095 0 0 if ($group eq 'sysop')
2100 0 0 unless ($has_bot and not $is_sysop)
2101 0 0 if $$self{'debug'} > 1
2103 0 0 unless $$self{'assert'}
2112 0 1 unless $res
2119 299 295 if (ref $hashref ne 'HASH')
2120 1 298 if ($hashref eq 'specials')
2123 36 51 if exists $$special{'private'} or exists $$special{'fishbowl'}
2153 1 0 if ($response->is_success)
2179 11 4 if exists $$self{'ns_data'}
2193 1 2 if exists $$self{'ns_alias_data'}