App/lcpan/Cmd/subnames_by_count.pm

filter: Statementstmt 53.3% 16 / 30 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 54.0% 20 / 37 CC 2 SCAR 11.0
CC
2
Cov
50%
handle_cmd
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« App/lcpan/Cmd/authors_by_script_count.pm ↑ Summary App/lcpan/Cmd/author_deps_by_dependent_count.pm »
1 package App::lcpan::Cmd::subnames_by_count;
2  
3 1 ▶use 5.010;
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 = '2023-09-26'; # DATE
11 1 our $DIST = 'App-lcpan'; # DIST
12 1 our $VERSION = '1.074'; # VERSION
13  
14 1 our %SPEC;
15  
16 1 $SPEC{'handle_cmd'} = {
17 v => 1.1,
18 summary => 'List subroutine names ranked by number of occurrences',
19 description => <<'_',
20  
21 _
22 args => {
23 %App::lcpan::common_args,
24 # XXX include_method
25 # XXX include_static_method
26 # XXX include_function
27 #packages => {
28 # 'x.name.is_plural' => 1,
29 # summary => 'Filter by package name(s)',
30 # schema => ['array*', of=>'str*', min_len=>1],
31 # element_completion => \&App::lcpan::_complete_mod,
32 # tags => ['category:filtering'],
33 #},
34 #authors => {
35 # 'x.name.is_plural' => 1,
36 # summary => 'Filter by author(s) of module',
37 # schema => ['array*', of=>'str*', min_len=>1],
38 # element_completion => \&App::lcpan::_complete_cpanid,
39 # tags => ['category:filtering'],
40 #},
41 },
42 };
43 0 ▶sub handle_cmd {
Subroutine handle_cmd: not called CC=2 SCAR=17.9
Pod documented
44 0 my %args = @_;
45  
46 0 my $state = App::lcpan::_init(\%args, 'ro');
47 0 my $dbh = $state->{dbh};
48  
49 0 my $sql = "SELECT
50 name sub,
51 COUNT(name) count
52 FROM sub
53 GROUP BY name
54 ORDER BY COUNT(name) DESC";
55  
56 0 my @res;
57 0 my $sth = $dbh->prepare($sql);
58 0 $sth->execute;
59 0 ▶ while (my $row = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 0 0 0
60 0 push @res, $row;
61 }
62  
63 0 require Data::TableData::Rank;
64 0 Data::TableData::Rank::add_rank_column_to_table(table => \@res, data_columns => ['count']);
65  
66 0 my $resmeta = {};
67 0 $resmeta->{'table.fields'} = [qw/rank sub count/];
68  
69 0 [200, "OK", \@res, $resmeta];
70 }
71  
72 1 1;
73 # ABSTRACT: List subroutine names ranked by number of occurrences
74  
75 __END__
« App/lcpan/Cmd/authors_by_script_count.pm ↑ Summary App/lcpan/Cmd/author_deps_by_dependent_count.pm »