| 1 | package Dist::Zilla::Plugin::PerlTidy::WithExclusions; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | our $VERSION = v0.001; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Perl::Tidy qw(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | with( | |||||||||||||||||||||||||||
| 9 | 'Dist::Zilla::Role::FileMunger', | ||||||||||||||||||||||||||||
| 10 | 'Dist::Zilla::Role::FileFinderUser' => { | ||||||||||||||||||||||||||||
| 11 | default_finders => [':AllFiles'], | ||||||||||||||||||||||||||||
| 12 | }, | ||||||||||||||||||||||||||||
| 13 | ); | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | has 'perltidyrc' => (is => 'ro'); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | has exclusions => ( | ||||||||||||||||||||||||||||
| 18 | is => 'ro', | ||||||||||||||||||||||||||||
| 19 | isa => 'ArrayRef[Str]', | ||||||||||||||||||||||||||||
| 20 | 0 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 21 | 1 | ); | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub mvp_multivalue_args {qw(exclusions)} | ||||||||||||||||||||||||||
|
Subroutine
mvp_multivalue_args: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub munge_files { | ||||||||||||||||||||||||||
|
Subroutine
munge_files: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 26 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | $self->munge_file($_) for @{ $self->found_files }; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub munge_file { | ||||||||||||||||||||||||||
|
Subroutine
munge_file: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 0 | my ($self, $file) = @_; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | return $self->_munge_perl($file) if $file->name =~ /\.(?:pm|pl|t)$/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | return if -B $file->name; # do not try to read binary file | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | return $self->_munge_perl($file) if $file->content =~ /^#!.*\bperl\b/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | return; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub _munge_perl { | ||||||||||||||||||||||||||
|
Subroutine
_munge_perl: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||
| 41 | 0 | my ($self, $file) = @_; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | return if ref($file) eq 'Dist::Zilla::File::FromCode'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | return if $file->name && $file->name =~ m{^blib/}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$file->name and $file->name =~ m[^blib/]
MC/DC0%0/2
$file->name and $file->name =~ m[^blib/]
$file->name
$file->name =~ m[^blib/]
Truth table0%0/3
A and B
A= $file->nameB= $file->name =~ m[^blib/]
| |||||||||||||||||||||||||||||
| 45 | return | ||||||||||||||||||||||||||||
| 46 | if $file->name | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | and scalar grep { $file->name =~ /$_/ } @{ $self->exclusions }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$file->name and scalar grep({$file->name =~ /$_/;} @{$self->exclusions;})
MC/DC0%0/1
$file->name and scalar grep({$file->name =~ /$_/;} @{$self->exclusions;})
$file->name
Truth table0%0/2
A
A= $file->name
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | my $perltidyrc; | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | if (defined $self->perltidyrc) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if (-r $self->perltidyrc) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | $perltidyrc = $self->perltidyrc; | |||||||||||||||||||||||||||
| 53 | } else { | ||||||||||||||||||||||||||||
| 54 | 0 | $self->log_fatal([ 'specified perltidyrc is not readable: %s', $perltidyrc ]); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | # make Perl::Tidy happy | ||||||||||||||||||||||||||||
| 59 | 0 | local @ARGV = (); | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | $self->log_debug([ 'Perltidying %s', $file->name, ]); | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | my $source = $file->content; | |||||||||||||||||||||||||||
| 64 | 0 | my ($destination, $errors); | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | Perl::Tidy::perltidy( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | source => \$source, | ||||||||||||||||||||||||||||
| 67 | destination => \$destination, | ||||||||||||||||||||||||||||
| 68 | stderr => \$errors, | ||||||||||||||||||||||||||||
| 69 | argv => ['--standard-error-output'], | ||||||||||||||||||||||||||||
| 70 | ($perltidyrc ? (perltidyrc => $perltidyrc) : ()), | ||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | $self->log([ 'Errors from perltidying %s: %s', $file->name, $errors, ]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | if $errors; | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | $file->content($destination); | |||||||||||||||||||||||||||
| 77 | } ## end sub _munge_perl | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 80 | 1 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 1 | 1; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||