XCompletion/filename_curdir.pm

filter: Statementstmt 60.0% 21 / 35 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 71.4% 5 / 7 Podpod 100% 1 / 1 totaltotal 40.9% 27 / 66 CC 9 SCAR 36.8
CC
9
Cov
40%
__ANON__
72.0
gen_completion
6.0
BEGIN
1.0
CRAP 39.5
« XCompletion/dirname_curdir.pm ↑ Summary XCompletion/pathname_curdir.pm »
1 package Perinci::Sub::XCompletion::filename_curdir;
2  
3 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Log::ger;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Complete::Util qw(complete_array_elem);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
11 1 our $DATE = '2023-11-18'; # DATE
12 1 our $DIST = 'Perinci-Sub-XCompletion'; # DIST
13 1 our $VERSION = '0.106'; # VERSION
14  
15 1 our %SPEC;
16  
17 $SPEC{gen_completion} = {
18 1 v => 1.1,
19 };
20 0 ▶sub gen_completion {
Subroutine gen_completion: not called CC=2 SCAR=17.9
Pod documented
21 0 my %fargs = @_;
22 0 ▶ my $allow_dot = $fargs{allow_dot} // 1;
Condition0%0/2
$fargs{"allow_dot"} // 1
l!l
00
MC/DC0%0/1
$fargs{"allow_dot"} // 1
$fargs{"allow_dot"}
Truth table0%0/2
A
A= $fargs{"allow_dot"}
Aresult
11
00
23  
24 0 ▶ sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
25 0 my %cargs = @_;
26 0 my @entries;
27 0 ▶ opendir my $dh, "." or do { log_warn "Can't opendir(.): $!"; return };
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, "." or do { log_warn("Can't opendir(.): $!"); return } 0 0 0
28 0 ▶ while (defined(my $e = readdir $dh)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $e = readdir $dh)) 0 0 0
29 0 ▶ next if $e eq '.' || $e eq '..';
Branch: 1 branch
BranchTrueFalseTotal
if $e eq "." or $e eq ".." 0 0 0
Condition0%0/3
$e eq "." or $e eq ".."
l!l&&r!l&&!r
000
MC/DC0%0/2
$e eq "." or $e eq ".."
$e eq "." $e eq ".."
Truth table0%0/3
A or B
A= $e eq "."B= $e eq ".."
ABresult
1X1
011
000
30 0 ▶ next if !$allow_dot && $e =~ /\A\./;
Branch: 1 branch
BranchTrueFalseTotal
if not $allow_dot and $e =~ /\A\./ 0 0 0
Condition0%0/3
not $allow_dot and $e =~ /\A\./
!ll&&!rl&&r
000
MC/DC0%0/2
not $allow_dot and $e =~ /\A\./
not $allow_dot $e =~ /\A\./
Truth table0%0/3
not(A) and B
A= not $allow_dotB= $e =~ /\A\./
ABresult
0X0
100
111
31 0 ▶ next unless -f $e;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $e 0 0 0
32 0 push @entries, $e;
33 }
34 0 complete_array_elem(word=>$cargs{word}, array=>\@entries);
35 0 };
36 }
37  
38 1 1;
39 # ABSTRACT: Generate completion for regular file name in the current directory
40  
41 __END__
« XCompletion/dirname_curdir.pm ↑ Summary XCompletion/pathname_curdir.pm »