Branch Coverage

blib/lib/CGI/Lingua.pm
Criterion Covered Total %
branch 109 444 24.5


line true false branch
112 2 31 ref $_[0] eq 'HASH' ? :
118 3 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)
152 0 0 if ($rc->{'_what_language'} || $rc->{'_rlanguage'} and $info and $info->lang)
184 31 0 if (defined $^V and $^V ge "v5.14.0")
185 0 31 if ${^GLOBAL_PHASE} eq "DESTRUCT"
187 11 20 unless ($ENV{'REMOTE_ADDR'})
191 0 20 unless ref $self
194 20 0 unless $cache
197 0 0 if (my $l = $self->_what_language)
201 0 0 if $cache->get($key)
203 0 0 if (my $logger = $self->{'_logger'})
233 0 0 unless $warning
235 0 0 if (my $syslog = $self->{'_syslog'})
241 0 0 if (ref $syslog eq "HASH")
244 0 0 if (my $info = $self->{'_info'}) { }
253 0 0 if ($self->{'_logger'}) { }
0 0 elsif (not defined $self->{'_syslog'}) { }
294 10 7 unless ($self->{'_slanguage'})
325 1 15 unless ($self->{'_slanguage'})
344 0 8 if ($self->{'_logger'})
347 1 7 unless ($self->{'_slanguage'})
350 0 8 if ($self->{'_logger'})
379 0 0 unless ($self->{'_slanguage'})
396 10 29 unless ($self->{'_rlanguage'})
410 0 22 if ($self->{'_logger'})
418 21 1 if (defined $http_accept_language)
419 0 21 if ($self->{'_logger'})
425 0 0 if (not $_[0] =~ /^Use of uninitialized value/)
432 3 18 if (not $l and $http_accept_language =~ /(.+)-.+/)
438 2 1 if ($i18n->accepts($1, $self->{'_supported'}))
443 19 2 if ($l)
444 0 19 if ($self->{'_logger'})
448 6 13 unless ($l =~ /^..-..$/)
450 6 0 if ($self->{'_slanguage'})
451 0 6 if ($self->{'_logger'})
462 3 3 if ($http_accept_language =~ /..-(..)$/) { }
0 3 elsif ($http_accept_language =~ /..-([a-z]{2,3})$/i) { }
467 3 3 if ($sl)
477 13 0 if ($l =~ /(.+)-(..)$/)
483 13 0 if ($accepts)
484 0 13 if ($self->{'_logger'})
487 13 0 if ($accepts =~ /\-/) { }
491 0 0 if ($self->{'_cache'})
494 0 0 if ($from_cache) { }
495 0 0 if ($self->{'_logger'})
502 0 0 if ($self->{'_slanguage'})
503 0 0 if ($variety eq "uk")
511 0 0 if (defined $c)
515 0 0 if ($self->{'_sublanguage'})
517 0 0 if ($self->{'_logger'})
522 0 0 unless ($from_cache)
523 0 0 if ($self->{'_logger'})
533 0 13 if ($self->{'_logger'})
536 13 0 if ($accepts)
540 13 0 if ($variety =~ /[a-z]{2,3}/ and not defined $self->{'_sublanguage'})
542 0 13 if ($self->{'_logger'})
545 0 13 if ($variety eq "uk")
554 0 13 if ($self->{'_cache'})
557 0 13 if (defined $from_cache) { }
558 0 0 if ($self->{'_logger'})
572 13 0 if (defined $results[0])
578 0 13 if ($@ or not defined $language_name) { }
585 0 13 if ($self->{'_logger'})
588 0 13 if ($self->{'_cache'} and not defined $from_cache)
589 0 0 if ($self->{'_logger'})
596 13 0 if (defined $self->{'_sublanguage'})
604 0 2 if ($self->{'_slanguage'} and $self->{'_slanguage'} ne "Unknown")
605 0 0 if ($self->{'_rlanguage'} eq "Unknown")
608 0 0 if ($self->{'_rlanguage'})
609 0 0 if ($l = $self->_code2language($self->{'_rlanguage'}))
620 1 1 if (!$self->{'_rlanguage'} || $self->{'_rlanguage'} eq 'Unknown' and length $http_accept_language == 2 || $http_accept_language =~ /^..-..$/)
624 1 0 unless ($self->{'_rlanguage'})
631 0 3 if ($self->{'_dont_use_ip'})
640 2 1 if (not defined $country and my $c = $self->_what_language)
641 0 2 if ($c =~ /^(..)_(..)/) { }
1 1 elsif ($c =~ /^(..)$/) { }
648 1 2 if (defined $country)
649 0 1 if ($self->{'_logger'})
655 0 1 if ($self->{'_cache'})
660 0 1 if ($from_cache) { }
661 0 0 if ($self->{'_logger'})
667 0 1 if ($l)
669 0 0 if (defined $l)
672 0 0 if ($self->{'_logger'} and $language_name)
679 0 1 if ($language_name) { }
0 1 elsif (defined $ip) { }
680 0 0 if (not defined $self->{'_rlanguage'} or $self->{'_rlanguage'} eq "Unknown")
683 0 0 unless (exists $self->{'_slanguage'} and $self->{'_slanguage'} ne "Unknown")
688 0 0 if ($language_name and $language_code2 and not defined $http_accept_language) { }
690 0 0 if ($self->{'_logger'})
695 0 0 if ($self->{'_logger'})
699 0 0 unless ($code)
700 0 0 if ($http_accept_language and $http_accept_language ne $self->{'_rlanguage'})
701 0 0 if ($self->{'_logger'})
706 0 0 unless ($code)
709 0 0 if ($self->{'_rlanguage'} =~ /(.+)\s\(.+/)
710 0 0 if (not defined $http_accept_language or $1 ne $self->{'_rlanguage'})
711 0 0 if ($self->{'_logger'})
717 0 0 unless ($code)
725 0 0 if ($code)
727 0 0 $self->{'_slanguage'} ? :
736 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'}) { }
737 0 0 if ($self->{'_logger'})
742 0 0 if ($self->{'_logger'})
763 10 3 if (/^(.+)-.+/) { }
768 13 0 if ($language_string eq $s)
780 25 0 if (ref $self)
781 0 25 if ($self->{'_logger'})
784 2 23 if ($self->{'_what_language'})
785 0 2 if ($self->{'_logger'})
790 0 23 if (my $info = $self->{'_info'})
791 0 0 if (my $rc = $info->lang)
793 0 0 if ($self->{'_logger'})
801 0 23 if (defined $ENV{'LANG'})
804 0 0 if (ref $self)
810 21 2 if ($ENV{'HTTP_ACCEPT_LANGUAGE'})
811 21 0 if (ref $self)
832 0 12 if ($self->{'_logger'})
839 0 12 if ($self->{'_country'})
840 0 0 if ($self->{'_logger'})
847 0 12 if (defined $ENV{'GEOIP_COUNTRY_CODE'})
851 2 10 if ($ENV{'HTTP_CF_IPCOUNTRY'} and $ENV{'HTTP_CF_IPCOUNTRY'} ne "XX")
859 10 0 unless defined $ip
864 0 0 unless (is_ipv4($ip))
865 0 0 if ($ip eq '::1') { }
875 0 0 if (is_private_ip($ip))
876 0 0 if ($self->{'_logger'})
881 0 0 if (is_loopback_ip($ip))
882 0 0 if ($self->{'_logger'})
888 0 0 if ($self->{'_cache'})
890 0 0 if ($self->{'_logger'})
891 0 0 if (defined $self->{'_country'}) { }
897 0 0 if (defined $self->{'_country'})
902 0 0 if ($self->{'_have_ipcountry'} == -1)
903 0 0 if (eval {
911 0 0 if ($self->{'_logger'})
915 0 0 if ($self->{'_have_ipcountry'})
917 0 0 if ($self->{'_country'}) { }
925 0 0 unless (defined $self->{'_country'})
926 0 0 if ($self->{'_have_geoip'} == -1)
929 0 0 if ($self->{'_have_geoip'} == 1)
932 0 0 unless (defined $self->{'_country'})
933 0 0 if ($self->{'_have_geoipfree'} == -1)
937 0 0 if ($@) { }
945 0 0 if ($self->{'_have_geoipfree'} == 1)
950 0 0 if ($self->{'_country'} and $self->{'_country'} eq "eu")
953 0 0 if (not $self->{'_country'} and eval {
955 0 0 if ($self->{'_logger'})
962 0 0 if (my $data = LWP::Simple::WithCache::get("http://www.geoplugin.net/json.gp?ip=$ip"))
966 0 0 unless ($self->{'_country'})
967 0 0 if ($self->{'_logger'})
982 0 0 unless ($@ or not defined $whois or ref $whois ne "HASH")
983 0 0 if (defined $whois->{'Country'}) { }
0 0 elsif (defined $whois->{'country'}) { }
988 0 0 if ($self->{'_country'})
989 0 0 if ($self->{'_country'} eq 'EU') { }
0 0 elsif ($self->{'_country'} eq 'US' and $whois->{'StateProv'} eq 'PR') { }
998 0 0 if ($self->{'_country'}) { }
999 0 0 if ($self->{'_logger'})
1003 0 0 if ($self->{'_logger'})
1014 0 0 unless ($@)
1016 0 0 if ($self->{'_logger'})
1022 0 0 if ($self->{'_country'})
1025 0 0 if ($self->{'_country'} =~ /^(..)\s*#/)
1033 0 0 if ($self->{'_country'})
1035 0 0 if ($self->{'_country'} eq 'hk') { }
0 0 elsif ($self->{'_country'} eq 'eu') { }
1044 0 0 if (subnet_matcher('185.10.104.0/22')->($ip)) { }
1054 0 0 if ($self->{'_cache'})
1055 0 0 if ($self->{'_logger'})
1069 0 0 if ($^O eq 'MSWin32' or -r '/usr/local/share/GeoIP/GeoIP.dat' or -r '/usr/share/GeoIP/GeoIP.dat') { }
1073 0 0 if ($@) { }
1078 0 0 if (-r '/usr/share/GeoIP/GeoIP.dat') { }
1110 0 1 if ($self->{'_locale'})
1118 1 0 if (defined $agent and $agent =~ /\((.+)\)/)
1124 0 5 if ($candidate =~ /^[a-zA-Z]{2}-([a-zA-Z]{2})$/)
1127 0 0 if ($c)
1135 1 0 if (eval {
1139 1 0 if ($browser and $browser->country)
1141 1 0 if ($c)
1152 0 0 if ($country)
1160 0 0 unless ($@)
1161 0 0 if ($c)
1169 0 0 if (defined $ENV{'GEOIP_COUNTRY_CODE'})
1172 0 0 if ($c)
1192 0 0 if ($self->{'_logger'})
1195 0 0 if ($self->{'_timezone'})
1196 0 0 if ($self->{'_logger'})
1202 0 0 if ($self->{'_have_geoip'} == -1)
1205 0 0 if (my $ip = $ENV{'REMOTE_ADDR'}) { }
1206 0 0 if ($self->{'_have_geoip'} == 1)
1209 0 0 unless ($self->{'_timezone'})
1210 0 0 if (eval {
1211 0 0 if ($self->{'_logger'})
1218 0 0 if (my $data = LWP::Simple::WithCache::get("http://ip-api.com/json/$ip"))
1227 0 0 if (open my $fin, '<', '/etc/timezone') { }
1244 0 20 unless $code
1245 0 20 if ($self->{'_logger'})
1246 0 0 if (defined $self->{'_country'}) { }
1252 20 0 unless ($self->{'_cache'})
1256 0 0 if ($from_cache)
1257 0 0 if ($self->{'_logger'})
1262 0 0 if ($self->{'_logger'})
1273 0 18 unless $code
1274 0 18 if ($self->{'_logger'})
1275 0 0 if ($self->{'_country'}) { }
1282 0 1 if (not $_[0] =~ /No result found in country table/)
1296 0 13 unless $code
1297 0 13 if ($self->{'_logger'})
1300 13 0 unless ($self->{'_cache'})
1302 13 0 if (defined $country)
1308 0 0 if ($from_cache)
1309 0 0 if ($self->{'_logger'})
1314 0 0 if ($self->{'_logger'})
1318 0 0 if (defined $country)