blib/lib/PLS/Server/Cache.pm

filter: Statementstmt 98.4% 65 / 66 Branchbran 79.1% 19 / 24 Conditioncond 77.7% 7 / 9 MC/DCmcdc 66.6% 4 / 6 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 4 totaltotal 88.2% 105 / 119 CC 19 SCAR 20.6
CC
19
Cov
92%
get_ext_modules
12.3
get_builtin_variables
8.0
BEGIN
1.0
CRAP 7.9
« blib/lib/PLS/Parser/Pod/Variable.pm ↑ Summary blib/lib/PLS/Server/Response/DocumentSymbol.pm »
1 package PLS::Server::Cache;
2  
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 13 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 13 ▶use ExtUtils::Installed;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use Module::CoreList;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 13 ▶use PLS::Parser::Pod;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub warm_up
14 4 ▶{
Subroutine warm_up: called CC=1 SCAR=0.0
Pod undocumented
15 4 get_builtin_variables();
16 4 get_core_modules();
17 4 get_ext_modules();
18  
19 4 return;
20 } ## end sub warm_up
21  
22 sub get_ext_modules
23 4 ▶{
Subroutine get_ext_modules: called CC=12 SCAR=25.1
Pod undocumented
24 4 state $include = [];
25 4 state $modules = [];
26  
27 4 my $curr_include = join ':', @{$include};
28 4 my $clean_inc = PLS::Parser::Pod->get_clean_inc();
29 4 my $updated_include = join ':', @{$clean_inc};
30  
31 0 ▶ if ($curr_include ne $updated_include or not scalar @{$modules})
Branch: 1 branch
BranchTrueFalseTotal
if ($curr_include ne $updated_include or not scalar @{$modules;}) 4 0 4
Condition33%1/3
$curr_include ne $updated_include or not scalar @{$modules;}
l!l&&r!l&&!r
400
MC/DC0%0/2
$curr_include ne $updated_include or not scalar @{$modules;}
$curr_include ne $updated_include not scalar @{$modules;}
Truth table33%1/3
A or not(B)
A= $curr_include ne $updated_includeB= not scalar @{$modules;}
ABresult
1X1
011
000
32 {
33 4 $include = $clean_inc;
34 4 my $installed = ExtUtils::Installed->new(inc_override => $clean_inc);
35  
36 4 foreach my $module ($installed->modules)
37 {
38 792 my @files = $installed->files($module);
39 792 $module =~ s/::/\//g;
40  
41 # Find all the packages that are part of this module
42 792 foreach my $file (@files)
43 {
44 46492 ▶ next if ($file !~ /\.pm$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ /\.pm$/ 37792 8700 46492
45 8700 my $valid = 0;
46  
47 8700 foreach my $path (@{$clean_inc})
48 {
49 69600 ▶ $valid = 1 if ($file =~ s/^\Q$path\E\/?(?:auto\/)?//);
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ s[^\Q$path\E/?(?:auto/)?][] 8700 60900 69600
50 }
51  
52 8700 ▶ next unless ($valid);
Branch: 1 branch
BranchTrueFalseTotal
unless $valid 0 8700 8700
53 8700 ▶ next unless (length $file);
Branch: 1 branch
BranchTrueFalseTotal
unless length $file 0 8700 8700
54 8700 $file =~ s/\.pm$//;
55 8700 my $mod_package = $file =~ s/\//::/gr;
56  
57 # Skip private packages
58 8700 ▶ next if ($mod_package =~ /^_/ or $mod_package =~ /::_/);
Branch: 1 branch
BranchTrueFalseTotal
if $mod_package =~ /^_/ or $mod_package =~ /::_/ 96 8604 8700
Condition100%3/3
$mod_package =~ /^_/ or $mod_package =~ /::_/
l!l&&r!l&&!r
4928604
MC/DC100%2/2
$mod_package =~ /^_/ or $mod_package =~ /::_/
$mod_package =~ /^_/ $mod_package =~ /::_/
Truth table100%3/3
A or B
A= $mod_package =~ /^_/B= $mod_package =~ /::_/
ABresult
1X1
011
000
59 8604 push @{$modules}, $mod_package;
60 } ## end foreach my $file (@files)
61 } ## end foreach my $module ($installed...)
62 } ## end if ($curr_include ne $updated_include...)
63  
64 4 return $modules;
65 } ## end sub get_ext_modules
66  
67 sub get_core_modules
68 4 ▶{
Subroutine get_core_modules: called CC=1 SCAR=0.0
Pod undocumented
69 4 state $core_modules = [Module::CoreList->find_modules(qr//, $])];
70 4 return $core_modules;
71 }
72  
73 sub get_builtin_variables
74 4 ▶{
Subroutine get_builtin_variables: called CC=8 SCAR=20.8
Pod undocumented
75 4 my $perldoc = PLS::Parser::Pod->get_perldoc_location();
76 4 state $builtin_variables = [];
77  
78 4 ▶ return $builtin_variables if (scalar @{$builtin_variables});
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$builtin_variables;} 0 4 4
79  
80 4 ▶ if (open my $fh, '-|', $perldoc, '-Tu', 'perlvar')
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, "-|", $perldoc, "-Tu", "perlvar") 4 0 4
81 {
82 4 ▶ while (my $line = <$fh>)
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 10892 4 10896
83 {
84 10892 ▶ if ($line =~ /=item\s*(C<)?([\$\@\%]\S+)\s*/)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /=item\s*(C<)?([\$\@\%]\S+)\s*/) 636 10256 10892
85 {
86 # If variable started with pod sequence "C<" remove ">" from the end
87 636 my $variable = $2;
88 636 ▶ $variable = substr $variable, 0, -1 if (length $1);
Branch: 1 branch
BranchTrueFalseTotal
if length $1 24 612 636
89  
90 # Remove variables indicated by pod sequences
91 636 ▶ next if ($variable =~ /^\$</ and $variable ne '$<'); ## no critic (RequireInterpolationOfMetachars)
Branch: 1 branch
BranchTrueFalseTotal
if $variable =~ /^\$</ and $variable ne "\$<" 4 632 636
Condition100%3/3
$variable =~ /^\$</ and $variable ne "\$<"
!ll&&!rl&&r
62844
MC/DC100%2/2
$variable =~ /^\$</ and $variable ne "\$<"
$variable =~ /^\$</ $variable ne "\$<"
Truth table100%3/3
A and B
A= $variable =~ /^\$</B= $variable ne "\$<"
ABresult
0X0
100
111
92 632 push @{$builtin_variables}, $variable;
93 } ## end if ($line =~ /=item\s*(C<)?([\$\@\%]\S+)\s*/...)
94 } ## end while (my $line = <$fh>)
95 } ## end if (open my $fh, '-|',...)
96  
97 4 return $builtin_variables;
98 } ## end sub get_builtin_variables
99  
100 13 1;
« blib/lib/PLS/Parser/Pod/Variable.pm ↑ Summary blib/lib/PLS/Server/Response/DocumentSymbol.pm »