blib/lib/Dist/Zilla/Plugin/CheckForUnwantedFiles.pm

filter: Statementstmt 100% 39 / 39 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 2 totaltotal 94.5% 52 / 55 CC 5 SCAR 8.9
CC
5
Cov
98%
after_build
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
↑ Summary
1 2 ▶use 5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Dist::Zilla::Plugin::CheckForUnwantedFiles;
6  
7 # ABSTRACT: Check for unwanted files
8 2 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 2 our $VERSION = '0.0100';
10  
11 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Types::Standard qw/ArrayRef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 with qw/
17 Dist::Zilla::Role::AfterBuild
18 /;
19  
20 has unwanted_file => (
21 is => 'ro',
22 isa => ArrayRef,
23 1 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
24 2 );
25  
26 4 ▶sub mvp_multivalue_args { qw/unwanted_file/ }
Subroutine mvp_multivalue_args: called CC=1 SCAR=0.0
Pod undocumented
27  
28 4 ▶sub after_build {
Subroutine after_build: called CC=5 SCAR=16.1
Pod undocumented
29 4 my $self = shift;
30 4 my $root_path = path('.');
31  
32 4 my @existing_unwanted_paths = ();
33 4 for my $unwanted (@{ $self->unwanted_file }) {
34 3 ▶ push @existing_unwanted_paths => $unwanted if $root_path->child($unwanted)->exists;
Branch: 1 branch
BranchTrueFalseTotal
if $root_path->child($unwanted)->exists 3 0 3
35 }
36  
37 4 ▶ if (scalar @existing_unwanted_paths) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @existing_unwanted_paths) 3 1 4
38 3 $self->log('The following unwanted files exist:');
39 3 for my $unwanted (@existing_unwanted_paths) {
40 3 $self->log("* $unwanted");
41 }
42 3 $self->log_fatal('Build aborted.');
43 }
44 }
45  
46 2 __PACKAGE__->meta->make_immutable;
47  
48 2 1;
49  
50 __END__
↑ Summary