blib/lib/IBGE/Municipios.pm

filter: Statementstmt 100% 17 / 17 Branchbran 100% 6 / 6 Conditioncond 86.6% 13 / 15 MC/DCmcdc 71.4% 5 / 7 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 92.0% 46 / 50 SCAR 22.0
CC
9
Cov
95%
codigo
5.0
_init
5.0
BEGIN
1.0
CRAP 9.0
↑ Summary
1 package IBGE::Municipios;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 our $VERSION = 0.01;
6  
7 2 my %code_for_data = _init();
8  
9 sub codigo {
10 5 ▶ my ($city, $state) = @_;
Subroutine codigo: called CC=5 SCAR=16.1
Pod documented
11  
12 return ( $city
13 && $state
14 && exists $code_for_data{$state}
15 && exists $code_for_data{$state}{$city}
16 5 ▶ ? $code_for_data{$state}{$city}
Branch: 1 branch
BranchTrueFalseTotal
$city && $state && exists $code_for_data{$state} && exists $code_for_data{$state}{$city} ? : 1 4 5
Condition88%8/9
$city and $state and exists $code_for_data{$state} and exists $code_for_data{$state}{$city}
!ll&&!rl&&r
311
$city and $state and exists $code_for_data{$state}
!ll&&!rl&&r
302
$city and $state
!ll&&!rl&&r
212
MC/DC75%3/4
$city and $state and exists $code_for_data{$state} and exists $code_for_data{$state}{$city}
$city $state exists $code_for_data{$state} exists $code_for_data{$state}{$city}
Truth table80%4/5
A and B and C and D
A= $cityB= $stateC= exists $code_for_data{$state}D= exists $code_for_data{$state}{$city}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
17 : undef
18 );
19 }
20  
21 sub _init {
22 2 ▶ my %codes = ();
Subroutine _init: called CC=5 SCAR=16.1
23  
24 2 ▶ while (my $line = <DATA>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline DATA)) 11234 2 11236
25 11234 my ($state, $code, $city) = split /,/ => $line;
26 11234 ▶ next unless $state && $code && $city;
Branch: 1 branch
BranchTrueFalseTotal
unless $state and $code and $city 104 11130 11234
Condition83%5/6
$state and $code and $city
!ll&&!rl&&r
901411130
$state and $code
!ll&&!rl&&r
09011144
MC/DC66%2/3
$state and $code and $city
$state $code $city
Truth table75%3/4
A and B and C
A= $stateB= $codeC= $city
ABCresult
0XX0
10X0
1100
1111
27  
28 11130 $codes{$state}{$city} = $code;
29 }
30 2 return %codes;
31 }
32  
33 2 1;
34 __DATA__
↑ Summary