Dist/Zilla/PluginBundle/Author/WATERKIP.pm

filter: Statementstmt 49.0% 50 / 102 Branchbran 3.8% 1 / 26 Conditioncond 24.0% 12 / 50 MC/DCmcdc 0.0% 0 / 23 Subroutinesub 58.6% 17 / 29 Podpod 100% 4 / 4 totaltotal 35.9% 84 / 234 CC 35 SCAR 30.1
CC
35
Cov
35%
configure
72.0
__ANON__
56.0
release_option
30.0
CRAP 20.2
↑ Summary auto/share/module/Dist-Zilla-MintingProfile-Author-WATERKIP/default/Module.pm »
1 package Dist::Zilla::PluginBundle::Author::WATERKIP;
2 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 # ABSTRACT: An plugin bundle for all distributions by WATERKIP
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 URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 our $VERSION = '3.4';
14  
15 2 with
16 'Dist::Zilla::Role::PluginBundle::Easy',
17 'Dist::Zilla::Role::PluginBundle::Airplane',
18 'Dist::Zilla::Role::PluginBundle::PluginRemover' =>
19 { -version => '0.103' },
20 'Dist::Zilla::Role::PluginBundle::Config::Slicer';
21  
22 has server => (
23 is => 'ro',
24 isa => enum([qw(github bitbucket gitlab none)]),
25 init_arg => undef,
26 lazy => 1,
27 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
28 2 );
29  
30 has license => (
31 is => 'ro',
32 isa => 'Str',
33 init_arg => undef,
34 lazy => 1,
35 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
36 2 );
37  
38 has exclude_files => (
39 isa => 'ArrayRef[Str]',
40 init_arg => undef,
41 lazy => 1,
42 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
43 2 traits => ['Array'],
44 handles => { exclude_files => 'elements' },
45 );
46  
47 0 ▶around exclude_files => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
48 0 my $orig = shift;
49 0 my $self = shift;
50 0 sort(uniq(
51 $self->$orig(@_),
52 qw(Dockerfile .gitlab-ci.yml docker-compose.yml docker-compose.override.yml .dockerignore dev-bin/cpanm)
53 ));
54 2 };
55  
56 has copy_file_from_build => (
57 isa => 'ArrayRef[Str]',
58 init_arg => undef,
59 lazy => 1,
60 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
61 2 traits => ['Array'],
62 handles => { copy_files_from_build => 'elements' },
63 );
64  
65 0 ▶around copy_files_from_build => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
66 0 my $orig = shift;
67 0 my $self = shift;
68 0 sort(uniq(
69 $self->$orig(@_),
70 qw(Makefile.PL cpanfile Build.PL README README.md CONTRIBUTORS),
71 $self->license
72 ));
73 2 };
74  
75 has copy_file_from_release => (
76 isa => 'ArrayRef[Str]',
77 init_arg => undef,
78 lazy => 1,
79 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
80 2 traits => ['Array'],
81 handles => { copy_files_from_release => 'elements' },
82 );
83  
84 0 ▶sub mvp_multivalue_args { qw(copy_file_from_build copy_file_from_release exclude_files) }
Subroutine mvp_multivalue_args: not called CC=1 SCAR=6.9
85  
86 0 ▶around copy_files_from_release => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
87 0 my $orig = shift;
88 0 my $self = shift;
89 0 sort(uniq(
90 $self->$orig(@_),
91 qw(CONTRIBUTING ppport.h INSTALL)
92 ));
93 2 };
94  
95 has debug => (
96 is => 'ro',
97 isa => 'Bool',
98 init_arg => undef,
99 lazy => 1,
100 default =>
101 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
102 2 );
103  
104 has upload_to => (
105 is => 'ro',
106 isa => enum([qw(cpan pause stratopan local)]),
107 init_arg => undef,
108 lazy => 1,
109 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
110 2 );
111  
112 has cpan_host => (
113 is => 'ro',
114 isa => 'Str',
115 init_arg => undef,
116 lazy => 1,
117 0 ▶ default => sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
118 0 ▶ my $host = $ENV{DZIL_CPAN_HOST} // $_[0]->payload->{cpan_host} // '';
Condition0%0/5
($ENV{"DZIL_CPAN_HOST"} // $_[0]->payload->{"cpan_host"}) // ""
l!l
00
$ENV{"DZIL_CPAN_HOST"} // $_[0]->payload->{"cpan_host"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($ENV{"DZIL_CPAN_HOST"} // $_[0]->payload->{"cpan_host"}) // ""
$ENV{"DZIL_CPAN_HOST"} $_[0]->payload->{"cpan_host"}
Truth table0%0/3
A // B
A= $ENV{"DZIL_CPAN_HOST"}B= $_[0]->payload->{"cpan_host"}
ABresult
1X1
011
000
119 0 ▶ return $host if $host eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $host eq "" 0 0 0
120 0 ▶ $host = "https://$host" unless $host =~ m{\Ahttps?://};
Branch: 1 branch
BranchTrueFalseTotal
unless $host =~ m[\Ahttps?://] 0 0 0
121  
122 0 my $uri = URI->new($host);
123 0 ▶ $uri->path('/authenquery') if $uri->path eq '' || $uri->path eq '/';
Branch: 1 branch
BranchTrueFalseTotal
if $uri->path eq "" or $uri->path eq "/" 0 0 0
Condition0%0/3
$uri->path eq "" or $uri->path eq "/"
l!l&&r!l&&!r
000
MC/DC0%0/2
$uri->path eq "" or $uri->path eq "/"
$uri->path eq "" $uri->path eq "/"
Truth table0%0/3
A or B
A= $uri->path eq ""B= $uri->path eq "/"
ABresult
1X1
011
000
124 0 return $uri->as_string;
125 },
126 2 );
127  
128 has cpan_host_insecure => (
129 is => 'ro',
130 isa => 'Bool',
131 init_arg => undef,
132 lazy => 1,
133 0 ▶ default => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
134 0 ▶ $ENV{DZIL_CPAN_HOST_INSECURE} // $_[0]->payload->{cpan_host_insecure} // 0;
Condition0%0/5
($ENV{"DZIL_CPAN_HOST_INSECURE"} // $_[0]->payload->{"cpan_host_insecure"}) // 0
l!l
00
$ENV{"DZIL_CPAN_HOST_INSECURE"} // $_[0]->payload->{"cpan_host_insecure"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($ENV{"DZIL_CPAN_HOST_INSECURE"} // $_[0]->payload->{"cpan_host_insecure"}) // 0
$ENV{"DZIL_CPAN_HOST_INSECURE"} $_[0]->payload->{"cpan_host_insecure"}
Truth table0%0/3
A // B
A= $ENV{"DZIL_CPAN_HOST_INSECURE"}B= $_[0]->payload->{"cpan_host_insecure"}
ABresult
1X1
011
000
135 },
136 2 );
137  
138 has authority => (
139 is => 'ro',
140 isa => 'Str',
141 init_arg => undef,
142 lazy => 1,
143 1 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
144 1 my $self = shift;
145 1 ▶ $self->payload->{authority} // 'cpan:WATERKIP';
Condition50%1/2
$self->payload->{"authority"} // "cpan:WATERKIP"
l!l
01
MC/DC0%0/1
$self->payload->{"authority"} // "cpan:WATERKIP"
$self->payload->{"authority"}
Truth table50%1/2
A
A= $self->payload->{"authority"}
Aresult
11
00
146 },
147 2 );
148  
149 has release_branch => (
150 is => 'ro',
151 isa => 'Str',
152 init_arg => undef,
153 lazy => 1,
154 default =>
155 0 ▶ sub { $ENV{RELEASE_BRANCH} // $_[0]->payload->{release_branch} // 'master' },
Subroutine __ANON__: not called CC=3 SCAR=24.8
Condition0%0/5
($ENV{"RELEASE_BRANCH"} // $_[0]->payload->{"release_branch"}) // "master"
l!l
00
$ENV{"RELEASE_BRANCH"} // $_[0]->payload->{"release_branch"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($ENV{"RELEASE_BRANCH"} // $_[0]->payload->{"release_branch"}) // "master"
$ENV{"RELEASE_BRANCH"} $_[0]->payload->{"release_branch"}
Truth table0%0/3
A // B
A= $ENV{"RELEASE_BRANCH"}B= $_[0]->payload->{"release_branch"}
ABresult
1X1
011
000
156 2 );
157  
158 has fake_release => (
159 is => 'ro',
160 isa => 'Bool',
161 init_arg => undef,
162 lazy => 1,
163 default =>
164 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
165 2 );
166  
167 has changes_version_columns => (
168 is => 'ro',
169 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
170 init_arg => undef,
171 lazy => 1,
172 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
173 2 );
174  
175 0 ▶sub _warn_me {
Subroutine _warn_me: not called CC=1 SCAR=6.9
176 0 my $msg = shift;
177 0 warn(sprintf("[\@Author::WATERKIP] %s\n", $msg));
178 }
179  
180 0 ▶sub commit_files_after_release {
Subroutine commit_files_after_release: not called CC=1 SCAR=6.9
Pod documented
181 0 my $self = shift;
182 0 grep { -e }
183 sort(uniq('README.pod', 'Changes', $self->copy_files_from_release, $self->copy_files_from_build));
184 }
185  
186 0 ▶sub build_network_plugins {
Subroutine build_network_plugins: not called CC=1 SCAR=6.9
Pod documented
187 0 return [qw(
188 PromptIfStale
189 Test::Pod::LinkCheck
190 Test::Pod::No404s
191 Git::Remote::Check
192 CheckPrereqsIndexed
193 CheckIssues
194 UploadToCPAN
195 UploadToDarkPAN
196 UploadToStratopan
197 Git::Push
198 )];
199 };
200  
201 2 my %removed;
202  
203 0 ▶sub release_option {
Subroutine release_option: not called CC=5 SCAR=34.0
Pod documented
204 0 my $self = shift;
205 0 ▶ if ($self->fake_release) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->fake_release) 0 0 0
206 0 _warn_me("Fake release has been set");
207 0 return 'FakeRelease';
208 }
209 0 ▶ if ($self->cpan_host) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->cpan_host) 0 0 0
210 0 _warn_me("Uploading to alternate CPAN host: " . $self->cpan_host);
211 0 ▶ if ($self->cpan_host_insecure) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->cpan_host_insecure) 0 0 0
212 0 _warn_me("Ignoring TLS certificate errors for this host");
213 0 $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
214 }
215 return [
216 0 'UploadToDarkPAN' => {
217 upload_uri => $self->cpan_host,
218 }
219 ];
220 }
221 0 ▶ if ($self->upload_to eq 'stratopan') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->upload_to eq "stratopan") 0 0 0
222 0 _warn_me("Stratopan release has been set");
223 0 my $prefix = 'stratopan';
224 return [
225 'UploadToStratopan' => {
226 repo => $self->payload->{"$prefix.repo"},
227 stack => $self->payload->{"$prefix.stack"},
228 0 recurse => $self->payload->{"$prefix.recurse"},
229 }
230 ],
231 ;
232 }
233 0 return 'UploadToCPAN';
234 }
235  
236 0 ▶sub configure {
Subroutine configure: not called CC=8 SCAR=42.8
Pod documented
237 0 my $self = shift;
238  
239 0 ▶ if ($self->debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->debug) 0 0 0
240 0 _warn_me(Dumper { payload => $self->payload, });
241 }
242  
243 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
244 {
245 0 ▶ _warn_me(
Branch: 1 branch
BranchTrueFalseTotal
-f 'Build.PL' ? : 0 0 0
246 '.git is missing and META.json is present -- this looks like a CPAN download rather than a git repository. You should probably run '
247 . (
248 -f 'Build.PL'
249 ? 'perl Build.PL; ./Build'
250 : 'perl Makefile.PL; make'
251 )
252 . ' instead of using dzil commands!',
253 );
254 }
255  
256 my @plugins = (
257  
258 [
259 'Git::GatherDir' => {
260 do {
261 my @filenames = uniq(
262 0 grep { -e } $self->copy_files_from_release,
263 $self->copy_files_from_build,
264 $self->exclude_files,
265 );
266 0 ▶ @filenames ? (exclude_filename => \@filenames) : ();
Branch: 1 branch
BranchTrueFalseTotal
@filenames ? : 0 0 0
267 },
268 },
269 ],
270  
271 [
272 'PromptIfStale' => 'stale modules, build' =>
273 { phase => 'build', module => [$self->meta->name] }
274 ],
275 [
276 'PromptIfStale' => 'stale modules, release' => {
277 phase => 'release',
278 check_all_plugins => 1,
279 check_all_prereqs => 1
280 }
281 ],
282  
283 qw(PruneCruft ManifestSkip MetaYAML MetaJSON),
284  
285 ['License' => { filename => $self->license }],
286  
287 ['ReadmeFromPod' => { type => 'markdown', readme => 'README.md' }],
288  
289 qw(ExecDir ShareDir MakeMaker Manifest
290 TestRelease PodWeaver),
291  
292 ['Git::Contributors' => { order_by => 'commits', include_authors => 1 }],
293 ['ContributorsFile' => { filename => 'CONTRIBUTORS' }],
294  
295 [
296 'AutoPrereqs' => {
297 skip => [
298 0 ▶ map { "^$_\$" } qw(
Branch: 1 branch
BranchTrueFalseTotal
$self->airplane ? : 0 0 0
299 Data::Dumper
300 Exporter
301 autodie
302 base
303 constant
304 feature
305 overload
306 perl
307 strict
308 utf8
309 vars
310 warnings
311 )
312 ]
313 }
314 ],
315 ['Prereqs::AuthorDeps' => { ':version' => '0.006' }],
316 [
317 'MinimumPerl' => {
318 ':version' => '1.006',
319 configure_finder => ':NoFiles'
320 }
321 ],
322 ['MetaProvides::Package'],
323  
324 [
325 'Encoding' => [
326 encoding => 'bytes',
327 match => '\.ico$',
328 match => '\.docx?$',
329 match => '\.zip$',
330 match => '\.ztb$', # Mintlab specific, just a zip file
331 match => '\.pdf$',
332 match => '\.odt$',
333 match => '\.msg$',
334 match => '\.gz$',
335 ]
336 ],
337  
338 ['CPANFile'],
339  
340 [
341 'CopyFilesFromBuild::Filtered' =>
342 { copy => [$self->copy_files_from_build] }
343 ],
344  
345 [ 'Git::Check' => 'initial check' => { allow_dirty => [ $self->airplane ? 'dist.ini' : '' ] } ],
346  
347 qw(Git::CheckFor::MergeConflicts),
348 ['Git::Remote::Check' => { branch => 'master', remote_branch => 'master' } ],
349 ['Git::CheckFor::CorrectBranch' =>
350 { release_branch => $self->release_branch }
351 ],
352  
353 qw(CheckPrereqsIndexed),
354  
355 ['Repository'],
356 ['ConfirmRelease'],
357  
358 # This plugin seems cool, but also unmaintained with downstream
359 # deps which are also unmaintained. ABORT
360 #[ 'PrereqsClean'],
361  
362 $self->release_option,
363  
364 [
365 'CopyFilesFromRelease' =>
366 { filename => [$self->copy_files_from_release] }
367 ],
368 );
369  
370 # Disable test::perl::critic as it messes with the version rewrite
371 # that happens during a build
372 # Also disable portability files as foo.conf.dist is not allowed :(
373 0 $self->add_bundle(
374 '@TestingMania' => {
375 disable => [
376 qw(
377 Test::Perl::Critic
378 Test::Portability::Files
379 Test::Portability
380 )
381 ]
382 }
383 );
384  
385 # plugins to do with calculating, munging, incrementing versions
386 0 $self->add_bundle(
387 '@Git::VersionManager' => {
388 'RewriteVersion::Transitional.global' => 1,
389 'RewriteVersion::Transitional.fallback_version_provider' =>
390 'Git::NextVersion',
391 'RewriteVersion::Transitional.version_regexp' =>
392 '^v([\d._]+)(-TRIAL)?$',
393  
394 # for first Git::Commit
395 commit_files_after_release => [$self->commit_files_after_release],
396  
397 # because of [Git::Check], only files copied from the release would
398 # be added -- there is nothing else hanging around in the current
399 # directory
400 'release snapshot.add_files_in' => ['.'],
401 'release snapshot.commit_msg' => '%N-%v%t%n%n%c',
402  
403 'Git::Tag.tag_message' => 'v%v%t',
404  
405 'BumpVersionAfterRelease::Transitional.global' => 1,
406  
407 'NextRelease.:version' => '5.033',
408 'NextRelease.time_zone' => 'UTC',
409 'NextRelease.format' => '%-'
410 . ($self->changes_version_columns - 2)
411 . 'v %{yyyy-MM-dd HH:mm:ss\'Z\'}d%{ (TRIAL RELEASE)}T',
412 }
413 );
414 0 $self->add_plugins(@plugins);
415  
416 }
417  
418  
419 2 __PACKAGE__->meta->make_immutable;
420  
421 __END__
↑ Summary auto/share/module/Dist-Zilla-MintingProfile-Author-WATERKIP/default/Module.pm »