Midgen.pm

filter: Statementstmt 15.1% 54 / 356 Branchbran 0.0% 0 / 188 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 30.7% 16 / 52 Podpod 100% 7 / 7 totaltotal 11.9% 77 / 646 CC 114 SCAR 51.7
CC
114
Cov
9%
_process_found_modules
552.0
_store_modules
380.0
run
240.0
CRAP 176.5
« Midgen/Role/Output/METAjson.pm ↑ Summary Midgen/Role/Experimental.pm »
1 package App::Midgen;
2  
3 2 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use constant {BLANK => q{ }, NONE => q{}, TWO => 2, THREE => 3, TRUE => 1,
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 FALSE => 0,};
6  
7 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 with qw(
9 App::Midgen::Role::Options
10 App::Midgen::Role::Attributes
11 App::Midgen::Role::AttributesX
12 App::Midgen::Role::InDistribution
13 App::Midgen::Role::TestRequires
14 App::Midgen::Role::UseOk
15 App::Midgen::Role::Eval
16 App::Midgen::Role::FindMinVersion
17 App::Midgen::Role::Output
18 App::Midgen::Role::UseModule
19 App::Midgen::Role::Experimental
20 App::Midgen::Role::Heuristics
21 );
22  
23 # Load time and dependencies negate execution time
24 # use namespace::clean -except => 'meta';
25 2 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 2 our $VERSION = '0.34';
27 2 $VERSION = eval $VERSION; ## no critic
28  
29 2 ▶use English qw( -no_match_vars ); # Avoids reg-ex performance penalty
Subroutine BEGIN: called CC=1 SCAR=0.0
30 2 local $OUTPUT_AUTOFLUSH = 1;
31  
32 2 ▶use Cwd qw(getcwd);
Subroutine BEGIN: called CC=1 SCAR=0.0
33 2 ▶use Data::Printer {caller_info => 1,};
Subroutine BEGIN: called CC=1 SCAR=0.0
34 2 ▶use File::Find qw(find);
Subroutine BEGIN: called CC=1 SCAR=0.0
35 2 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 2 ▶use Module::CoreList;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 2 ▶use PPI;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 2 ▶use Term::ANSIColor qw( :constants colored colorstrip );
Subroutine BEGIN: called CC=1 SCAR=0.0
39 2 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 2 ▶use Tie::Static qw(static);
Subroutine BEGIN: called CC=1 SCAR=0.0
41 2 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 # stop rlib from Fing all over cwd
44 2 our $Working_Dir = getcwd();
45 2 our $Min_Version = 0;
46  
47  
48 #######
49 # run
50 #######
51 0 ▶sub run {
Subroutine run: not called CC=15 SCAR=54.8
Pod documented
52 0 my $self = shift;
53  
54 0 $self->_initialise();
55 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 0 $self->first_package_name();
57 0 };
58  
59  
60 0 $self->find_runtime_modules();
61 0 $self->find_test_modules();
62 0 ▶ $self->find_develop_modules() if $self->experimental;
Branch: 1 branch
BranchTrueFalseTotal
if $self->experimental 0 0 0
63  
64 #now for some Heuristics :)
65 $self->recast_to_runtimerequires($self->{RuntimeRequires},
66 0 $self->{RuntimeRecommends});
67 0 $self->recast_to_testrequires($self->{TestRequires}, $self->{TestSuggests});
68  
69 # Now we have switched to MetaCPAN-Api we can hunt for noisy children in tests
70 0 ▶ if ($self->experimental) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->experimental) 0 0 0
71  
72 0 $self->remove_noisy_children($self->{RuntimeRequires});
73 0 $self->remove_twins($self->{RuntimeRequires});
74  
75 # Run a second time if we found any twins, this will sort out twins and triplets etc
76 $self->remove_noisy_children($self->{RuntimeRequires})
77 0 ▶ if $self->found_twins;
Branch: 1 branch
BranchTrueFalseTotal
if $self->found_twins 0 0 0
78  
79 0 foreach (qw( TestRequires TestSuggests DevelopRequires )) {
80  
81 0 ▶ p $self->{$_} if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
82 0 $self->remove_noisy_children($self->{$_});
83 0 foreach my $module (keys %{$self->{$_}}) {
84 0 ▶ if ($self->{RuntimeRequires}{$module}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"RuntimeRequires"}{$module}) 0 0 0
85 0 ▶ warn $module if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
86 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
87 0 delete $self->{$_}{$module};
88 0 };
89 }
90 }
91 0 ▶ p $self->{$_} if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
92 }
93 }
94  
95 # display chosen output format
96 0 $self->output_header();
97 0 $self->output_main_body('RuntimeRequires', $self->{RuntimeRequires});
98 $self->output_main_body('RuntimeRecommends', $self->{RuntimeRecommends})
99 0 ▶ if $self->meta2;
Branch: 1 branch
BranchTrueFalseTotal
if $self->meta2 0 0 0
100 0 $self->output_main_body('TestRequires', $self->{TestRequires});
101 0 ▶ if ($self->meta2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->meta2) { } 0 0 0
102 0 $self->output_main_body('TestSuggests', $self->{TestSuggests});
103 0 $self->output_main_body('Close', {});
104 0 $self->output_main_body('DevelopRequires', $self->{DevelopRequires});
105 }
106 else {
107  
108 # concatenate hashes
109 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
110 0 %{$self->{recommends}} = (%{$self->{RuntimeRecommends}},);
111 0 };
112 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
113 0 %{$self->{recommends}}
114 0 = (%{$self->{recommends}}, %{$self->{TestSuggests}},);
115 0 };
116 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
117 0 %{$self->{recommends}}
118 0 = (%{$self->{recommends}}, %{$self->{DevelopRequires}},);
119 0 };
120 0 $self->output_main_body('recommends', $self->{recommends});
121 }
122  
123 0 $self->output_footer();
124  
125 #now for tidy-up Heuristics :)
126 0 ▶ $self->remove_inc_mi() if ( $self->{format} eq 'dsl' or 'mi' );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"format"} eq "dsl" or "mi" 0 0 0
Condition0%0/2
$self->{"format"} eq "dsl" or "mi"
l!l
00
MC/DC0%0/1
$self->{"format"} eq "dsl" or "mi"
$self->{"format"} eq "dsl"
Truth table0%0/2
A
A= $self->{"format"} eq "dsl"
Aresult
11
00
127  
128 0 ▶ p $self->{modules} if ($self->verbose == TWO);
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose == 2 0 0 0
129  
130 0 return;
131 }
132  
133 #######
134 # initialise
135 #######
136 0 ▶sub _initialise {
Subroutine _initialise: not called CC=2 SCAR=17.9
137 0 my $self = shift;
138  
139 # let's give Output a copy, to stop it being F'up as well, suspect Tiny::Path as-well rlib
140 0 ▶ warn 'working in dir: ' . $Working_Dir if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
141  
142 0 return;
143 }
144  
145 #######
146 # first_package_name
147 #######
148 0 ▶sub first_package_name {
Subroutine first_package_name: not called CC=4 SCAR=30.0
Pod documented
149 0 my $self = shift;
150  
151 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
152 find(
153 0 ▶ sub { _find_package_names($self); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
154 0 File::Spec->catfile($Working_Dir, 'lib')
155 );
156 0 };
157  
158 0 ▶ p $self->package_names if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
159  
160 # We will assume the first package found is our Package Name, pot lock :)
161 # due to Milla not being a dist we go and get dist-name
162  
163 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
164 0 my $is_package_name = $self->package_names->[0];
165 0 $is_package_name =~ s{::}{-}g;
166  
167 # MetaCPAN::Client expects hyphens in distribution search
168 0 my $mcpan_dist_info = $self->mcpan->distribution($is_package_name);
169 0 my $distribution_name = $mcpan_dist_info->name();
170  
171 0 $distribution_name =~ s{-}{::}g;
172 0 $self->_set_distribution_name($distribution_name);
173 }
174 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
175 0 $self->_set_distribution_name($self->package_names->[0]);
176 0 };
177  
178 # I still want to see package name even though infile sets verbose = 0
179 0 ▶ print 'Package: ' . $self->distribution_name . "\n"
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose or $self->format eq "infile" 0 0 0
Condition0%0/3
$self->verbose or $self->format eq "infile"
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->verbose or $self->format eq "infile"
$self->verbose $self->format eq "infile"
Truth table0%0/3
A or B
A= $self->verboseB= $self->format eq "infile"
ABresult
1X1
011
000
180 if $self->verbose
181 or $self->format eq 'infile';
182  
183 0 return;
184 }
185 #######
186 # find_package_name
187 #######
188 0 ▶sub _find_package_names {
Subroutine _find_package_names: not called CC=4 SCAR=30.0
189 0 my $self = shift;
190 0 my $filename = $_;
191 0 static \my $files_checked;
192 0 ▶ if (defined $files_checked) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $files_checked) 0 0 0
193 0 ▶ return if $files_checked >= THREE;
Branch: 1 branch
BranchTrueFalseTotal
if $files_checked >= 3 0 0 0
194 }
195  
196 # Only check in pm files
197 0 ▶ return if $filename !~ /[.]pm$/sxm;
Branch: 1 branch
BranchTrueFalseTotal
unless $filename =~ /[.]pm$/msx 0 0 0
198  
199 # Load a Document from a file
200 0 $self->_set_ppi_document(PPI::Document->new($filename));
201  
202 # Extract package names
203 0 push @{$self->package_names},
204 $self->ppi_document->find_first('PPI::Statement::Package')->namespace;
205 0 $files_checked++;
206  
207 0 return;
208 }
209  
210  
211 #######
212 # find_runtime_modules
213 #######
214 0 ▶sub find_runtime_modules {
Subroutine find_runtime_modules: not called CC=4 SCAR=30.0
Pod documented
215 0 my $self = shift;
216  
217 my @posiable_directories_to_search
218 0 = map { File::Spec->catfile($Working_Dir, $_) }
219 qw( bin share script lib );
220  
221 0 my @directories_to_search = ();
222 0 foreach my $directory (@posiable_directories_to_search) {
223 0 ▶ if (defined -d $directory) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined -d $directory) 0 0 0
224 0 push @directories_to_search, $directory;
225 }
226 }
227 0 ▶ p @directories_to_search if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
228  
229 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
230 0 ▶ find(sub { _find_runtime_requirments($self); }, @directories_to_search);
Subroutine __ANON__: not called CC=1 SCAR=6.9
231 0 };
232  
233 0 return;
234  
235 }
236 #######
237 # _find_runtime_requirments
238 #######
239 0 ▶sub _find_runtime_requirments {
Subroutine _find_runtime_requirments: not called CC=14 SCAR=53.5
240 0 my $self = shift;
241 0 my $filename = $_;
242  
243 0 ▶ return if $self->is_perlfile($filename) == FALSE;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_perlfile($filename) == 0 0 0 0
244
245 0 my $relative_dir = $File::Find::dir;
246 0 $relative_dir =~ s/$Working_Dir//;
247 0 $self->_set_looking_infile(File::Spec->catfile($relative_dir, $filename));
248 0 $self->_set_ppi_document(PPI::Document->new($filename));
249  
250 # do extra test early check for use_module before hand
251 0 $self->xtests_use_module('RuntimeRecommends');
252  
253 # ToDo add eval/try here -> prereqs { runtime { suggests or recommends {...}}}
254 0 $self->xtests_eval('RuntimeRecommends');
255  
256 # normal pps -> RuntimeRequires
257 0 my $prereqs = $self->scanner->scan_ppi_document($self->ppi_document);
258 0 my @modules = $prereqs->required_modules;
259  
260  
261 0 foreach my $mod_ver (@modules) {
262 0 $self->{found_version}{$mod_ver}
263 = $prereqs->requirements_for_module($mod_ver);
264 }
265  
266 0 $self->{skip_not_mcpan_stamp} = 0;
267  
268 0 ▶ if (grep { $_ =~ m/^Dist::Zilla::Role::PluginBundle/ } @modules) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ =~ /^Dist::Zilla::Role::PluginBundle/;} @modules) 0 0 0
269  
270 0 $self->{skip_not_mcpan_stamp} = 1;
271  
272 0 my $ppi_tqs = $self->ppi_document->find('PPI::Token::Quote::Single');
273 0 ▶ if ($ppi_tqs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ppi_tqs) 0 0 0
274  
275 0 foreach my $include (@{$ppi_tqs}) {
276  
277 0 my $module = $include->content;
278 0 $module =~ s/^[']//;
279 0 $module =~ s/[']$//;
280  
281 0 ▶ next if $module =~ m/^Dist::Zilla::Role::PluginBundle/;
Branch: 1 branch
BranchTrueFalseTotal
if $module =~ /^Dist::Zilla::Role::PluginBundle/ 0 0 0
282 0 ▶ next if $module =~ m{\A[-|:|\d]};
Branch: 1 branch
BranchTrueFalseTotal
if $module =~ /\A[-|:|\d]/ 0 0 0
283 0 ▶ next if $module !~ m{\A(?:[[a-zA-Z])};
Branch: 1 branch
BranchTrueFalseTotal
unless $module =~ /\A(?:[[a-zA-Z])/ 0 0 0
284 0 ▶ next if $module =~ m{[.|$|\\|/|\-|\[|%|@|]};
Branch: 1 branch
BranchTrueFalseTotal
if $module =~ m([.|$|\\|/|\-|\[|%|@|]) 0 0 0
285 0 ▶ next if $module eq NONE;
Branch: 1 branch
BranchTrueFalseTotal
if $module eq "" 0 0 0
286  
287 0 push @modules, 'Dist::Zilla::Plugin::' . $module;
288 }
289 }
290 }
291  
292 0 ▶ if (scalar @modules > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @modules > 0) 0 0 0
293 0 for (0 .. $#modules) {
294 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
295 0 $self->_process_found_modules('RuntimeRequires', $modules[$_],
296 $prereqs->requirements_for_module($modules[$_]),
297 'Perl::PrereqScanner', 'RuntimeRequires',);
298 0 };
299 }
300 }
301  
302 #run pmv now
303 0 ▶ $self->min_version($self->looking_infile) if $self->format ne 'infile';
Branch: 1 branch
BranchTrueFalseTotal
if $self->format ne "infile" 0 0 0
304  
305 0 return;
306 }
307  
308  
309 #######
310 # find_test_modules
311 #######
312 0 ▶sub find_test_modules {
Subroutine find_test_modules: not called CC=2 SCAR=17.9
Pod documented
313 0 my $self = shift;
314  
315 0 my $directory = 't';
316 0 ▶ if (defined -d $directory) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined -d $directory) 0 0 0
317  
318 0 ▶ find(sub { _find_test_develop_requirments($self, $directory); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
319 0 $directory);
320  
321 }
322  
323 0 return;
324  
325 }
326 #######
327 # find_develop_modules
328 #######
329 0 ▶sub find_develop_modules {
Subroutine find_develop_modules: not called CC=2 SCAR=17.9
Pod documented
330 0 my $self = shift;
331  
332 0 my $directory = 'xt';
333 0 ▶ if (defined -d $directory) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined -d $directory) 0 0 0
334  
335 0 ▶ find(sub { _find_test_develop_requirments($self, $directory); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
336 0 $directory);
337  
338 }
339 0 return;
340  
341 }
342  
343  
344 #######
345 # _find_test_develop_requirments
346 #######
347 0 ▶sub _find_test_develop_requirments {
Subroutine _find_test_develop_requirments: not called CC=11 SCAR=48.8
348 0 my $self = shift;
349 0 my $directorie = shift;
350 0 my $filename = $_;
351  
352 ##p $directorie;
353 0 ▶ my $phase_relationship
Branch: 1 branch
BranchTrueFalseTotal
$directorie =~ /xt$/ ? : 0 0 0
354 = ($directorie =~ m/xt$/) ? 'DevelopRequires' : 'TestSuggests';
355 0 ▶ $self->_set_xtest(TRUE) if $directorie =~ m/xt$/;
Branch: 1 branch
BranchTrueFalseTotal
if $directorie =~ /xt$/ 0 0 0
356  
357 0 ▶ return if $self->is_perlfile($filename) == FALSE;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_perlfile($filename) == 0 0 0 0
358  
359 0 my $relative_dir = $File::Find::dir;
360 0 $relative_dir =~ s/$Working_Dir//;
361 0 $self->_set_looking_infile(File::Spec->catfile($relative_dir, $filename));
362  
363 # Load a Document from a file and check use and require contents
364 0 $self->_set_ppi_document(PPI::Document->new($filename));
365  
366 # don't scan xt/ for pmv
367 0 ▶ $self->min_version($filename)
Branch: 1 branch
BranchTrueFalseTotal
if not $directorie =~ /xt$/ or $self->format ne "infile" 0 0 0
Condition0%0/3
not $directorie =~ /xt$/ or $self->format ne "infile"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $directorie =~ /xt$/ or $self->format ne "infile"
not $directorie =~ /xt$/ $self->format ne "infile"
Truth table0%0/3
not(A) or B
A= not $directorie =~ /xt$/B= $self->format ne "infile"
ABresult
1X1
011
000
368 if $directorie !~ m/xt$/
369 or $self->format ne 'infile';
370  
371  
372 # do extra test early check for Test::Requires before hand
373 0 $self->xtests_test_requires($phase_relationship);
374  
375 # do extra test early check for use_ok in BEGIN blocks before hand
376 0 $self->xtests_use_ok($phase_relationship);
377  
378 # do extra test early to identify eval before hand
379 0 $self->xtests_eval($phase_relationship);
380  
381 # do extra test early check for use_module before hand
382 0 $self->xtests_use_module($phase_relationship);
383  
384  
385 # let's run p-ps for the rest
386 0 my $prereqs = $self->scanner->scan_ppi_document($self->ppi_document);
387 0 my @modules = $prereqs->required_modules;
388  
389 0 ▶ p @modules if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
390  
391 0 foreach my $mod_ver (@modules) {
392 0 $self->{found_version}{$mod_ver}
393 = $prereqs->requirements_for_module($mod_ver);
394 }
395  
396 0 ▶ if (scalar @modules > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @modules > 0) 0 0 0
397 0 for (0 .. $#modules) {
398  
399 0 ▶ if ($self->xtest) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->xtest) { } 0 0 0
400 0 ▶ try {
Subroutine __ANON__: not called CC=2 SCAR=17.9
401 0 ▶ $self->_process_found_modules($phase_relationship, $modules[$_],
Branch: 1 branch
BranchTrueFalseTotal
if $self->meta2 0 0 0
402 $prereqs->requirements_for_module($modules[$_]),
403 'Perl::PrereqScanner', $phase_relationship,)
404 if $self->meta2;
405 0 };
406 0 ▶ try {
Subroutine __ANON__: not called CC=2 SCAR=17.9
407 0 ▶ $self->_process_found_modules('DevelopRequires', $modules[$_],
Branch: 1 branch
BranchTrueFalseTotal
if not $self->meta2 0 0 0
408 $prereqs->requirements_for_module($modules[$_]),
409 'Perl::PrereqScanner', 'DevelopRequires',)
410 if not $self->meta2;
411 0 };
412 }
413 else {
414 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
415 0 $self->_process_found_modules('TestRequires', $modules[$_],
416 $prereqs->requirements_for_module($modules[$_]),
417 'Perl::PrereqScanner', 'TestRequires',);
418 0 };
419 }
420 }
421 }
422 0 return;
423 }
424  
425  
426 #######
427 # composed method - _process_found_modules
428 #######
429 0 ▶sub _process_found_modules {
Subroutine _process_found_modules: not called CC=23 SCAR=63.1
430 0 my $self = shift;
431 0 my $require_type = shift;
432 0 my $module = shift;
433 0 ▶ my $version = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
434 0 ▶ my $extra_scanner = shift || 'none';
Condition0%0/2
shift() || 'none'
l!l
00
MC/DC0%0/1
shift() || 'none'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
435 0 ▶ my $pr_location = shift || 'none';
Condition0%0/2
shift() || 'none'
l!l
00
MC/DC0%0/1
shift() || 'none'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
436  
437 0 ▶ p $module if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
438 0 ▶ p $version if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
439 0 ▶ p $require_type if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
440  
441 #deal with ''
442 0 ▶ next if $module eq NONE;
Branch: 1 branch
BranchTrueFalseTotal
if $module eq "" 0 0 0
443  
444 # let's show every thing we can find infile
445 0 ▶ if ($self->format ne 'infile') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->format ne "infile") 0 0 0
446  
447 0 ▶ my $distribution_name = $self->distribution_name || 'm/t';
Condition0%0/2
$self->distribution_name || 'm/t'
l!l
00
MC/DC0%0/1
$self->distribution_name || 'm/t'
$self->distribution_name
Truth table0%0/2
A
A= $self->distribution_name
Aresult
11
00
448  
449 0 ▶ if ($module =~ /perl/sxm) {
Branch: 6 branches
BranchTrueFalseTotal
if ($module =~ /perl/msx) { } 0 0 0
elsif ($module =~ /\A\Q$distribution_name\E/msx) { } 0 0 0
elsif ($module =~ /^t::/msx) { } 0 0 0
elsif ($module =~ /^inc::Module::Install/msx) { } 0 0 0
elsif ($module =~ /Mojo/msx) { } 0 0 0
elsif ($module =~ /^Padre/msx) { } 0 0 0
450  
451 # ignore perl we will get it from minperl required
452 0 next;
453 }
454 elsif ($module =~ /\A\Q$distribution_name\E/sxm) {
455  
456 # don't include our own packages here
457 0 next;
458 }
459 elsif ($module =~ /^t::/sxm) {
460  
461 # don't include our own test packages here
462 0 next;
463 }
464 elsif ($module =~ /^inc::Module::Install/sxm) {
465  
466 # don't inc::Module::Install as it is really Module::Install
467 0 next;
468 }
469 elsif ($module =~ /Mojo/sxm) {
470 0 ▶ if ($self->experimental) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->experimental) 0 0 0
471 0 ▶ if ($self->_check_mojo_core($module, $require_type)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_check_mojo_core($module, $require_type)) 0 0 0
472 0 ▶ if (not $self->quiet) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->quiet) 0 0 0
473 0 print BRIGHT_BLACK;
474 0 print "swapping out $module for Mojolicious\n";
475 0 print CLEAR;
476 }
477 0 next;
478 }
479 }
480 }
481 elsif ($module =~ /^Padre/sxm) {
482  
483 # mark all Padre core as just Padre only, for plugins
484 0 $module = 'Padre';
485 }
486 }
487  
488 # lets keep track of how many times a module include is found
489 0 $self->{modules}{$module}{count} += 1;
490 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
491 0 push @{$self->{modules}{$module}{infiles}},
492 [$self->looking_infile(), $version, $extra_scanner, $pr_location,];
493 0 };
494  
495 # don't process already found modules
496 0 ▶ p $self->{modules}{$module}{prereqs} if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
497  
498 0 ▶ next if defined $self->{modules}{$module}{prereqs};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"modules"}{$module}{"prereqs"} 0 0 0
499 0 ▶ p $module if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
500  
501 # add skip for infile as we don't need to get v-string from metacpan-api
502 0 ▶ $self->_store_modules($require_type, $module) if $self->format ne 'infile';
Branch: 1 branch
BranchTrueFalseTotal
if $self->format ne "infile" 0 0 0
503  
504 0 return;
505 }
506  
507 #######
508 # composed method - _store_modules
509 #######
510 0 ▶sub _store_modules {
Subroutine _store_modules: not called CC=19 SCAR=59.4
511 0 my $self = shift;
512 0 my $require_type = shift;
513 0 my $module = shift;
514 0 ▶ p $module if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
515  
516 $self->_in_corelist($module)
517 0 ▶ if not defined $self->{modules}{$module}{corelist};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"modules"}{$module}{"corelist"} 0 0 0
518 0 my $version = $self->get_module_version($module, $require_type);
519  
520 0 ▶ if ($version eq '!mcpan') {
Branch: 2 branches
BranchTrueFalseTotal
if ($version eq '!mcpan') { } 0 0 0
elsif ($version eq 'core') { } 0 0 0
521 $self->{$require_type}{$module} = colored('!mcpan', 'magenta')
522 0 ▶ if not $self->{skip_not_mcpan_stamp};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"skip_not_mcpan_stamp"} 0 0 0
523 0 $self->{modules}{$module}{prereqs} = $require_type;
524 0 $self->{modules}{$module}{version} = '!mcpan';
525 }
526 elsif ($version eq 'core') {
527 0 ▶ $self->{$require_type}{$module} = $version if $self->core;
Branch: 1 branch
BranchTrueFalseTotal
if $self->core 0 0 0
528 0 ▶ $self->{$require_type}{$module} = '0' if $self->zero;
Branch: 1 branch
BranchTrueFalseTotal
if $self->zero 0 0 0
529 0 $self->{modules}{$module}{prereqs} = $require_type;
530 0 ▶ $self->{modules}{$module}{version} = $version if $self->core;
Branch: 1 branch
BranchTrueFalseTotal
if $self->core 0 0 0
531 }
532 else {
533 0 ▶ if ($self->{modules}{$module}{corelist}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'modules'}{$module}{'corelist'}) { } 0 0 0
534  
535 0 ▶ $self->{$require_type}{$module} = colored($version, 'bright_yellow')
Branch: 1 branch
BranchTrueFalseTotal
if $self->dual_life or $self->core 0 0 0
Condition0%0/3
$self->dual_life or $self->core
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->dual_life or $self->core
$self->dual_life $self->core
Truth table0%0/3
A or B
A= $self->dual_lifeB= $self->core
ABresult
1X1
011
000
536 if ($self->dual_life || $self->core);
537 0 ▶ $self->{modules}{$module}{prereqs} = $require_type
Branch: 1 branch
BranchTrueFalseTotal
if $self->dual_life or $self->core 0 0 0
Condition0%0/3
$self->dual_life or $self->core
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->dual_life or $self->core
$self->dual_life $self->core
Truth table0%0/3
A or B
A= $self->dual_lifeB= $self->core
ABresult
1X1
011
000
538 if ($self->dual_life || $self->core);
539 0 ▶ $self->{modules}{$module}{version} = $version
Branch: 1 branch
BranchTrueFalseTotal
if $self->dual_life or $self->core 0 0 0
Condition0%0/3
$self->dual_life or $self->core
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->dual_life or $self->core
$self->dual_life $self->core
Truth table0%0/3
A or B
A= $self->dual_lifeB= $self->core
ABresult
1X1
011
000
540 if ($self->dual_life || $self->core);
541 0 $self->{modules}{$module}{dual_life} = 1;
542 0 $self->{modules}{$module}{prereqs} = $require_type;
543 0 $self->{modules}{$module}{version} = $version;
544  
545 }
546 else {
547 0 $self->{$require_type}{$module} = colored($version, 'yellow');
548 0 ▶ $self->{$require_type}{$module}
Branch: 1 branch
BranchTrueFalseTotal
if $self->numify 0 0 0
549 = colored(version->parse($version)->numify, 'yellow')
550 if $self->numify;
551  
552 0 $self->{modules}{$module}{prereqs} = $require_type;
553 0 $self->{modules}{$module}{version} = $version;
554  
555 $self->{$require_type}{$module} = colored($version, 'bright_cyan')
556 0 ▶ if $self->{modules}{$module}{'distribution'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"modules"}{$module}{"distribution"} 0 0 0
557 }
558 }
559 0 ▶ p $self->{modules}{$module} if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
560  
561 0 return;
562 }
563  
564 #######
565 # composed method _in_corelist
566 #######
567 0 ▶sub _in_corelist {
Subroutine _in_corelist: not called CC=3 SCAR=24.8
568 0 my $self = shift;
569 0 my $module = shift;
570  
571 #return TRUE (1) if defined $self->{modules}{$module}{corelist};
572  
573 # hash with core modules to process regardless
574 0 my $ignore_core = {'File::Path' => 1, 'Test::More' => 1,};
575  
576 0 ▶ if (!$ignore_core->{$module}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ignore_core->{$module}) 0 0 0
577  
578 0 ▶ if ( Module::CoreList->first_release($module) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ('Module::CoreList'->first_release($module)) { } 0 0 0
579 0 $self->{modules}{$module}{corelist} = 1;
580 0 return TRUE;
581 }
582 else {
583 0 $self->{modules}{$module}{corelist} = 0;
584 0 return FALSE;
585 }
586 }
587  
588 0 return FALSE;
589 }
590  
591  
592 #######
593 # _check_mojo_core
594 #######
595 0 ▶sub _check_mojo_core {
Subroutine _check_mojo_core: not called CC=6 SCAR=37.4
596 0 my $self = shift;
597 0 my $mojo_module = shift;
598 0 my $require_type = shift;
599  
600 0 my $mojo_module_ver;
601 0 static \my $mojo_ver;
602  
603 0 ▶ if (not defined $mojo_ver) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $mojo_ver) 0 0 0
604 0 $mojo_ver = $self->get_module_version('Mojolicious');
605 0 ▶ p $mojo_ver if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
606 }
607  
608 0 $mojo_module_ver = $self->get_module_version($mojo_module);
609  
610 0 ▶ if ($self->verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->verbose) 0 0 0
611 0 print BRIGHT_BLACK;
612  
613 #stdout - 'looks like we found another mojo core module';
614 0 print "$mojo_module version $mojo_module_ver\n";
615 0 print CLEAR;
616 }
617  
618 0 ▶ if ($mojo_ver == $mojo_module_ver) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mojo_ver == $mojo_module_ver) { } 0 0 0
619 $self->{$require_type}{'Mojolicious'}
620 = colored($mojo_module_ver, 'bright_blue')
621 0 ▶ if !$self->{modules}{'Mojolicious'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"modules"}{"Mojolicious"} 0 0 0
622 0 $self->{modules}{'Mojolicious'}{prereqs} = $require_type;
623 0 return 1;
624 }
625 else {
626 0 return 0;
627 }
628 }
629  
630 #######
631 # get module version using metacpan_client (mc)
632 #######
633 0 ▶sub get_module_version {
Subroutine get_module_version: not called CC=5 SCAR=34.0
Pod documented
634 0 my $self = shift;
635 0 my $module = shift;
636 0 ▶ my $require_type = shift || undef;
Condition0%0/2
shift() || undef
l!l
00
MC/DC0%0/1
shift() || undef
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
637 0 my $cpan_version;
638 0 my $found = 0;
639 0 my $mcc;
640  
641 0 ▶ p $module if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
642  
643 0 ▶ try {
Subroutine __ANON__: not called CC=2 SCAR=17.9
644  
645 0 $mcc = $self->mcpan->module($module);
646  
647 0 $cpan_version = $mcc->version_numified();
648 0 ▶ p $cpan_version if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
649  
650 0 $found = 1;
651 0 };
652 0 ▶ try {
Subroutine __ANON__: not called CC=5 SCAR=34.0
653 0 my $dist_name = $mcc->distribution();
654 0 $dist_name =~ s/-/::/g;
655  
656 0 ▶ if ($dist_name eq 'perl') {
Branch: 3 branches
BranchTrueFalseTotal
if ($dist_name eq 'perl') { } 0 0 0
elsif ($module =~ /^inc::/) { } 0 0 0
elsif ($dist_name ne $module) { } 0 0 0
657  
658 # mark all perl core modules with either 'core' or '0'
659 0 $cpan_version = 'core';
660 0 $found = 1;
661 }
662 elsif ($module =~ m/^inc::/) {
663  
664 #skip saving inc::Module::Install from Role-Output
665 0 return $cpan_version;
666 }
667 elsif ($dist_name ne $module) {
668  
669 # This is where we add a dist version to a knackered module
670 0 $self->{modules}{$module}{distribution} = $dist_name;
671 0 ▶ $self->mod_in_dist($dist_name, $module, $require_type,
Branch: 1 branch
BranchTrueFalseTotal
if $require_type 0 0 0
672 $mcc->version_numified())
673 if $require_type;
674 0 $found = 1;
675 }
676 }
677 0 ▶ finally {
Subroutine __ANON__: not called CC=2 SCAR=17.9
678 # not in metacpan so mark accordingly
679 0 ▶ $cpan_version = '!mcpan' if $found == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $found == 0 0 0 0
680 0 };
681  
682 # the following my note be needed any more due to developments in MetaCPAN
683 # scientific numbers in a version string, O what fun.
684 0 ▶ if ($cpan_version =~ m/\d+e/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cpan_version =~ /\d+e/) 0 0 0
685  
686 # a bit of de crappy-flying
687 # catch Test::Kwalitee::Extra 6e-06
688 0 print BRIGHT_BLACK;
689 0 ▶ print $module
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose >= 1 0 0 0
690 . ' Unique Release Sequence Indicator NOT! -> '
691 . $cpan_version . "\n"
692 if $self->verbose >= 1;
693 0 print CLEAR;
694 0 $cpan_version = version->parse($cpan_version)->numify;
695 }
696  
697 0 return $cpan_version;
698 }
699  
700 #######
701 # composed method
702 #######
703 0 ▶sub mod_in_dist {
Subroutine mod_in_dist: not called CC=6 SCAR=37.4
Pod documented
704 0 my $self = shift;
705 0 my $dist = shift;
706 0 my $module = shift;
707 0 my $require_type = shift;
708 0 my $version = shift;
709  
710 0 $dist =~ s/-/::/g;
711 0 ▶ if ($module =~ /$dist/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($module =~ /$dist/) 0 0 0
712  
713 0 print BRIGHT_BLACK;
714 0 ▶ print "module - $module -> in dist - $dist\n" if $self->verbose >= 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose >= 1 0 0 0
715 0 print CLEAR;
716  
717 # add dist to output hash so we can get rind of cruff later
718 0 ▶ if ($self->experimental) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->experimental) 0 0 0
719  
720 $self->{$require_type}{$dist} = colored($version, 'bright_cyan')
721 0 ▶ if not defined $self->{modules}{$module}{prereqs};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"modules"}{$module}{"prereqs"} 0 0 0
722 }
723  
724 $self->{$require_type}{$module} = colored($version, 'bright_cyan')
725 0 ▶ if not defined $self->{modules}{$module}{prereqs};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"modules"}{$module}{"prereqs"} 0 0 0
726 }
727  
728 0 return;
729 }
730  
731  
732 2 ▶no Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
733  
734 2 1;
735  
736 __END__
« Midgen/Role/Output/METAjson.pm ↑ Summary Midgen/Role/Experimental.pm »