Cmd/nearest_mods.pm

filter: Statementstmt 59.2% 16 / 27 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 58.8% 20 / 34 CC 2 SCAR 11.0
CC
2
Cov
55%
handle_cmd
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« Cmd/nearest_dists.pm ↑ Summary CmdBundle/nearest.pm »
1 package App::lcpan::Cmd::nearest_mods;
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  
7 1 require App::lcpan;
8  
9 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
10 1 our $DATE = '2022-03-27'; # DATE
11 1 our $DIST = 'App-lcpan-CmdBundle-nearest'; # DIST
12 1 our $VERSION = '0.003'; # VERSION
13  
14 1 our %SPEC;
15  
16 $SPEC{handle_cmd} = {
17 1 v => 1.1,
18 summary => 'List modules with names nearest to a specified name',
19 args => {
20 %App::lcpan::mod_args,
21 },
22 links => [
23 {url=>'pm:CPAN::Nearest', summary=>'Also uses pm:Text::Fuzzy to search for nearest module names'},
24 ],
25 };
26  
27 0 ▶sub handle_cmd {
Subroutine handle_cmd: not called CC=2 SCAR=17.9
Pod documented
28 0 my %args = @_;
29  
30 0 my $state = App::lcpan::_init(\%args, 'ro');
31 0 my $dbh = $state->{dbh};
32  
33 0 my $sth = $dbh->prepare("SELECT name FROM module");
34 0 $sth->execute;
35 0 my @names;
36 0 ▶ while (my ($name) = $sth->fetchrow_array) { push @names, $name }
Branch: 1 branch
BranchTrueFalseTotal
if (my($name) = $sth->fetchrow_array) 0 0 0
37  
38 0 require Text::Fuzzy;
39 0 my $tf = Text::Fuzzy->new($args{module});
40  
41 0 [200, "OK", [$tf->nearestv(\@names)]];
42 }
43  
44 1 1;
45 # ABSTRACT: List modules with names nearest to a specified name
46  
47 __END__
« Cmd/nearest_dists.pm ↑ Summary CmdBundle/nearest.pm »