Branch Coverage

blib/lib/MediaWiki/Bot.pm
Criterion Covered Total %
branch 306 604 50.6


line true false branch
33 46 1 if (ref $_[0] eq 'HASH') { }
45 0 1 if @_
58 1 46 if $assert
59 2 45 if $operator
62 3 44 unless ($agent)
63 3 0 defined 'MediaWiki::Bot'->VERSION ? :
66 1 2 if $operator
71 1 46 if $assert
74 0 47 defined $maxlag ? :
82 47 0 if defined $agent
92 0 47 if ($login_data)
94 0 0 if ($success) { }
98 0 0 if $$self{'debug'}
113 47 0 if (ref $_[0] eq 'HASH') { }
126 46 1 unless defined $protocol
127 1 46 unless defined $host
128 46 1 unless defined $path
132 0 47 if ($host =~ m[^(http|https)(://)?] and not $protocol)
140 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)
144 0 0 if $$self{'ns_data'}
145 0 0 if $$self{'ns_alias_data'}
152 46 1 $path ? :
155 0 47 if $$self{'debug'} > 1
169 1 0 if (ref $_[0] eq 'HASH') { }
172 0 1 defined $_[0]{'autoconfig'} ? :
188 0 1 if ($basic_auth)
189 0 0 if $$self{'debug'} > 1
198 0 1 if ($$self{'host'} eq 'secure.wikimedia.org')
204 0 1 if ($do_sul)
206 0 0 if $$self{'debug'} > 1 and not $sul_success
210 1 0 if (-r $cookies)
215 0 1 if ($self->_is_loggedin)
216 0 0 if $autoconfig
217 0 0 if $$self{'debug'} > 1
222 0 1 unless ($password)
223 0 0 if $$self{'debug'}
227 0 1 unless my $res = $$self{'api'}->api({'action', 'login', 'lgname', $username, 'lgpassword', $password, 'lgdomain', $lgdomain})
234 1 0 if -w $cookies or -w '.'
236 0 1 unless $$res{'login'}
237 0 1 unless $$res{'login'}{'result'}
239 1 0 if ($$res{'login'}{'result'} eq 'NeedToken')
241 0 1 unless $res = $$self{'api'}->api({'action', 'login', 'lgname', $username, 'lgpassword', $password, 'lgdomain', $lgdomain, 'lgtoken', $token})
250 1 0 if -w $cookies or -w '.'
253 0 1 if ($$res{'login'}{'result'} eq 'Success')
254 0 0 if ($$res{'login'}{'lgusername'} eq $$self{'username'})
255 0 0 if $autoconfig
256 0 0 if $$self{'debug'} > 1
294 0 0 if $debug > 1
304 0 0 $success ? :
0 0 if $debug > 1
305 0 0 if $debug > 1 and not $success
317 0 0 if $debug > 1
345 8 0 if (ref $_[0] eq 'HASH') { }
367 1 7 unless $summary
368 1 7 if ($assert) { }
374 7 1 unless defined $is_minor
375 8 0 unless defined $markasbot
378 0 8 unless $edittoken
387 1 7 $section ? :
1 7 $assert ? :
8 0 $is_minor ? :
403 1 7 unless $res
404 0 7 if ($$res{'edit'}{'result'} and $$res{'edit'}{'result'} eq 'Failure')
405 0 0 if ($$self{'operator'})
407 0 0 if (defined $optalk)
408 0 0 if $$self{'debug'}
409 0 0 if ($$self{'username'}) { }
419 0 0 if $$self{'debug'}
431 0 0 if $$self{'debug'}
454 0 0 if defined $$opts{'movetalk'}
455 0 0 if defined $$opts{'noredirect'}
458 0 0 unless $res
478 0 5 if $rvstartid
479 0 5 if $direction
482 0 5 unless $res
520 9 14 if $revid
521 1 22 if $section
524 0 23 unless $res
526 2 21 if ($id == -1) { }
546 0 1 unless $res
548 0 1 if ($id == -1) { }
559 1 1 ref $_[0] eq 'ARRAY' ? :
573 0 2 unless $res
577 6 2 if ($$diff{$$page{'title'}}) { }
584 2 4 if (defined $$page{'missing'})
588 4 0 if (defined $$page{'revisions'})
590 0 4 if (not defined $revisions) { }
0 4 elsif (length $revisions < 150 and $revisions =~ /\#REDIRECT\s\[\[([^\[\]]+)\]\]/) { }
607 2 6 if ($$diff{$title} == 1)
609 2 0 if (@pieces > 1)
612 0 2 if $$self{'debug'} > 1
615 0 2 if (defined $v and $v =~ /\#REDIRECT\s\[\[([^\[\]]+)\]\]/)
632 0 0 if $$options{'width'}
633 0 0 if $$options{'height'}
642 0 0 unless $ref
644 0 0 unless defined $$pageref{'imageinfo'}
647 0 0 unless $url =~ m[^https?://]
650 0 0 unless $response->code == 200
678 0 1 if defined $after
693 0 1 unless $res
711 1 2 unless $res
733 1 0 unless $$options{'max'}
736 0 1 unless $res
737 0 1 unless ref $res
761 2 3 if (ref $_[0] eq 'HASH') { }
767 0 2 if (ref $args{'show'} eq 'HASH') { }
785 2 3 if ref $ns eq 'ARRAY'
794 0 5 if defined $user
795 0 5 if defined $show
797 5 0 unless $$options{'max'}
799 0 5 unless my $res = $$self{'api'}->list($hash, $options)
801 2 3 unless ref $res
813 0 2 if ref $ns eq 'ARRAY'
814 2 0 if (defined $filter and $filter =~ /(all|redirects|nonredirects)/)
825 1 1 if defined $ns
826 2 0 if $filter
827 0 2 unless $$options{'max'}
830 0 2 unless $res
831 1 1 unless ref $res
850 0 2 if ref $ns eq 'ARRAY'
851 2 0 if (defined $filter and $filter =~ /(all|redirects|nonredirects)/)
862 2 0 if $filter
863 0 2 if defined $ns
864 0 2 unless $$options{'max'}
867 0 2 unless $res
868 1 1 unless ref $res
885 12 0 if ($category =~ /:/) { }
887 0 12 if ($cat ne 'Category')
890 0 0 if ($cat ne $cat_ns_name)
898 0 12 if $$self{'debug'} > 1
906 0 12 unless defined $$options{'max'}
907 1 11 if $$options{'max'} == 0
910 1 11 unless ref $res
911 0 11 unless $res
928 1 11 unless defined $$options{'max'}
931 3 9 unless $_[0]
941 16 1939 if ($page =~ /^$cat_ns_name:/) { }
942 9 7 if (not exists $data{$page}) { }
971 1 1 if (defined $options and $$options{'max'} == '0')
976 0 2 unless $res
994 0 2 if ref $ns eq 'ARRAY'
1003 0 2 if defined $ns
1004 0 2 if $prot
1005 0 2 unless $$options{'max'}
1008 0 2 unless $res
1009 1 1 unless ref $res
1025 0 0 if (ref $page eq 'ARRAY') { }
1039 0 0 unless $res
1042 0 0 if exists $$hashref{'purged'}
1055 0 5 unless $res
1071 0 3 unless ($image =~ /^File:|Image:/)
1077 0 0 unless ($image =~ /^\Q$image_ns_name\E:/)
1082 1 2 unless defined $$options{'max'}
1083 0 3 if $$options{'max'} == 0
1085 0 3 if ref $ns eq 'ARRAY'
1093 0 3 if defined $ns
1094 1 2 if (defined $filter and $filter =~ /(all|redirects|nonredirects)/)
1098 0 3 unless $res
1099 1 2 unless ref $res
1115 2 1 defined $limit ? :
1117 1 2 unless ($image =~ /^File:|Image:/)
1120 1 0 unless ($image =~ /^\Q$image_ns_name\E:/)
1127 5 0 $limit ? :
1135 1 2 if $filterlocal
1136 0 3 if $cont
1139 0 3 unless $res
1142 0 3 if $cont and $$self{'debug'} > 1
1146 1 2 unless $cont
1149 1 2 @data > $limit ? :
1176 0 4 unless $res
1179 2 2 if ($number == 1) { }
2 0 elsif ($number == 0) { }
1203 1 3 if (ref $image eq 'ARRAY')
1214 0 4 unless $res
1217 1 3 if ($multi) { }
1230 2 4 if ($$res{'query'}{'pages'}{$id}{'imagerepository'} eq 'shared') { }
2 2 elsif (exists $$res{'query'}{'pages'}{$id}{'missing'}) { }
0 2 elsif ($$res{'query'}{'pages'}{$id}{'imagerepository'} eq '') { }
2 0 elsif ($$res{'query'}{'pages'}{$id}{'imagerepository'} eq 'local') { }
1231 1 1 if ($multi) { }
1239 1 1 if ($multi) { }
1247 0 0 if ($multi) { }
1255 1 1 if ($multi) { }
1280 3 1 unless defined $$options{'max'}
1281 1 3 if exists $$options{'max'} and $$options{'max'} == 0
1284 1 3 unless $res
1285 0 3 unless ref $res
1302 0 2 unless $res
1319 0 0 unless $res
1327 1 1 unless $username =~ /User:/i
1335 0 2 unless $res
1350 0 1 unless $res
1366 0 1 if ($limit > 50)
1378 0 1 if $rvstartid
1379 0 1 if $direction
1382 0 1 unless $res
1410 0 4 unless $res
1413 2 2 if ($number == 1) { }
2 0 elsif ($number == 0) { }
1437 1 1 unless ($text)
1438 0 1 unless $page
1442 1 1 $page ? :
1448 0 2 unless $res
1465 1 1 if defined $group
1466 2 0 unless exists $$opts{'max'}
1467 0 2 if exists $$opts{'max'} and $$opts{'max'} == 0
1469 0 2 unless $res
1470 0 2 unless ref $res
1484 1 0 unless ($$self{'sitematrix'})
1488 1 0 if (ref $wiki eq 'ARRAY') { }
1509 0 1 unless ($$self{'sitematrix'})
1513 1 0 if (ref $wiki eq 'ARRAY') { }
1534 1 0 if (ref $_[0] eq 'HASH') { }
1550 0 1 if ($title) { }
1 0 elsif ($revid) { }
1559 0 1 unless $res
1574 0 1 if (defined $filter and $filter =~ /(all|redirects|nonredirects)/)
1578 1 0 if (not defined $ns and $prefix =~ /:/)
1579 0 1 if $$self{'debug'} > 1
1584 0 1 if $$self{'debug'} > 1
1593 1 0 if defined $ns
1594 0 1 if $filter
1595 1 0 unless $$options{'max'}
1599 0 1 unless $res
1600 0 1 unless ref $res
1618 0 2 if (ref $ns eq 'ARRAY')
1633 2 0 unless $$options{'max'}
1636 0 2 unless $res
1637 0 2 unless ref $res
1657 1 0 if ($user)
1668 1 0 if $log_type
1669 1 0 if $user
1670 1 0 if $target
1671 1 0 unless $$options{'max'}
1674 0 1 unless $res
1675 0 1 unless ref $res
1695 0 1 unless $res
1696 1 0 unless $$res{'query'}{'globalblocks'}[0]
1708 0 2 unless ($$self{'host'} eq 'meta.wikimedia.org')
1709 0 0 if $$self{'debug'}
1722 0 2 unless $res
1725 1 1 if ($number == 1) { }
1 0 elsif ($number == 0) { }
1743 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)
1751 0 0 if $$self{'debug'}
1764 0 2 unless $res
1766 1 1 if ($number == 1) { }
1 0 elsif ($number == 0) { }
1781 1 2 if (ref $page eq 'ARRAY')
1792 0 3 unless $res
1800 3 1 if (@$protection == 0)
1806 2 1 if (scalar keys %$out_data == 1) { }
1827 0 0 if (ref $rcid eq 'ARRAY') { }
1842 0 0 unless $token_res
1843 0 0 if (exists $$token_res{'warnings'} and $$token_res{'warnings'}{'recentchanges'}{'*'} eq q[Action 'patrol' is not allowed for the current user])
1861 0 0 if not $res or $$self{'error'}{'details'} and $$self{'error'}{'details'} =~ /^(?:permissiondenied|badtoken)/
1876 0 0 if (ref $user eq 'ARRAY')
1886 0 0 if ($user =~ /:/)
1899 0 0 unless $res
1911 0 0 unless defined $$options{'max'}
1912 0 0 if $$options{'max'} == 0
1921 0 0 unless $res
1922 0 0 unless ref $res
1926 0 0 if exists $$page{'top'}
1939 1 2 if (ref $user eq 'ARRAY') { }
1945 0 3 if ref $ns eq 'ARRAY'
1948 3 0 unless defined $$opts{'max'}
1949 0 3 if $$opts{'max'} == 0
1951 1 2 defined $ns ? :
1960 0 3 unless $$res[0]
1961 0 3 unless ref $res
1972 0 0 if (not defined $data and defined $$args{'file'})
1973 0 0 unless open my $in, '<:raw', $$args{'file'}
1975 0 0 unless (defined $data)
1980 0 0 unless (defined $$args{'file'} or defined $$args{'title'})
2002 0 0 unless (defined $url)
2037 0 1 unless $res
2040 0 1 unless $$res_user{'name'} eq $user
2065 0 9 unless my $res = $$self{'api'}->api({'action', 'query', 'titles', $page, 'prop', 'info|revisions', 'intoken', $type})
2083 0 3 if $$self{'debug'}
2087 0 3 defined $error && ref $error eq 'HASH' && exists $$error{'code'} && exists $$error{'details'} ? :
2100 0 1 if $$self{'debug'} > 1
2107 0 1 unless my $res = $$self{'api'}->api({'action', 'query', 'meta', 'userinfo'})
2125 0 0 unless $res
2126 0 0 unless $$res{'query'}
2127 0 0 unless $$res{'query'}{'userinfo'}
2128 0 0 unless $$res{'query'}{'userinfo'}{'name'}
2134 0 0 if $is ne $ought
2136 0 0 unless $$res{'query'}{'userinfo'}{'rights'}
2140 0 0 if ($right eq 'bot')
2146 0 0 unless $$res{'query'}{'userinfo'}{'groups'}
2149 0 0 if ($group eq 'sysop')
2154 0 0 unless ($has_bot and not $is_sysop)
2155 0 0 if $$self{'debug'} > 1
2157 0 0 unless $$self{'assert'}
2166 0 1 unless $res
2173 299 295 if (ref $hashref ne 'HASH')
2174 1 298 if ($hashref eq 'specials')
2177 35 51 if exists $$special{'private'} or exists $$special{'fishbowl'}
2207 1 0 if ($response->is_success)
2233 11 4 if exists $$self{'ns_data'}
2247 1 1 if exists $$self{'ns_alias_data'}