XCompletion/pathname_curdir.pm

filter: Statementstmt 61.7% 21 / 34 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 71.4% 5 / 7 Podpod 100% 1 / 1 totaltotal 42.8% 27 / 63 CC 8 SCAR 33.7
CC
8
Cov
42%
__ANON__
56.0
gen_completion
6.0
BEGIN
1.0
CRAP 29.2
« XCompletion/filename_curdir.pm ↑ Summary XCompletion/comma_sep.pm »
1 package Perinci::Sub::XCompletion::pathname_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=7 SCAR=40.3
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 push @entries, $e;
32 }
33 0 complete_array_elem(word=>$cargs{word}, array=>\@entries);
34 0 };
35 }
36  
37 1 1;
38 # ABSTRACT: Generate completion for file/directory name in the current directory
39  
40 __END__
« XCompletion/filename_curdir.pm ↑ Summary XCompletion/comma_sep.pm »