Branch Coverage

blib/lib/CGI/Lingua.pm
Criterion Covered Total %
branch 109 446 24.4


line true false branch
112 2 29 ref $_[0] eq 'HASH' ? :
118 1 30 unless ($params{'supported'})
126 0 0 if ($cache and $ENV{'REMOTE_ADDR'})
129 0 0 if ($info and $l = $info->lang) { }
0 0 elsif ($l = $class->_what_language) { }
135 0 0 if ($logger)
138 0 0 if (my $rc = $cache->get($key))
139 0 0 if ($logger)
149 0 0 if ($rc->{'_what_language'} || $rc->{'_rlanguage'} and $info and $info->lang)
181 30 0 if (defined $^V and $^V ge 'v5.14.0')
182 0 30 if ${^GLOBAL_PHASE} eq 'DESTRUCT'
184 10 20 unless ($ENV{'REMOTE_ADDR'})
188 0 20 unless ref $self
191 20 0 unless $cache
194 0 0 if (my $l = $self->_what_language)
198 0 0 if $cache->get($key)
200 0 0 if (my $logger = $self->{'_logger'})
230 0 0 unless $warning
232 0 0 if (my $syslog = $self->{'_syslog'})
238 0 0 if (ref $syslog eq 'HASH')
241 0 0 if (my $info = $self->{'_info'}) { }
250 0 0 if ($self->{'_logger'}) { }
0 0 elsif (not defined $self->{'_syslog'}) { }
290 10 7 unless ($self->{'_slanguage'})
321 1 15 unless ($self->{'_slanguage'})
340 0 8 if ($self->{'_logger'})
343 1 7 unless ($self->{'_slanguage'})
346 0 8 if ($self->{'_logger'})
375 0 0 unless ($self->{'_slanguage'})
392 10 29 unless ($self->{'_rlanguage'})
406 0 22 if ($self->{'_logger'})
414 21 1 if (defined $http_accept_language)
415 0 21 if ($self->{'_logger'})
421 0 0 if (not $_[0] =~ /^Use of uninitialized value/)
428 3 18 if (not $l and $http_accept_language =~ /(.+)-.+/)
434 2 1 if ($i18n->accepts($1, $self->{'_supported'}))
439 19 2 if ($l)
440 0 19 if ($self->{'_logger'})
444 6 13 unless ($l =~ /^..-..$/)
446 6 0 if ($self->{'_slanguage'})
447 0 6 if ($self->{'_logger'})
458 3 3 if ($http_accept_language =~ /..-(..)$/) { }
0 3 elsif ($http_accept_language =~ /..-([a-z]{2,3})$/i) { }
463 3 3 if ($sl)
473 13 0 if ($l =~ /(.+)-(..)$/)
479 13 0 if ($accepts)
480 0 13 if ($self->{'_logger'})
483 13 0 if ($accepts =~ /\-/) { }
487 0 0 if ($self->{'_cache'})
490 0 0 if ($from_cache) { }
491 0 0 if ($self->{'_logger'})
498 0 0 if ($self->{'_slanguage'})
499 0 0 if ($variety eq 'uk')
507 0 0 if (defined $c)
511 0 0 if ($self->{'_sublanguage'})
513 0 0 if ($self->{'_logger'})
518 0 0 unless ($from_cache)
519 0 0 if ($self->{'_logger'})
529 0 13 if ($self->{'_logger'})
532 13 0 if ($accepts)
536 13 0 if ($variety =~ /[a-z]{2,3}/ and not defined $self->{'_sublanguage'})
538 0 13 if ($self->{'_logger'})
541 0 13 if ($variety eq 'uk')
550 0 13 if ($self->{'_cache'})
553 0 13 if (defined $from_cache) { }
554 0 0 if ($self->{'_logger'})
568 13 0 if (defined $results[0])
574 0 13 if ($@ or not defined $language_name) { }
581 0 13 if ($self->{'_logger'})
584 0 13 if ($self->{'_cache'} and not defined $from_cache)
585 0 0 if ($self->{'_logger'})
592 13 0 if (defined $self->{'_sublanguage'})
600 0 2 if ($self->{'_slanguage'} and $self->{'_slanguage'} ne 'Unknown')
601 0 0 if ($self->{'_rlanguage'} eq 'Unknown')
604 0 0 if ($self->{'_rlanguage'})
605 0 0 if ($l = $self->_code2language($self->{'_rlanguage'}))
616 1 1 if (!$self->{'_rlanguage'} || $self->{'_rlanguage'} eq 'Unknown' and length $http_accept_language == 2 || $http_accept_language =~ /^..-..$/)
620 1 0 unless ($self->{'_rlanguage'})
627 0 3 if ($self->{'_dont_use_ip'})
636 2 1 if (not defined $country and my $c = $self->_what_language)
637 0 2 if ($c =~ /^(..)_(..)/) { }
1 1 elsif ($c =~ /^(..)$/) { }
644 1 2 if (defined $country)
645 0 1 if ($self->{'_logger'})
651 0 1 if ($self->{'_cache'})
656 0 1 if ($from_cache) { }
657 0 0 if ($self->{'_logger'})
663 0 1 if ($l)
665 0 0 if (defined $l)
668 0 0 if ($self->{'_logger'} and $language_name)
675 0 1 if ($language_name) { }
0 1 elsif (defined $ip) { }
676 0 0 if (not defined $self->{'_rlanguage'} or $self->{'_rlanguage'} eq 'Unknown')
679 0 0 unless (exists $self->{'_slanguage'} and $self->{'_slanguage'} ne 'Unknown')
684 0 0 if ($language_name and $language_code2 and not defined $http_accept_language) { }
686 0 0 if ($self->{'_logger'})
691 0 0 if ($self->{'_logger'})
695 0 0 unless ($code)
696 0 0 if ($http_accept_language and $http_accept_language ne $self->{'_rlanguage'})
697 0 0 if ($self->{'_logger'})
702 0 0 unless ($code)
705 0 0 if ($self->{'_rlanguage'} =~ /(.+)\s\(.+/)
706 0 0 if (not defined $http_accept_language or $1 ne $self->{'_rlanguage'})
707 0 0 if ($self->{'_logger'})
713 0 0 unless ($code)
721 0 0 if ($code)
723 0 0 $self->{'_slanguage'} ? :
732 0 0 if (not defined $self->{'_slanguage_code_alpha2'}) { }
0 0 elsif (not defined $from_cache and $self->{'_cache'} and defined $self->{'_slanguage_code_alpha2'}) { }
733 0 0 if ($self->{'_logger'})
738 0 0 if ($self->{'_logger'})
759 10 3 if (/^(.+)-.+/) { }
764 13 0 if ($language_string eq $s)
776 25 0 if (ref $self)
777 0 25 if ($self->{'_logger'})
780 2 23 if ($self->{'_what_language'})
781 0 2 if ($self->{'_logger'})
786 0 23 if (my $info = $self->{'_info'})
787 0 0 if (my $rc = $info->lang)
789 0 0 if ($self->{'_logger'})
797 0 23 if (defined $ENV{'LANG'})
800 0 0 if (ref $self)
806 21 2 if ($ENV{'HTTP_ACCEPT_LANGUAGE'})
807 21 0 if (ref $self)
828 0 12 if ($self->{'_logger'})
835 0 12 if ($self->{'_country'})
836 0 0 if ($self->{'_logger'})
843 0 12 if (defined $ENV{'GEOIP_COUNTRY_CODE'})
847 2 10 if ($ENV{'HTTP_CF_IPCOUNTRY'} and $ENV{'HTTP_CF_IPCOUNTRY'} ne 'XX')
855 10 0 unless defined $ip
860 0 0 unless (is_ipv4($ip))
861 0 0 if ($ip eq '::1') { }
871 0 0 if (is_private_ip($ip))
872 0 0 if ($self->{'_logger'})
877 0 0 if (is_loopback_ip($ip))
878 0 0 if ($self->{'_logger'})
884 0 0 if ($self->{'_cache'})
886 0 0 if ($self->{'_logger'})
887 0 0 if (defined $self->{'_country'}) { }
893 0 0 if (defined $self->{'_country'})
898 0 0 if ($self->{'_have_ipcountry'} == -1)
899 0 0 if (eval {
907 0 0 if ($self->{'_logger'})
911 0 0 if ($self->{'_have_ipcountry'})
913 0 0 if ($self->{'_country'}) { }
921 0 0 unless (defined $self->{'_country'})
922 0 0 if ($self->{'_have_geoip'} == -1)
923 0 0 if ($^O eq 'MSWin32' or -r '/usr/local/share/GeoIP/GeoIP.dat') { }
924 0 0 if (eval {
937 0 0 if ($self->{'_have_geoip'} == 1)
940 0 0 unless (defined $self->{'_country'})
941 0 0 if ($self->{'_have_geoipfree'} == -1)
942 0 0 if (eval {
950 0 0 if ($self->{'_have_geoipfree'} == 1)
955 0 0 if ($self->{'_country'} and $self->{'_country'} eq 'eu')
958 0 0 if (not $self->{'_country'} and eval {
960 0 0 if ($self->{'_logger'})
967 0 0 if (my $data = LWP::Simple::WithCache::get("http://www.geoplugin.net/json.gp?ip=$ip"))
971 0 0 unless ($self->{'_country'})
972 0 0 if ($self->{'_logger'})
987 0 0 unless ($@ or not defined $whois or ref $whois ne 'HASH')
988 0 0 if (defined $whois->{'Country'}) { }
0 0 elsif (defined $whois->{'country'}) { }
993 0 0 if ($self->{'_country'})
994 0 0 if ($self->{'_country'} eq 'EU') { }
0 0 elsif ($self->{'_country'} eq 'US' and $whois->{'StateProv'} eq 'PR') { }
1003 0 0 if ($self->{'_country'}) { }
1004 0 0 if ($self->{'_logger'})
1008 0 0 if ($self->{'_logger'})
1019 0 0 unless ($@)
1021 0 0 if ($self->{'_logger'})
1027 0 0 if ($self->{'_country'})
1030 0 0 if ($self->{'_country'} =~ /^(..)\s*#/)
1038 0 0 if ($self->{'_country'})
1040 0 0 if ($self->{'_country'} eq 'hk') { }
0 0 elsif ($self->{'_country'} eq 'eu') { }
1049 0 0 if (subnet_matcher('185.10.104.0/22')->($ip)) { }
1059 0 0 if ($self->{'_cache'})
1060 0 0 if ($self->{'_logger'})
1089 0 1 if ($self->{'_locale'})
1097 1 0 if (defined $agent and $agent =~ /\((.+)\)/)
1103 0 5 if ($candidate =~ /^[a-zA-Z]{2}-([a-zA-Z]{2})$/)
1106 0 0 if ($c)
1114 1 0 if (eval {
1118 1 0 if ($browser and $browser->country)
1120 1 0 if ($c)
1131 0 0 if ($country)
1139 0 0 unless ($@)
1140 0 0 if ($c)
1148 0 0 if (defined $ENV{'GEOIP_COUNTRY_CODE'})
1151 0 0 if ($c)
1171 0 0 if ($self->{'_logger'})
1174 0 0 if ($self->{'_timezone'})
1175 0 0 if ($self->{'_logger'})
1181 0 0 if ($self->{'_have_geoip'} == -1)
1182 0 0 if ($^O eq 'MSWin32' or -r '/usr/local/share/GeoIP/GeoIP.dat') { }
1183 0 0 if (eval {
1196 0 0 if (my $ip = $ENV{'REMOTE_ADDR'}) { }
1197 0 0 if ($self->{'_have_geoip'} == 1)
1200 0 0 unless ($self->{'_timezone'})
1201 0 0 if (eval {
1202 0 0 if ($self->{'_logger'})
1209 0 0 if (my $data = LWP::Simple::WithCache::get("http://ip-api.com/json/$ip"))
1218 0 0 if (open my $fin, '<', '/etc/timezone') { }
1235 0 20 unless $code
1236 0 20 if ($self->{'_logger'})
1237 0 0 if (defined $self->{'_country'}) { }
1243 20 0 unless ($self->{'_cache'})
1247 0 0 if ($from_cache)
1248 0 0 if ($self->{'_logger'})
1253 0 0 if ($self->{'_logger'})
1264 0 18 unless $code
1265 0 18 if ($self->{'_logger'})
1266 0 0 if ($self->{'_country'}) { }
1273 0 1 if (not $_[0] =~ /No result found in country table/)
1287 0 13 unless $code
1288 0 13 if ($self->{'_logger'})
1291 13 0 unless ($self->{'_cache'})
1293 13 0 if (defined $country)
1299 0 0 if ($from_cache)
1300 0 0 if ($self->{'_logger'})
1305 0 0 if ($self->{'_logger'})
1309 0 0 if (defined $country)