| 1 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | package Dist::Zilla::Plugin::CheckSelfDependency; # git description: v0.010-10-g077e534 | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Check if your distribution declares a dependency on itself | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # KEYWORDS: plugin validate distribution prerequisites dependencies modules | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # vim: set ts=8 sts=4 sw=4 tw=78 et : | ||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | our $VERSION = '0.011'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | with 'Dist::Zilla::Role::AfterBuild', | |||||||||||||||||||||||||||||||||||||||||
| 10 | 'Dist::Zilla::Role::FileFinderUser' => { | ||||||||||||||||||||||||||||||||||||||||||
| 11 | default_finders => [ ':InstallModules' ], | ||||||||||||||||||||||||||||||||||||||||||
| 12 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 'Dist::Zilla::Role::ModuleMetadata', | ||||||||||||||||||||||||||||||||||||||||||
| 14 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | ▶ | use CPAN::Meta::Prereqs 2.132830; # for merged_requirements | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 6 | ▶ | use CPAN::Meta::Requirements; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | around dump_config => sub | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | my ($orig, $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | my $config = $self->$orig; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | $config->{+__PACKAGE__} = { | |||||||||||||||||||||||||||||||||||||||||
| 25 | finder => $self->finder, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | return $config; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | sub after_build | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_build: called CC=12 SCAR=24.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 6 | my %prereqs = map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||
| 36 | 6 | map { keys %$_ } | |||||||||||||||||||||||||||||||||||||||||
| 37 | 6 | map { values %$_ } | |||||||||||||||||||||||||||||||||||||||||
| 38 | 40 | grep { defined } | |||||||||||||||||||||||||||||||||||||||||
| 39 | 10 | @{ $self->zilla->prereqs->as_string_hash }{qw(configure build runtime test)}; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 10 | my $develop_prereqs = $self->zilla->prereqs->cpan_meta_prereqs | |||||||||||||||||||||||||||||||||||||||||
| 42 | ->merged_requirements(['develop'], [qw(requires recommends suggests)]); | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 10 | my $develop_prereqs_hash = $develop_prereqs->as_string_hash; | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 10 | my $provides = $self->zilla->distmeta->{provides}; # copy, to avoid autovivifying | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 10 | my @errors; | |||||||||||||||||||||||||||||||||||||||||
| 48 | # when 'provides' data is mandatory, we will rely on what it says - | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # but for now, we will check our modules explicitly for provided packages. | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 10 | foreach my $file (@{$self->found_files}) | |||||||||||||||||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 10 | ▶ | $self->log_fatal([ 'Could not decode %s: %s', $file->name, $file->added_by ]) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$file->can("encoding") and $file->encoding eq "bytes"
MC/DC0%0/2
$file->can("encoding") and $file->encoding eq "bytes"
$file->can("encoding")
$file->encoding eq "bytes"
Truth table33%1/3
A and B
A= $file->can("encoding")B= $file->encoding eq "bytes"
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | if $file->can('encoding') and $file->encoding eq 'bytes'; | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 10 | my @packages = $self->module_metadata_for_file($file)->packages_inside; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 10 | foreach my $package (@packages) | |||||||||||||||||||||||||||||||||||||||||
| 57 | { | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 10 | ▶ | if (exists $prereqs{$package} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
exists $prereqs{$package} or exists $develop_prereqs_hash->{$package} and not exists $provides->{$package}
exists $develop_prereqs_hash->{$package} and not exists $provides->{$package}
MC/DC100%3/3
exists $prereqs{$package} or exists $develop_prereqs_hash->{$package} and not exists $provides->{$package}
exists $prereqs{$package}
exists $develop_prereqs_hash->{$package}
not exists $provides->{$package}
Truth table100%4/4
A or B and not(C)
A= exists $prereqs{$package}B= exists $develop_prereqs_hash->{$package}C= not exists $provides->{$package}
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | or (exists $develop_prereqs_hash->{$package} | ||||||||||||||||||||||||||||||||||||||||||
| 60 | # you can only have a develop prereq on yourself if you | ||||||||||||||||||||||||||||||||||||||||||
| 61 | # use 'provides' metadata - so we're darned sure we | ||||||||||||||||||||||||||||||||||||||||||
| 62 | # matched up the right module names | ||||||||||||||||||||||||||||||||||||||||||
| 63 | and not exists $provides->{$package})) | ||||||||||||||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 5 | push @errors, $package . ' is listed as a prereq, but is also provided by this dist (' | |||||||||||||||||||||||||||||||||||||||||
| 66 | . $file->name . ')!'; | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | next; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 5 | ▶ | next if not exists $develop_prereqs_hash->{$package}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | ▶ | my $version = $provides ? $provides->{$package}{version} : $self->zilla->version; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 3 | ▶ | if (not $develop_prereqs->accepts_module($package => $version)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | { | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | push @errors, "$package $develop_prereqs_hash->{$package} is listed as a develop prereq, " | |||||||||||||||||||||||||||||||||||||||||
| 76 | . 'but this dist doesn\'t provide that version (' | ||||||||||||||||||||||||||||||||||||||||||
| 77 | . $file->name . ' only has ' . $version . ')!'; | ||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 10 | ▶ | $self->log_fatal(@errors) if @errors; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | __END__ | ||||||||||||||||||||||||||||||||||||||||||