Dist/Zilla/PluginBundle/Author/MINTLAB.pm

filter: Statementstmt 71.1% 101 / 142 Branchbran 4.5% 1 / 22 Conditioncond 37.8% 14 / 37 MC/DCmcdc 0.0% 0 / 17 Subroutinesub 82.9% 34 / 41 Podpod 100% 3 / 3 totaltotal 58.4% 153 / 262 CC 28 SCAR 31.6
CC
28
Cov
58%
configure
132.0
release_option
12.0
__ANON__
4.1
CRAP 23.5
↑ Summary auto/share/module/Dist-Zilla-MintingProfile-Author-MINTLAB/default/Module.pm »
1 package Dist::Zilla::PluginBundle::Author::MINTLAB;
2 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 # ABSTRACT: An plugin bundle for all distributions by MINTLAB
5 # KEYWORDS: author bundle distribution tool
6  
7 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use List::Util qw(uniq any first);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Moose::Util::TypeConstraints qw(enum subtype where);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # Use all the modules so we don't get weird dependency issues
13 2 ▶use Dist::Zilla::App::Command::xtest ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Dist::Zilla::Plugin::CheckExtraTests ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Dist::Zilla::Plugin::ContributorsFile ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use Dist::Zilla::Plugin::CopyFilesFromBuild::Filtered ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use Dist::Zilla::Plugin::Git::Contributors ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use Dist::Zilla::Plugin::MetaProvides ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use Dist::Zilla::Plugin::MinimumPerl ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use Dist::Zilla::Plugin::PodWeaver ();
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use Dist::Zilla::Plugin::Prereqs::AuthorDeps ();
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use Dist::Zilla::Plugin::PromptIfStale ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use Dist::Zilla::Plugin::Repository ();
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 ▶use Dist::Zilla::PluginBundle::Filter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25 2 ▶use Dist::Zilla::PluginBundle::Git::VersionManager ();
Subroutine BEGIN: called CC=1 SCAR=0.0
26 2 ▶use Dist::Zilla::PluginBundle::TestingMania ();
Subroutine BEGIN: called CC=1 SCAR=0.0
27 2 ▶use Dist::Zilla::Role::PluginBundle ();
Subroutine BEGIN: called CC=1 SCAR=0.0
28 2 ▶use Dist::Zilla::Role::PluginBundle::Easy ();
Subroutine BEGIN: called CC=1 SCAR=0.0
29 2 ▶use Dist::Zilla::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 2 our $VERSION = '0.02';
32  
33 2 with
34 'Dist::Zilla::Role::PluginBundle::Easy',
35 'Dist::Zilla::Role::PluginBundle::PluginRemover' =>
36 { -version => '0.103' },
37 'Dist::Zilla::Role::PluginBundle::Config::Slicer';
38  
39 has server => (
40 is => 'ro',
41 isa => enum([qw(github bitbucket gitlab none)]),
42 init_arg => undef,
43 lazy => 1,
44 1 ▶ default => sub { $_[0]->payload->{server} // 'gitlab' },
Subroutine __ANON__: called CC=2 SCAR=7.6
Condition50%1/2
$_[0]->payload->{"server"} // "gitlab"
l!l
01
MC/DC0%0/1
$_[0]->payload->{"server"} // "gitlab"
$_[0]->payload->{"server"}
Truth table50%1/2
A
A= $_[0]->payload->{"server"}
Aresult
11
00
45 2 );
46  
47 has airplane => (
48 is => 'ro',
49 isa => 'Bool',
50 init_arg => undef,
51 lazy => 1,
52 1 ▶ default => sub { $ENV{DZIL_AIRPLANE} || $_[0]->payload->{airplane} // 0 },
Subroutine __ANON__: called CC=3 SCAR=14.2
Condition40%2/5
($ENV{"DZIL_AIRPLANE"} || $_[0]->payload->{"airplane"}) // 0
l!l
01
$ENV{"DZIL_AIRPLANE"} or $_[0]->payload->{"airplane"}
l!l&&r!l&&!r
001
MC/DC0%0/2
($ENV{"DZIL_AIRPLANE"} || $_[0]->payload->{"airplane"}) // 0
$ENV{"DZIL_AIRPLANE"} $_[0]->payload->{"airplane"}
Truth table33%1/3
A or B
A= $ENV{"DZIL_AIRPLANE"}B= $_[0]->payload->{"airplane"}
ABresult
1X1
011
000
53 2 );
54  
55 has license => (
56 is => 'ro',
57 isa => 'Str',
58 init_arg => undef,
59 lazy => 1,
60 1 ▶ default => sub { $_[0]->payload->{license} // 'LICENSE' },
Subroutine __ANON__: called CC=2 SCAR=7.6
Condition50%1/2
$_[0]->payload->{"license"} // "LICENSE"
l!l
01
MC/DC0%0/1
$_[0]->payload->{"license"} // "LICENSE"
$_[0]->payload->{"license"}
Truth table50%1/2
A
A= $_[0]->payload->{"license"}
Aresult
11
00
61 2 );
62  
63 has exclude_files => (
64 isa => 'ArrayRef[Str]',
65 init_arg => undef,
66 lazy => 1,
67 1 ▶ default => sub { $_[0]->payload->{exclude_files} // [] },
Subroutine __ANON__: called CC=2 SCAR=7.6
Condition50%1/2
$_[0]->payload->{"exclude_files"} // []
l!l
01
MC/DC0%0/1
$_[0]->payload->{"exclude_files"} // []
$_[0]->payload->{"exclude_files"}
Truth table50%1/2
A
A= $_[0]->payload->{"exclude_files"}
Aresult
11
00
68 2 traits => ['Array'],
69 handles => { exclude_files => 'elements' },
70 );
71  
72 0 ▶around exclude_files => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
73 0 my $orig = shift;
74 0 my $self = shift;
75  
76 0 return sort(uniq(
77 $self->$orig(@_),
78 qw(Dockerfile .gitlab-ci.yml docker-compose.yml docker-compose.override.yml .dockerignore dev-bin/cpanm)
79 ));
80 2 };
81  
82 has copy_file_from_build => (
83 isa => 'ArrayRef[Str]',
84 init_arg => undef,
85 lazy => 1,
86 1 ▶ default => sub { $_[0]->payload->{copy_file_from_build} // [] },
Subroutine __ANON__: called CC=2 SCAR=7.6
Condition50%1/2
$_[0]->payload->{"copy_file_from_build"} // []
l!l
01
MC/DC0%0/1
$_[0]->payload->{"copy_file_from_build"} // []
$_[0]->payload->{"copy_file_from_build"}
Truth table50%1/2
A
A= $_[0]->payload->{"copy_file_from_build"}
Aresult
11
00
87 2 traits => ['Array'],
88 handles => { copy_files_from_build => 'elements' },
89 );
90  
91 0 ▶around copy_files_from_build => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
92 0 my $orig = shift;
93 0 my $self = shift;
94 0 sort(uniq(
95 $self->$orig(@_),
96 qw(Makefile.PL cpanfile Build.PL README README.md CONTRIBUTORS)
97 ));
98 2 };
99  
100 has copy_file_from_release => (
101 isa => 'ArrayRef[Str]',
102 init_arg => undef,
103 lazy => 1,
104 1 ▶ default => sub { $_[0]->payload->{copy_file_from_release} // [] },
Subroutine __ANON__: called CC=2 SCAR=7.6
Condition50%1/2
$_[0]->payload->{"copy_file_from_release"} // []
l!l
01
MC/DC0%0/1
$_[0]->payload->{"copy_file_from_release"} // []
$_[0]->payload->{"copy_file_from_release"}
Truth table50%1/2
A
A= $_[0]->payload->{"copy_file_from_release"}
Aresult
11
00
105 2 traits => ['Array'],
106 handles => { copy_files_from_release => 'elements' },
107 );
108  
109 0 ▶around copy_files_from_release => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
110 0 my $orig = shift;
111 0 my $self = shift;
112 0 sort(uniq(
113 $self->$orig(@_),
114 qw(LICENCE LICENSE CONTRIBUTING ppport.h INSTALL)
115 ));
116 2 };
117  
118 has debug => (
119 is => 'ro',
120 isa => 'Bool',
121 init_arg => undef,
122 lazy => 1,
123 default =>
124 1 ▶ sub { $ENV{DZIL_AUTHOR_DEBUG} // $_[0]->payload->{debug} // 0 },
Subroutine __ANON__: called CC=3 SCAR=14.2
Condition40%2/5
($ENV{"DZIL_AUTHOR_DEBUG"} // $_[0]->payload->{"debug"}) // 0
l!l
01
$ENV{"DZIL_AUTHOR_DEBUG"} // $_[0]->payload->{"debug"}
l!l&&r!l&&!r
001
MC/DC0%0/2
($ENV{"DZIL_AUTHOR_DEBUG"} // $_[0]->payload->{"debug"}) // 0
$ENV{"DZIL_AUTHOR_DEBUG"} $_[0]->payload->{"debug"}
Truth table33%1/3
A // B
A= $ENV{"DZIL_AUTHOR_DEBUG"}B= $_[0]->payload->{"debug"}
ABresult
1X1
011
000
125 2 );
126  
127 has upload_to => (
128 is => 'ro',
129 isa => enum([qw(cpan pause stratopan local)]),
130 init_arg => undef,
131 lazy => 1,
132 1 ▶ default => sub { $_[0]->payload->{upload_to} // 'cpan' },
Subroutine __ANON__: called CC=2 SCAR=7.6
Condition50%1/2
$_[0]->payload->{"upload_to"} // "cpan"
l!l
01
MC/DC0%0/1
$_[0]->payload->{"upload_to"} // "cpan"
$_[0]->payload->{"upload_to"}
Truth table50%1/2
A
A= $_[0]->payload->{"upload_to"}
Aresult
11
00
133 2 );
134  
135 has authority => (
136 is => 'ro',
137 isa => 'Str',
138 init_arg => undef,
139 lazy => 1,
140 1 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
141 1 my $self = shift;
142 1 ▶ $self->payload->{authority} // 'cpan:MINTLAB';
Condition50%1/2
$self->payload->{"authority"} // "cpan:MINTLAB"
l!l
01
MC/DC0%0/1
$self->payload->{"authority"} // "cpan:MINTLAB"
$self->payload->{"authority"}
Truth table50%1/2
A
A= $self->payload->{"authority"}
Aresult
11
00
143 },
144 2 );
145  
146 has fake_release => (
147 is => 'ro',
148 isa => 'Bool',
149 init_arg => undef,
150 lazy => 1,
151 default =>
152 1 ▶ sub { $ENV{FAKE_RELEASE} // $_[0]->payload->{fake_release} // 0 },
Subroutine __ANON__: called CC=3 SCAR=14.2
Condition40%2/5
($ENV{"FAKE_RELEASE"} // $_[0]->payload->{"fake_release"}) // 0
l!l
01
$ENV{"FAKE_RELEASE"} // $_[0]->payload->{"fake_release"}
l!l&&r!l&&!r
001
MC/DC0%0/2
($ENV{"FAKE_RELEASE"} // $_[0]->payload->{"fake_release"}) // 0
$ENV{"FAKE_RELEASE"} $_[0]->payload->{"fake_release"}
Truth table33%1/3
A // B
A= $ENV{"FAKE_RELEASE"}B= $_[0]->payload->{"fake_release"}
ABresult
1X1
011
000
153 2 );
154  
155 has changes_version_columns => (
156 is => 'ro',
157 1 ▶ isa => subtype('Int', where { $_ > 0 && $_ < 20 }),
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_ > 0 and $_ < 20 1 0 1
158 init_arg => undef,
159 lazy => 1,
160 1 ▶ default => sub { $_[0]->payload->{changes_version_columns} // 10 },
Subroutine __ANON__: called CC=2 SCAR=7.6
Condition50%1/2
$_[0]->payload->{"changes_version_columns"} // 10
l!l
01
MC/DC0%0/1
$_[0]->payload->{"changes_version_columns"} // 10
$_[0]->payload->{"changes_version_columns"}
Truth table50%1/2
A
A= $_[0]->payload->{"changes_version_columns"}
Aresult
11
00
161 2 );
162  
163 2 my @network_plugins = qw(
164 PromptIfStale
165 Test::Pod::LinkCheck
166 Test::Pod::No404s
167 Git::Remote::Check
168 CheckPrereqsIndexed
169 CheckIssues
170 UploadToCPAN
171 UploadToStratopan
172 Git::Push
173 );
174 2 my %network_plugins;
175 2 @network_plugins{ map { Dist::Zilla::Util->expand_config_package_name($_) }
176 @network_plugins } = () x @network_plugins;
177  
178 0 ▶sub _warn_me {
Subroutine _warn_me: not called CC=1 SCAR=6.9
179 0 my $msg = shift;
180 0 warn(sprintf("[\@Author::MINTLAB] %s\n", $msg));
181 }
182  
183 0 ▶sub commit_files_after_release {
Subroutine commit_files_after_release: not called CC=1 SCAR=6.9
Pod documented
184 0 my $self = shift;
185 0 grep { -e }
186 sort(uniq(
187 'README.pod',
188 'Changes',
189 $self->copy_files_from_release,
190 $self->copy_files_from_build,
191 ));
192 }
193  
194 2 my %removed;
195  
196 0 ▶sub release_option {
Subroutine release_option: not called CC=3 SCAR=24.8
Pod documented
197 0 my $self = shift;
198 0 ▶ if ($self->fake_release) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->fake_release) 0 0 0
199 0 _warn_me("Fake release has been set");
200 0 return 'FakeRelease';
201 }
202 0 ▶ if ($self->upload_to eq 'stratopan') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->upload_to eq "stratopan") 0 0 0
203 0 _warn_me("Stratopan release has been set");
204 0 my $prefix = 'stratopan';
205 return [
206 'UploadToStratopan' => {
207 repo => $self->payload->{"$prefix.repo"},
208 stack => $self->payload->{"$prefix.stack"},
209 0 recurse => $self->payload->{"$prefix.recurse"},
210 }
211 ],
212 ;
213 }
214 0 return 'UploadToCPAN';
215 }
216  
217 0 ▶sub configure {
Subroutine configure: not called CC=11 SCAR=48.8
Pod documented
218 0 my $self = shift;
219  
220 0 ▶ if ($self->debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->debug) 0 0 0
221 0 _warn_me(Dumper { payload => $self->payload, });
222 }
223  
224 0 ▶ if (!-d '.git' and -f 'META.json' and !exists $removed{'Git::GatherDir'})
Branch: 1 branch
BranchTrueFalseTotal
if (not -d ".git" and -f "META.json" and not exists $removed{"Git::GatherDir"}) 0 0 0
Condition0%0/6
not -d ".git" and -f "META.json" and not exists $removed{"Git::GatherDir"}
!ll&&!rl&&r
000
not -d ".git" and -f "META.json"
!ll&&!rl&&r
000
MC/DC0%0/3
not -d ".git" and -f "META.json" and not exists $removed{"Git::GatherDir"}
not -d ".git" -f "META.json" not exists $removed{"Git::GatherDir"}
Truth table0%0/4
not(A) and B and not(C)
A= not -d ".git"B= -f "META.json"C= not exists $removed{"Git::GatherDir"}
ABCresult
0XX0
10X0
1100
1111
225 {
226 0 ▶ _warn_me(
Branch: 1 branch
BranchTrueFalseTotal
-f 'Build.PL' ? : 0 0 0
227 '.git is missing and META.json is present -- this looks like a CPAN download rather than a git repository. You should probably run '
228 . (
229 -f 'Build.PL'
230 ? 'perl Build.PL; ./Build'
231 : 'perl Makefile.PL; make'
232 )
233 . ' instead of using dzil commands!',
234 );
235 }
236  
237 my @plugins = (
238  
239 [
240 'Git::GatherDir' => {
241 0 do {
242 my @filenames = uniq(
243 0 grep { -e } $self->copy_files_from_release,
244 $self->copy_files_from_build,
245 $self->exclude_files,
246 );
247 0 ▶ @filenames ? (exclude_filename => \@filenames) : ();
Branch: 2 branches
BranchTrueFalseTotal
@filenames ? : 0 0 0
$self->airplane ? : 0 0 0
248 },
249 },
250 ],
251  
252 [
253 'PromptIfStale' => 'stale modules, build' =>
254 { phase => 'build', module => [$self->meta->name] }
255 ],
256 [
257 'PromptIfStale' => 'stale modules, release' => {
258 phase => 'release',
259 check_all_plugins => 1,
260 check_all_prereqs => 1
261 }
262 ],
263  
264 qw(PruneCruft ManifestSkip MetaYAML MetaJSON),
265  
266 ['License' => { filename => $self->license }],
267  
268 ['ReadmeFromPod' => { type => 'markdown', readme => 'README.md' }],
269  
270 qw(ExecDir ShareDir MakeMaker Manifest
271 TestRelease PodWeaver),
272  
273 ['Git::Contributors' => { order_by => 'commits' }],
274 ['ContributorsFile' => { filename => 'CONTRIBUTORS' }],
275  
276 ['AutoPrereqs' => { skip => [qw(^perl$)] }],
277 ['Prereqs::AuthorDeps' => { ':version' => '0.006' }],
278 [
279 'MinimumPerl' =>
280 { ':version' => '1.006',
281 configure_finder => ':NoFiles'
282 }
283 ],
284 ['MetaProvides::Package'],
285  
286 ['CPANFile'],
287  
288 [ 'CopyFilesFromBuild::Filtered' => {
289 copy => [ $self->copy_files_from_build ]
290 }],
291  
292 [ 'Git::Check' => 'initial check' => { allow_dirty => [ $self->airplane ? 'dist.ini' : '' ] } ],
293  
294 qw(Git::CheckFor::MergeConflicts),
295 ['Git::Remote::Check' => { branch => 'master', remote_branch => 'master' } ],
296 ['Git::CheckFor::CorrectBranch' =>
297 { release_branch => 'master' }
298 ],
299  
300 qw(CheckPrereqsIndexed),
301  
302 ['Repository'],
303 ['ConfirmRelease'],
304  
305 $self->release_option,
306  
307 [
308 'CopyFilesFromRelease' =>
309 { filename => [$self->copy_files_from_release] }
310 ],
311 );
312  
313 0 ▶ if ($self->airplane) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->airplane) 0 0 0
314 0 _warn_me(
315 "Building in airplane mode, skipping network required modules");
316 @plugins = grep {
317 0 ▶ my $plugin
Branch: 2 branches
BranchTrueFalseTotal
!ref($_) ? : 0 0 0
ref $_ eq 'ARRAY' ? : 0 0 0
318 = Dist::Zilla::Util->expand_config_package_name(
319 !ref($_) ? $_ : ref eq 'ARRAY' ? $_->[0] : die 'wtf');
320 0 not exists $network_plugins{$plugin}
321 } @plugins;
322  
323 # allow our uncommitted dist.ini edit which sets 'airplane = 1'
324 #push @{( first { ref eq 'ARRAY' && $_->[0] eq 'Git::Check' } @plugins )->[-1]{allow_dirty}}, 'dist.ini';
325  
326 # halt release after pre-release checks, but before ConfirmRelease
327 0 push @plugins, 'BlockRelease';
328 }
329  
330 # Disable test::perl::critic as it messes with the version rewrite
331 # that happens during a build
332 # Also disable portability files as foo.conf.dist is not allowed :(
333 $self->add_bundle(
334 0 '@TestingMania' => {
335 disable => [
336 qw(
337 Test::Perl::Critic
338 Test::Portability::Files
339 )
340 ]
341 }
342 );
343  
344 # plugins to do with calculating, munging, incrementing versions
345 0 $self->add_bundle(
346 '@Git::VersionManager' => {
347 'RewriteVersion::Transitional.global' => 1,
348 'RewriteVersion::Transitional.fallback_version_provider' =>
349 'Git::NextVersion',
350 'RewriteVersion::Transitional.version_regexp' =>
351 '^v([\d._]+)(-TRIAL)?$',
352  
353 # for first Git::Commit
354 commit_files_after_release => [$self->commit_files_after_release],
355  
356 # because of [Git::Check], only files copied from the release would be added -- there is nothing else
357 # hanging around in the current directory
358 'release snapshot.add_files_in' => ['.'],
359 'release snapshot.commit_msg' => '%N-%v%t%n%n%c',
360  
361 'Git::Tag.tag_message' => 'v%v%t',
362  
363 'BumpVersionAfterRelease::Transitional.global' => 1,
364  
365 'NextRelease.:version' => '5.033',
366 'NextRelease.time_zone' => 'UTC',
367 'NextRelease.format' => '%-'
368 . ($self->changes_version_columns - 2)
369 . 'v %{yyyy-MM-dd HH:mm:ss\'Z\'}d%{ (TRIAL RELEASE)}T',
370 }
371 );
372 0 $self->add_plugins(@plugins);
373  
374 }
375  
376 2 __PACKAGE__->meta->make_immutable;
377  
378 __END__
↑ Summary auto/share/module/Dist-Zilla-MintingProfile-Author-MINTLAB/default/Module.pm »