blib/lib/Games/TF2/Demo/Names.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 2 / 2 Conditioncond 50.0% 3 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 11 / 11 Podpod 100% 4 / 4 totaltotal 91.0% 51 / 56 CC 4 SCAR 6.8
CC
4
Cov
92%
_name_in
4.4
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« blib/lib/Games/TF2/Server/Stats.pm ↑ Summary blib/lib/Games/TF2/Demo/Summary.pm »
1 package Games::TF2::Demo::Names;
2  
3 12 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶no warnings 'experimental::signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 12 our $VERSION = '0.01';
9  
10 12 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 12 our @EXPORT_OK = qw(team_name player_class_name building_kind_name projectile_kind_name);
14  
15 # The names the tfdemo tool gives the numbers of the C API (to_string of
16 # tf-demo-parser-cpp's src/match.cpp and src/gamestate.cpp).
17 12 Readonly my @TEAMS => qw(unassigned spectator red blue);
18 12 Readonly my @PLAYER_CLASSES => qw(unknown scout sniper soldier demoman medic heavy pyro spy engineer);
19 12 Readonly my @BUILDING_KINDS => qw(sentry dispenser teleporter_entrance teleporter_exit);
20 12 Readonly my @PROJECTILE_KINDS => qw(rocket sentry_rocket pipe sticky loose_cannon flare arrow healing_bolt jar cleaver ball other);
21  
22 34 ▶sub _name_in ( $names, $number, $fallback ) {
Subroutine _name_in: called CC=4 SCAR=14.9
23 34 ▶ return $fallback unless defined $number && $number =~ /\A[0-9]+\z/ && $number < @$names;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $number and $number =~ /\A[0-9]+\z/u and $number < @$names 4 30 34
Condition50%3/6
defined $number and $number =~ /\A[0-9]+\z/u and $number < @$names
!ll&&!rl&&r
0430
defined $number and $number =~ /\A[0-9]+\z/u
!ll&&!rl&&r
0034
MC/DC33%1/3
defined $number and $number =~ /\A[0-9]+\z/u and $number < @$names
defined $number $number =~ /\A[0-9]+\z/u $number < @$names
Truth table50%2/4
A and B and C
A= defined $numberB= $number =~ /\A[0-9]+\z/uC= $number < @$names
ABCresult
0XX0
10X0
1100
1111
24 30 return $names->[$number];
25 }
26  
27 5 ▶sub team_name ($team) { return _name_in( \@TEAMS, $team, 'unassigned' ) }
Subroutine team_name: called CC=1 SCAR=0.0
Pod documented
28 11 ▶sub player_class_name ($player_class) { return _name_in( \@PLAYER_CLASSES, $player_class, 'unknown' ) }
Subroutine player_class_name: called CC=1 SCAR=0.0
Pod documented
29 5 ▶sub building_kind_name ($kind) { return _name_in( \@BUILDING_KINDS, $kind, 'unknown' ) }
Subroutine building_kind_name: called CC=1 SCAR=0.0
Pod documented
30 13 ▶sub projectile_kind_name ($kind) { return _name_in( \@PROJECTILE_KINDS, $kind, 'unknown' ) }
Subroutine projectile_kind_name: called CC=1 SCAR=0.0
Pod documented
31  
32 12 1;
33  
34 __END__
« blib/lib/Games/TF2/Server/Stats.pm ↑ Summary blib/lib/Games/TF2/Demo/Summary.pm »