blib/lib/IBGE/Municipios.pm

filter: Statementstmt 100% 18 / 18 Branchbran 100% 8 / 8 Conditioncond 86.6% 13 / 15 MC/DCmcdc 71.4% 5 / 7 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 92.4% 49 / 53 CC 10 SCAR 15.8
CC
10
Cov
95%
_init
6.0
codigo
5.0
BEGIN
1.0
CRAP 4.9
↑ 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.02;
6  
7 2 my %code_for_data = _init();
8  
9 5 ▶sub codigo {
Subroutine codigo: called CC=5 SCAR=16.1
Pod documented
10 5 my ($city, $state) = @_;
11 return ( $city
12 && $state
13 && exists $code_for_data{$state}
14 && exists $code_for_data{$state}{$city}
15 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
16 : undef
17 );
18 }
19  
20 2 ▶sub _init {
Subroutine _init: called CC=6 SCAR=17.9
21 2 my %codes = ();
22  
23 2 ▶ while (my $line = <DATA>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline DATA)) 11238 2 11240
24 11238 my ($state, $code, $city) = split /,/ => $line;
25 11238 ▶ chomp $city if defined $city;
Branch: 1 branch
BranchTrueFalseTotal
if defined $city 11142 96 11238
26 11238 ▶ next unless $state && $code && $city;
Branch: 1 branch
BranchTrueFalseTotal
unless $state and $code and $city 96 11142 11238
Condition83%5/6
$state and $code and $city
!ll&&!rl&&r
821411142
$state and $code
!ll&&!rl&&r
08211156
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 11142 $codes{$state}{$city} = $code;
28 }
29 2 return %codes;
30 }
31  
32 2 1;
33 __DATA__
↑ Summary