script/dump-perl-exports

filter: Statementstmt 68.8% 86 / 125 Branchbran 70.0% 21 / 30 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod n/a totaltotal 70.1% 120 / 171 CC 1 SCAR 0.0
CC
1
Cov
69%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« test-data/lib/Local/LongList.pm ↑ Summary test-data/lib/Local/ViaSubExporter.pm »
1 #!perl
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use feature qw( say );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 ▶use App::perlimports::ExportInspector ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use Getopt::Long::Descriptive qw( describe_options );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use List::Util qw( max );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 10 ▶use Log::Dispatch ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 ▶use Module::Runtime qw( use_module );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 10 ▶use Pod::Usage qw( pod2usage );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 10 ▶use Text::SimpleTable::AutoWidth ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 10 my ( $opts, $usage ) = _options();
16  
17 10 ▶if ( $opts->version ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->version) 1 9 10
18 1 say $App::perlimports::ExportInspector::VERSION;
19 1 exit(0);
20 }
21  
22 9 ▶if ( $opts->help ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->help) 1 8 9
23 1 print $usage;
24 1 exit(0);
25 }
26  
27 8 ▶if ( $opts->verbose_help ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->verbose_help) 1 7 8
28 1 print STDOUT $usage;
29 1 pod2usage({ -exitval => 0 });
30 }
31  
32 7 ▶if ( $opts->libs ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->libs) 2 5 7
33 2 unshift @INC, ( split m{,}, $opts->libs );
34 }
35  
36 7 my $logger = Log::Dispatch->new(
37 outputs => [
38 [
39 'Screen',
40 min_level => $opts->log_level,
41 newline => 1,
42 stderr => 1
43 ]
44 ]
45 );
46  
47 7 ▶my $module = $opts->module || shift @ARGV;
Condition66%2/3
$opts->module || shift @ARGV
l!l&&r!l&&!r
430
MC/DC0%0/2
$opts->module || shift @ARGV
$opts->module shift @ARGV
Truth table66%2/3
A || B
A= $opts->moduleB= shift @ARGV
ABresult
1X1
011
000
48  
49 7 ▶if ( !$module ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($module) 0 7 7
50 0 say q{Mandatory parameter 'module' missing};
51 0 print $usage;
52 0 exit(1);
53 }
54  
55 7 my $ei = App::perlimports::ExportInspector->new(
56 logger => $logger,
57 module_name => $module,
58 );
59  
60 7 ▶if ( $ei->is_oo_class ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ei->is_oo_class) 0 7 7
61 0 print 'Appears to be an Object Oriented class.' . "\n";
62 }
63  
64 7 ▶if ( @{ $ei->class_isa } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$ei->class_isa;}) 0 7 7
65 0 my $t = Text::SimpleTable::AutoWidth->new();
66 0 $t->captions( ['ISA'] );
67 0 for my $class ( @{ $ei->class_isa } ) {
68 0 $t->row($class);
69 }
70 0 print $t->draw;
71 }
72  
73 7 ▶if ( @{ $ei->pkg_isa } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$ei->pkg_isa;}) 4 3 7
74 4 my $t = Text::SimpleTable::AutoWidth->new();
75 4 $t->captions( ['Package ISA'] );
76 4 for my $class ( @{ $ei->pkg_isa } ) {
77 4 $t->row($class);
78 }
79 4 print $t->draw;
80 }
81  
82 7 ▶if ( @{ $ei->at_export_tags } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$ei->at_export_tags;}) 0 7 7
83 0 my %tags = %{ $ei->at_export_tags };
84 0 my @keys = keys %tags;
85  
86 0 my @headings = ( 'Export Tag', 'Exported Symbols' );
87  
88 0 my $col1_width = max map { length($_) } @keys, $headings[0];
89 0 my $col2_width = max map { length($_) } map ( { @{$_} } values %tags ),
90 $headings[1];
91  
92 0 my $t = Text::SimpleTable->new(
93 [ $col1_width, 'Export Tag' ],
94 [ $col2_width, 'Exported Symbols' ]
95 );
96  
97 0 my $i = 0;
98 0 for my $key ( sort @keys ) {
99 0 $t->row( $key, join "\n", sort @{ $tags{$key} } );
100 0 ++$i;
101 0 ▶ $t->hr if $i < scalar @keys;
Branch: 1 branch
BranchTrueFalseTotal
if $i < scalar @keys 0 0 0
102 }
103 0 print $t->draw;
104 }
105  
106 7 ▶if ( @{ $ei->at_export_fail } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$ei->at_export_fail;}) 0 7 7
107 0 my $t = Text::SimpleTable::AutoWidth->new();
108 0 $t->captions( ['@EXPORT_FAIL'] );
109 0 for my $val ( sort @{ $ei->at_export_fail } ) {
110 0 $t->row($val);
111 }
112 0 print $t->draw;
113 }
114  
115 7 ▶if ( $ei->has_implicit_exports ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ei->has_implicit_exports) 6 1 7
116 6 my $t = Text::SimpleTable::AutoWidth->new();
117 6 ▶ if ( $ei->implicit_export_names_match_values ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ei->implicit_export_names_match_values) { } 6 0 6
118 6 $t->captions( ['Default Exported Symbols'] );
119 6 for my $symbol ( sort $ei->implicit_export_names ) {
120 40 $t->row($symbol);
121 }
122 }
123 else {
124 0 $t->captions( [ 'Default Export Symbol', 'Import Name' ] );
125 0 for my $key ( sort $ei->implicit_export_names ) {
126 0 $t->row( $key, $ei->implicit_exports->{$key} );
127 }
128 }
129 6 print $t->draw;
130 6 printf( "%i symbols\n", scalar $ei->implicit_export_names );
131 }
132  
133 7 my $exports = $ei->explicit_exports;
134 7 ▶if ( !keys %{$exports} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$exports;}) 0 7 7
135 0 print 'No exported symbols found' . "\n";
136 0 exit(0);
137 }
138  
139 {
140 7 my $t = Text::SimpleTable::AutoWidth->new();
141  
142 7 ▶ if ( $ei->explicit_export_names_match_values ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ei->explicit_export_names_match_values) { } 6 1 7
143 6 $t->captions( ['All Exportable Symbols'] );
144 6 for my $symbol ( sort $ei->explicit_export_names ) {
145 40 $t->row($symbol);
146 }
147 }
148 else {
149 1 $t->captions( [ 'Explicit Export Symbol', 'Import Name' ] );
150 1 for my $key ( sort $ei->explicit_export_names ) {
151 1 $t->row( $key, $exports->{$key} );
152 }
153 }
154 7 print $t->draw;
155 7 printf( "%i symbols\n", scalar $ei->explicit_export_names );
156  
157 7 require Data::Dumper; ## no perlimports
158 7 $logger->debug( Data::Dumper::Dumper($ei) );
159 }
160  
161 10 ▶sub _options {
Subroutine _options: called CC=1 SCAR=0.0
162 10 return describe_options(
163 'dump-perl-exports %o',
164 [
165 'module|m=s', 'The module to inspect for exports',
166 ],
167 [],
168 [
169 'libs=s',
170 'Comma-separated list of library paths to include (eg --libs lib,t/lib,dev/lib)',
171  
172 ],
173 [],
174 [ 'version', 'Print installed version', { shortcircuit => 1 } ],
175 [
176 'log-level|l=s', 'Print messages to STDERR',
177 { default => 'warning' }
178 ],
179 [ 'help', 'Print usage message and exit', { shortcircuit => 1 } ],
180 [
181 'verbose-help', 'Print usage message and documentation ',
182 { shortcircuit => 1 }
183 ],
184 );
185 }
186  
187 # PODNAME: dump-perl-exports
188 # ABSTRACT: A command line utility for describing what a class exports
189  
190 __END__
« test-data/lib/Local/LongList.pm ↑ Summary test-data/lib/Local/ViaSubExporter.pm »