| 1 | package App::perlimports::ExportInspector; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 124 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | ## no critic (Modules::RequireExplicitInclusion, Subroutines::ProhibitCallsToUnexportedSubs, TestingAndDebugging::ProhibitNoStrict) | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 118 | our $VERSION = '0.000067'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 124 | ▶ | use App::perlimports::Sandbox (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 124 | ▶ | use Class::Inspector (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 124 | ▶ | use List::Util qw( any ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 124 | ▶ | use Module::Runtime qw( require_module ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 124 | ▶ | use Sub::HandlesVia; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 124 | ▶ | use Try::Tiny qw( catch try ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 124 | ▶ | use Types::Standard qw(ArrayRef Bool HashRef Int InstanceOf Str); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 118 | with 'App::perlimports::Role::Logger'; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | has at_export => ( | ||||||||||||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||||||||||
| 21 | isa => ArrayRef [Str], | ||||||||||||||||||||||||||||
| 22 | lazy => 1, | ||||||||||||||||||||||||||||
| 23 | 227 | ▶ | default => sub { shift->_implicit->{export} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 118 | ); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # Explicit accessor rather than a Sub::HandlesVia 'count' delegation. Array | ||||||||||||||||||||||||||||
| 27 | # handlers route through the Sub::HandlesVia::XS backend, whose XS array handler | ||||||||||||||||||||||||||||
| 28 | # caches the Perl stack pointer across the attribute builder's call_sv and can | ||||||||||||||||||||||||||||
| 29 | # write through it after the builder has reallocated the stack. See issue #171. | ||||||||||||||||||||||||||||
| 30 | 217 | ▶ | sub has_at_export { return scalar @{ $_[0]->at_export }; } | ||||||||||||||||||||||||||
|
Subroutine
has_at_export: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | has at_export_ok => ( | ||||||||||||||||||||||||||||
| 33 | is => 'ro', | ||||||||||||||||||||||||||||
| 34 | isa => ArrayRef [Str], | ||||||||||||||||||||||||||||
| 35 | lazy => 1, | ||||||||||||||||||||||||||||
| 36 | 223 | ▶ | default => sub { shift->_implicit->{export_ok} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 37 | 118 | ); | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # Explicit accessor rather than a Sub::HandlesVia 'count' delegation; see the | ||||||||||||||||||||||||||||
| 40 | # note on has_at_export above and issue #171. (An unused 'elements' delegation | ||||||||||||||||||||||||||||
| 41 | # was dropped here at the same time.) | ||||||||||||||||||||||||||||
| 42 | 305 | ▶ | sub has_at_export_ok { return scalar @{ $_[0]->at_export_ok }; } | ||||||||||||||||||||||||||
|
Subroutine
has_at_export_ok: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | has at_export_fail => ( | ||||||||||||||||||||||||||||
| 45 | is => 'ro', | ||||||||||||||||||||||||||||
| 46 | isa => ArrayRef [Str], | ||||||||||||||||||||||||||||
| 47 | lazy => 1, | ||||||||||||||||||||||||||||
| 48 | 15 | ▶ | default => sub { shift->_implicit->{export_fail} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 49 | 118 | ); | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | has at_export_tags => ( | ||||||||||||||||||||||||||||
| 52 | is => 'ro', | ||||||||||||||||||||||||||||
| 53 | isa => ArrayRef [Str], | ||||||||||||||||||||||||||||
| 54 | lazy => 1, | ||||||||||||||||||||||||||||
| 55 | 15 | ▶ | default => sub { shift->_implicit->{export_tags} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 56 | 118 | ); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | has class_isa => ( | ||||||||||||||||||||||||||||
| 59 | is => 'ro', | ||||||||||||||||||||||||||||
| 60 | isa => ArrayRef [Str], | ||||||||||||||||||||||||||||
| 61 | lazy => 1, | ||||||||||||||||||||||||||||
| 62 | 227 | ▶ | default => sub { shift->_implicit->{class_isa} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 63 | 118 | ); | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | has has_fatal_error => ( | ||||||||||||||||||||||||||||
| 66 | is => 'ro', | ||||||||||||||||||||||||||||
| 67 | isa => Bool, | ||||||||||||||||||||||||||||
| 68 | lazy => 1, | ||||||||||||||||||||||||||||
| 69 | 135 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||
| 70 | 135 | my $self = shift; | |||||||||||||||||||||||||||
| 71 | ( $self->_implicit->{fatal_error} | ||||||||||||||||||||||||||||
| 72 | || $self->explicit_exports->{fatal_error} ) | ||||||||||||||||||||||||||||
| 73 | 134 | ▶ | ? 1 | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->_implicit->{"fatal_error"} or $self->explicit_exports->{"fatal_error"}
MC/DC50%1/2
$self->_implicit->{"fatal_error"} or $self->explicit_exports->{"fatal_error"}
$self->_implicit->{"fatal_error"}
$self->explicit_exports->{"fatal_error"}
Truth table66%2/3
A or B
A= $self->_implicit->{"fatal_error"}B= $self->explicit_exports->{"fatal_error"}
| |||||||||||||||||||||||||||||
| 74 | : 0; | ||||||||||||||||||||||||||||
| 75 | }, | ||||||||||||||||||||||||||||
| 76 | 118 | ); | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 118 | has _implicit => ( | |||||||||||||||||||||||||||
| 79 | is => 'ro', | ||||||||||||||||||||||||||||
| 80 | isa => HashRef, | ||||||||||||||||||||||||||||
| 81 | lazy => 1, | ||||||||||||||||||||||||||||
| 82 | builder => '_build_implicit', | ||||||||||||||||||||||||||||
| 83 | ); | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 118 | has import_flags => ( | |||||||||||||||||||||||||||
| 86 | is => 'ro', | ||||||||||||||||||||||||||||
| 87 | isa => ArrayRef, | ||||||||||||||||||||||||||||
| 88 | lazy => 1, | ||||||||||||||||||||||||||||
| 89 | builder => '_build_import_flags', | ||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | # Explicit accessor rather than a Sub::HandlesVia 'count' delegation; see the | ||||||||||||||||||||||||||||
| 93 | # note on has_at_export above and issue #171. | ||||||||||||||||||||||||||||
| 94 | 138 | ▶ | sub has_import_flags { return scalar @{ $_[0]->import_flags }; } | ||||||||||||||||||||||||||
|
Subroutine
has_import_flags: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 118 | has is_exporter => ( | |||||||||||||||||||||||||||
| 97 | is => 'ro', | ||||||||||||||||||||||||||||
| 98 | isa => Bool, | ||||||||||||||||||||||||||||
| 99 | lazy => 1, | ||||||||||||||||||||||||||||
| 100 | builder => '_build_is_exporter', | ||||||||||||||||||||||||||||
| 101 | ); | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 118 | has isa_test_builder => ( | |||||||||||||||||||||||||||
| 104 | is => 'ro', | ||||||||||||||||||||||||||||
| 105 | isa => Bool, | ||||||||||||||||||||||||||||
| 106 | lazy => 1, | ||||||||||||||||||||||||||||
| 107 | builder => '_build_isa_test_builder', | ||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 118 | has explicit_exports => ( | |||||||||||||||||||||||||||
| 111 | is => 'ro', | ||||||||||||||||||||||||||||
| 112 | isa => HashRef, | ||||||||||||||||||||||||||||
| 113 | lazy => 1, | ||||||||||||||||||||||||||||
| 114 | handles_via => 'Hash', | ||||||||||||||||||||||||||||
| 115 | handles => { | ||||||||||||||||||||||||||||
| 116 | has_explicit_exports => 'count', | ||||||||||||||||||||||||||||
| 117 | explicit_export_names => 'keys', | ||||||||||||||||||||||||||||
| 118 | explicit_export_values => 'values', | ||||||||||||||||||||||||||||
| 119 | }, | ||||||||||||||||||||||||||||
| 120 | builder => '_build_explicit_exports', | ||||||||||||||||||||||||||||
| 121 | ); | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 118 | has implicit_exports => ( | |||||||||||||||||||||||||||
| 124 | is => 'ro', | ||||||||||||||||||||||||||||
| 125 | isa => HashRef, | ||||||||||||||||||||||||||||
| 126 | lazy => 1, | ||||||||||||||||||||||||||||
| 127 | handles_via => 'Hash', | ||||||||||||||||||||||||||||
| 128 | handles => { | ||||||||||||||||||||||||||||
| 129 | has_implicit_exports => 'count', | ||||||||||||||||||||||||||||
| 130 | implicit_export_names => 'keys', | ||||||||||||||||||||||||||||
| 131 | implicit_export_values => 'values', | ||||||||||||||||||||||||||||
| 132 | }, | ||||||||||||||||||||||||||||
| 133 | builder => '_build_implicit_exports', | ||||||||||||||||||||||||||||
| 134 | ); | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 224 | ▶ | sub _build_implicit_exports { | ||||||||||||||||||||||||||
|
Subroutine
_build_implicit_exports: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 137 | 224 | my $self = shift; | |||||||||||||||||||||||||||
| 138 | 224 | my $pkg = $self->_pkg_for_implicit; | |||||||||||||||||||||||||||
| 139 | return $self->is_exporter | ||||||||||||||||||||||||||||
| 140 | ? $self->_list_to_hash( $pkg, $self->at_export ) | ||||||||||||||||||||||||||||
| 141 | 224 | ▶ | : $self->_list_to_hash( $pkg, $self->_implicit->{_maybe_exports} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 118 | has is_moose_class => ( | |||||||||||||||||||||||||||
| 145 | is => 'ro', | ||||||||||||||||||||||||||||
| 146 | isa => Bool, | ||||||||||||||||||||||||||||
| 147 | lazy => 1, | ||||||||||||||||||||||||||||
| 148 | builder => '_build_is_moose_class', | ||||||||||||||||||||||||||||
| 149 | ); | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 118 | has is_moo_class => ( | |||||||||||||||||||||||||||
| 152 | is => 'ro', | ||||||||||||||||||||||||||||
| 153 | isa => Bool, | ||||||||||||||||||||||||||||
| 154 | lazy => 1, | ||||||||||||||||||||||||||||
| 155 | builder => '_build_is_moo_class', | ||||||||||||||||||||||||||||
| 156 | ); | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 118 | has is_moose_type_class => ( | |||||||||||||||||||||||||||
| 159 | is => 'ro', | ||||||||||||||||||||||||||||
| 160 | isa => Bool, | ||||||||||||||||||||||||||||
| 161 | lazy => 1, | ||||||||||||||||||||||||||||
| 162 | builder => '_build_is_moose_type_class', | ||||||||||||||||||||||||||||
| 163 | ); | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 118 | has is_oo_class => ( | |||||||||||||||||||||||||||
| 166 | is => 'ro', | ||||||||||||||||||||||||||||
| 167 | isa => Bool, | ||||||||||||||||||||||||||||
| 168 | lazy => 1, | ||||||||||||||||||||||||||||
| 169 | builder => '_build_is_oo_class', | ||||||||||||||||||||||||||||
| 170 | ); | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 118 | has _module_name => ( | |||||||||||||||||||||||||||
| 173 | is => 'ro', | ||||||||||||||||||||||||||||
| 174 | isa => Str, | ||||||||||||||||||||||||||||
| 175 | init_arg => 'module_name', | ||||||||||||||||||||||||||||
| 176 | required => 1, | ||||||||||||||||||||||||||||
| 177 | ); | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | has pkg_isa => ( | ||||||||||||||||||||||||||||
| 180 | is => 'ro', | ||||||||||||||||||||||||||||
| 181 | isa => ArrayRef [Str], | ||||||||||||||||||||||||||||
| 182 | lazy => 1, | ||||||||||||||||||||||||||||
| 183 | 146 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 184 | 124 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 185 | 146 | return [ @{ shift->_pkg_for_implicit . '::ISA' } ]; | |||||||||||||||||||||||||||
| 186 | }, | ||||||||||||||||||||||||||||
| 187 | 118 | ); | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | has _pkg_for_implicit => ( | ||||||||||||||||||||||||||||
| 190 | is => 'ro', | ||||||||||||||||||||||||||||
| 191 | isa => Str, | ||||||||||||||||||||||||||||
| 192 | lazy => 1, | ||||||||||||||||||||||||||||
| 193 | 227 | ▶ | default => sub { return shift()->_random_pkg_name }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 194 | 118 | ); | |||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 118 | has success_counter => ( | |||||||||||||||||||||||||||
| 197 | traits => ['Counter'], | ||||||||||||||||||||||||||||
| 198 | is => 'ro', | ||||||||||||||||||||||||||||
| 199 | isa => Int, | ||||||||||||||||||||||||||||
| 200 | default => 0, | ||||||||||||||||||||||||||||
| 201 | handles => { | ||||||||||||||||||||||||||||
| 202 | _increment_success_counter => 'inc', | ||||||||||||||||||||||||||||
| 203 | }, | ||||||||||||||||||||||||||||
| 204 | ); | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 118 | has uses_moose => ( | |||||||||||||||||||||||||||
| 207 | is => 'ro', | ||||||||||||||||||||||||||||
| 208 | isa => Bool, | ||||||||||||||||||||||||||||
| 209 | lazy => 1, | ||||||||||||||||||||||||||||
| 210 | builder => '_build_uses_moose', | ||||||||||||||||||||||||||||
| 211 | ); | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 210 | ▶ | sub evals_ok { | ||||||||||||||||||||||||||
|
Subroutine
evals_ok: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 214 | 210 | my $self = shift; | |||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 210 | $self->explicit_exports; | |||||||||||||||||||||||||||
| 217 | 210 | $self->implicit_exports; | |||||||||||||||||||||||||||
| 218 | 210 | return $self->success_counter; | |||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 218 | ▶ | sub _build_explicit_exports { | ||||||||||||||||||||||||||
|
Subroutine
_build_explicit_exports: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 222 | 218 | my $self = shift; | |||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | # If this is Exporter, then the exportable symbols will be listed in either | ||||||||||||||||||||||||||||
| 225 | # @EXPORT or @EXPORT_OK. Maybe in both? | ||||||||||||||||||||||||||||
| 226 | 218 | ▶ | if ( $self->has_at_export_ok || $self->has_at_export ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->has_at_export_ok or $self->has_at_export
MC/DC100%2/2
$self->has_at_export_ok or $self->has_at_export
$self->has_at_export_ok
$self->has_at_export
Truth table100%3/3
A or B
A= $self->has_at_export_okB= $self->has_at_export
| |||||||||||||||||||||||||||||
| 227 | return $self->_list_to_hash( | ||||||||||||||||||||||||||||
| 228 | $self->_pkg_for_implicit, # reuse package name | ||||||||||||||||||||||||||||
| 229 | 162 | [ @{ $self->at_export }, @{ $self->at_export_ok } ] | |||||||||||||||||||||||||||
| 230 | ); | ||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | # If this is Sub::Exporter, we can cheat and see what's in the :all tag | ||||||||||||||||||||||||||||
| 234 | 60 | my $pkg = $self->_random_pkg_name; | |||||||||||||||||||||||||||
| 235 | 60 | my $use_statement = sprintf( 'use %s qw(:all);', $self->_module_name ); | |||||||||||||||||||||||||||
| 236 | 60 | my ( $exports, $fatal_error ) | |||||||||||||||||||||||||||
| 237 | = $self->_exports_for_include( $pkg, $use_statement ); | ||||||||||||||||||||||||||||
| 238 | 60 | ▶ | if ($fatal_error) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | 11 | return { fatal_error => $fatal_error }; | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | 53 | return $self->_list_to_hash( $pkg, $exports ); | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | # If this module uses something other than Exporter or Sub::Exporter, we | ||||||||||||||||||||||||||||
| 245 | # probably returned an empty hash above. We could guess and say it's the | ||||||||||||||||||||||||||||
| 246 | # default exports + possibly something else. It's probably less confusing | ||||||||||||||||||||||||||||
| 247 | # to leave it up to the code which uses this object to decide how to handle | ||||||||||||||||||||||||||||
| 248 | # it. | ||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 132 | ▶ | sub _build_import_flags { | ||||||||||||||||||||||||||
|
Subroutine
_build_import_flags: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 252 | 132 | my $self = shift; | |||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 132 | my %modules = ( | |||||||||||||||||||||||||||
| 255 | Carp => ['verbose'], | ||||||||||||||||||||||||||||
| 256 | English => ['-no_match_vars'], | ||||||||||||||||||||||||||||
| 257 | ); | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | return | ||||||||||||||||||||||||||||
| 260 | exists $modules{ $self->_module_name } | ||||||||||||||||||||||||||||
| 261 | 132 | ▶ | ? $modules{ $self->_module_name } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | : []; | ||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 226 | ▶ | sub _build_is_exporter { | ||||||||||||||||||||||||||
|
Subroutine
_build_is_exporter: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 266 | 226 | my $self = shift; | |||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 226 | ▶ | return 1 if any { $_ eq 'Exporter' } @{ $self->class_isa }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 269 | 136 | ▶ | return $self->has_at_export || $self->has_at_export_ok ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->has_at_export or $self->has_at_export_ok
MC/DC100%2/2
$self->has_at_export or $self->has_at_export_ok
$self->has_at_export
$self->has_at_export_ok
Truth table100%3/3
A or B
A= $self->has_at_exportB= $self->has_at_export_ok
| |||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 144 | ▶ | sub _build_is_oo_class { | ||||||||||||||||||||||||||
|
Subroutine
_build_is_oo_class: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 273 | 144 | my $self = shift; | |||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 144 | ▶ | return 0 if $self->has_implicit_exports || $self->has_explicit_exports; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->has_implicit_exports or $self->has_explicit_exports
MC/DC100%2/2
$self->has_implicit_exports or $self->has_explicit_exports
$self->has_implicit_exports
$self->has_explicit_exports
Truth table100%3/3
A or B
A= $self->has_implicit_exportsB= $self->has_explicit_exports
| |||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 10 | my $methods | |||||||||||||||||||||||||||
| 278 | = Class::Inspector->methods( $self->_module_name, 'full', 'public' ); | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 263 | ▶ | return any { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 281 | 263 | ▶ | $_ eq 'Moose::Object::BUILDALL' || $_ eq 'Moo::Object::BUILDALL' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 282 | 10 | } @{$methods}; | |||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 96 | ▶ | sub _build_isa_test_builder { | ||||||||||||||||||||||||||
|
Subroutine
_build_isa_test_builder: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 286 | 93 | my $self = shift; | |||||||||||||||||||||||||||
| 287 | 93 | ▶ | if ( any { $_ eq 'Test::Builder::Module' } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 93 | @{ $self->_implicit->{class_isa} } ) { | |||||||||||||||||||||||||||
| 289 | 9 | return 1; | |||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 85 | ▶ | return 0 if $self->_module_name !~ m{\ATest}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 3 | my $err = App::perlimports::Sandbox::eval_pkg( | |||||||||||||||||||||||||||
| 295 | $self->_module_name, | ||||||||||||||||||||||||||||
| 296 | sprintf( 'use %s qw( some_function );', $self->_module_name ) | ||||||||||||||||||||||||||||
| 297 | ); | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | # Catch cases like Test::HTML::Lint, where, which doesn't subclass | ||||||||||||||||||||||||||||
| 300 | # Test::Builder, but essentially calls Tester::Builder->new->plan(@_); in | ||||||||||||||||||||||||||||
| 301 | # its import(). The error will be something like "plan() doesn't understand | ||||||||||||||||||||||||||||
| 302 | # some_function at" | ||||||||||||||||||||||||||||
| 303 | 3 | ▶ | if ( $err =~ m{plan} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 304 | 1 | return 1; | |||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | 3 | return 0; | |||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 431 | ▶ | sub _list_to_hash { | ||||||||||||||||||||||||||
|
Subroutine
_list_to_hash: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||
| 310 | 428 | my $self = shift; | |||||||||||||||||||||||||||
| 311 | 428 | my $pkg = shift; | |||||||||||||||||||||||||||
| 312 | 428 | my $list = shift; | |||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 428 | my %hash; | |||||||||||||||||||||||||||
| 315 | 428 | for my $item ( @{$list} ) { | |||||||||||||||||||||||||||
| 316 | 15443 | my $value = $item; | |||||||||||||||||||||||||||
| 317 | 15443 | $value =~ s{^&}{}; | |||||||||||||||||||||||||||
| 318 | 15443 | $hash{$item} = $value; | |||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | # Specifically for File::chdir, which exports a typeglob, but doesn't | ||||||||||||||||||||||||||||
| 322 | # implement every possibility. | ||||||||||||||||||||||||||||
| 323 | 428 | for my $key ( keys %hash ) { | |||||||||||||||||||||||||||
| 324 | 15392 | ▶ | if ( substr( $key, 0, 1 ) eq '*' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 325 | 223 | my $thing = substr( $key, 1 ); | |||||||||||||||||||||||||||
| 326 | 223 | for my $sigil ( '&', '$', '@', '%' ) { | |||||||||||||||||||||||||||
| 327 | 889 | my $symbol_name = $sigil . $pkg . '::' . $thing; | |||||||||||||||||||||||||||
| 328 | 889 | ▶ | if ( Symbol::Get::get($symbol_name) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 329 | 245 | $hash{ $sigil . $thing } = $key; | |||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | # Treat Moose type libraries a bit differently. Importing ArrayRef, for | ||||||||||||||||||||||||||||
| 336 | # instance, also imports is_ArrayRef and to_ArrayRef (if a coercion) | ||||||||||||||||||||||||||||
| 337 | # exists. So, let's deal with that here. | ||||||||||||||||||||||||||||
| 338 | 428 | ▶ | if ( $self->is_moose_type_class ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 1 | for my $key ( keys %hash ) { | |||||||||||||||||||||||||||
| 340 | 1 | ▶ | if ( $key =~ m{^(is_|to_)} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 341 | 1 | $hash{$key} = substr( $key, 3 ); | |||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | 428 | return \%hash; | |||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | 227 | ▶ | sub _build_implicit { | ||||||||||||||||||||||||||
|
Subroutine
_build_implicit: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 350 | 224 | my $self = shift; | |||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | 224 | my $module_name = $self->_module_name; | |||||||||||||||||||||||||||
| 353 | 224 | my $pkg = $self->_pkg_for_implicit; | |||||||||||||||||||||||||||
| 354 | 224 | my $use_statement = "use $module_name;"; | |||||||||||||||||||||||||||
| 355 | 224 | my ( $maybe_exports, $fatal_error ) | |||||||||||||||||||||||||||
| 356 | = $self->_exports_for_include( $pkg, $use_statement ); | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 124 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 359 | my $aggregated = { | ||||||||||||||||||||||||||||
| 360 | 224 | class_isa => [ @{ $self->_module_name . '::ISA' } ], | |||||||||||||||||||||||||||
| 361 | 224 | export => [ @{ $self->_module_name . '::EXPORT' } ], | |||||||||||||||||||||||||||
| 362 | 224 | export_fail => [ @{ $self->_module_name . '::EXPORT_FAIL' } ], | |||||||||||||||||||||||||||
| 363 | 224 | export_ok => [ @{ $self->_module_name . '::EXPORT_OK' } ], | |||||||||||||||||||||||||||
| 364 | 224 | export_tags => [ @{ $self->_module_name . '::EXPORT_TAGS' } ], | |||||||||||||||||||||||||||
| 365 | fatal_error => $fatal_error, | ||||||||||||||||||||||||||||
| 366 | _maybe_exports => $maybe_exports, | ||||||||||||||||||||||||||||
| 367 | }; | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | 224 | return $aggregated; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 283 | ▶ | sub _exports_for_include { | ||||||||||||||||||||||||||
|
Subroutine
_exports_for_include: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 373 | 280 | my $self = shift; | |||||||||||||||||||||||||||
| 374 | 280 | my $pkg = shift; | |||||||||||||||||||||||||||
| 375 | 280 | my $use_statement = shift; | |||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | 280 | my $logger = $self->logger; | |||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | # If you're importing Moose into a namespace and following that with an | ||||||||||||||||||||||||||||
| 380 | # import of namespace::autoclean, you may find that symbols like "after" | ||||||||||||||||||||||||||||
| 381 | # and "around" are no longer found. | ||||||||||||||||||||||||||||
| 382 | # | ||||||||||||||||||||||||||||
| 383 | # We log available symbols inside the BEGIN block in order to defeat | ||||||||||||||||||||||||||||
| 384 | # namespace::autoclean, which removes symbols from the stash after | ||||||||||||||||||||||||||||
| 385 | # compilation but before runtime. Thanks to Florian Ragwitz for the tip and | ||||||||||||||||||||||||||||
| 386 | # the preceding explanation. | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | 280 | my $to_eval = <<"EOF"; | |||||||||||||||||||||||||||
| 389 | package $pkg; | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | use Symbol::Get; | ||||||||||||||||||||||||||||
| 392 | $use_statement | ||||||||||||||||||||||||||||
| 393 | our \@__EXPORTABLES; | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | BEGIN { | ||||||||||||||||||||||||||||
| 396 | \@__EXPORTABLES = Symbol::Get::get_names(); | ||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | 1; | ||||||||||||||||||||||||||||
| 399 | EOF | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | 280 | $self->logger->debug($to_eval); | |||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | 47 | ▶ | my $logger_cb = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 404 | 47 | my $msg = shift; | |||||||||||||||||||||||||||
| 405 | 47 | my $level = 'info'; | |||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | # Mojo classes tend to throw "Can't locate :all.pm in @INC". This is | ||||||||||||||||||||||||||||
| 408 | # expected and shouldn't be raised to the warning level. | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 47 | ▶ | if ( $msg =~ qr{Can't locate} && $msg !~ m{\:all\.pm in \@INC} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$msg =~ qr/Can't locate/ and not $msg =~ /\:all\.pm in \@INC/
MC/DC50%1/2
$msg =~ qr/Can't locate/ and not $msg =~ /\:all\.pm in \@INC/
$msg =~ qr/Can't locate/
not $msg =~ /\:all\.pm in \@INC/
Truth table66%2/3
A and not(B)
A= $msg =~ qr/Can't locate/B= not $msg =~ /\:all\.pm in \@INC/
| |||||||||||||||||||||||||||||
| 411 | 15 | $level = 'warning'; | |||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | $logger->log( | ||||||||||||||||||||||||||||
| 415 | 47 | level => $level, | |||||||||||||||||||||||||||
| 416 | message => sprintf( | ||||||||||||||||||||||||||||
| 417 | "Problem trying to eval %s\n%s", | ||||||||||||||||||||||||||||
| 418 | $pkg, | ||||||||||||||||||||||||||||
| 419 | $msg, | ||||||||||||||||||||||||||||
| 420 | ), | ||||||||||||||||||||||||||||
| 421 | ); | ||||||||||||||||||||||||||||
| 422 | 280 | }; | |||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 280 | local $SIG{__WARN__} = $logger_cb; | |||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | 280 | local $@ = undef; | |||||||||||||||||||||||||||
| 427 | ## no critic (BuiltinFunctions::ProhibitStringyEval) | ||||||||||||||||||||||||||||
| 428 | ## no critic (ErrorHandling::RequireCheckingReturnValueOfEval) | ||||||||||||||||||||||||||||
| 429 | 280 | ▶ | eval $to_eval; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | 280 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 432 | 18 | $logger_cb->($@); | |||||||||||||||||||||||||||
| 433 | 18 | return undef, $@; | |||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||
| 435 | else { | ||||||||||||||||||||||||||||
| 436 | 263 | $self->_increment_success_counter; | |||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | ## no critic (TestingAndDebugging::ProhibitNoStrict) | ||||||||||||||||||||||||||||
| 440 | 122 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 441 | my @export | ||||||||||||||||||||||||||||
| 442 | 7777 | ▶ | = grep { $_ !~ m{(?:BEGIN|ISA|__EXPORTABLES)} && $_ !~ m{^__ANON__} } | ||||||||||||||||||||||||||
|
Condition100%3/3
$_ =~ /(?:BEGIN|ISA|__EXPORTABLES)/ || $_ =~ /^__ANON__/
MC/DC100%2/2
$_ =~ /(?:BEGIN|ISA|__EXPORTABLES)/ || $_ =~ /^__ANON__/
$_ =~ /(?:BEGIN|ISA|__EXPORTABLES)/
$_ =~ /^__ANON__/
Truth table100%3/3
A || B
A= $_ =~ /(?:BEGIN|ISA|__EXPORTABLES)/B= $_ =~ /^__ANON__/
| |||||||||||||||||||||||||||||
| 443 | 263 | @{ $pkg . '::__EXPORTABLES' }; | |||||||||||||||||||||||||||
| 444 | 122 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 445 | ## use critic | ||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | 263 | return \@export, undef; | |||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | 280 | ▶ | sub _random_pkg_name { | ||||||||||||||||||||||||||
|
Subroutine
_random_pkg_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 451 | 280 | my $self = shift; | |||||||||||||||||||||||||||
| 452 | 280 | return App::perlimports::Sandbox::pkg_for( $self->_module_name ); | |||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | 136 | ▶ | sub _build_is_moose_class { | ||||||||||||||||||||||||||
|
Subroutine
_build_is_moose_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 456 | 136 | my $self = shift; | |||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | return | ||||||||||||||||||||||||||||
| 459 | 4 | ▶ | any { $_ eq 'Moose::Object' || $_ eq 'Test::Class::Moose' } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 460 | 136 | @{ $self->pkg_isa }; | |||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | 130 | ▶ | sub _build_uses_moose { | ||||||||||||||||||||||||||
|
Subroutine
_build_uses_moose: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 464 | 130 | my $self = shift; | |||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | # Make sure the module itself has been loaded before looking for a | ||||||||||||||||||||||||||||
| 467 | # metaclass. _implicit is cached and tolerates load failures. | ||||||||||||||||||||||||||||
| 468 | 130 | $self->_implicit; | |||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | 130 | ▶ | if ( $self->_maybe_require_module('Moose::Util') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 471 | 130 | ▶ | return Moose::Util::find_meta( $self->_module_name ) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | 1 | return 0; | |||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | 129 | ▶ | sub _build_is_moo_class { | ||||||||||||||||||||||||||
|
Subroutine
_build_is_moo_class: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||
| 477 | 129 | my $self = shift; | |||||||||||||||||||||||||||
| 478 | 129 | ▶ | if ( $self->_maybe_require_module('Class::Inspector') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 479 | return 1 | ||||||||||||||||||||||||||||
| 480 | 129 | ▶ | if any { $_ eq 'Moo::is_class' } @{ Class::Inspector->methods( | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
Condition50%1/2
'Class::Inspector'->methods($self->_module_name, 'full', 'public') || []
MC/DC0%0/1
'Class::Inspector'->methods($self->_module_name, 'full', 'public') || []
'Class::Inspector'->methods($self->_module_name, 'full', 'public')
Truth table50%1/2
A
A= 'Class::Inspector'->methods($self->_module_name, 'full', 'public')
| |||||||||||||||||||||||||||||
| 481 | $self->_module_name, 'full', 'public' | ||||||||||||||||||||||||||||
| 482 | ) | ||||||||||||||||||||||||||||
| 483 | || [] | ||||||||||||||||||||||||||||
| 484 | }; | ||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||
| 486 | 129 | return 0; | |||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | 221 | ▶ | sub _build_is_moose_type_class { | ||||||||||||||||||||||||||
|
Subroutine
_build_is_moose_type_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 490 | 221 | my $self = shift; | |||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | return | ||||||||||||||||||||||||||||
| 493 | 141 | ▶ | any { $_ eq 'MooseX::Types::Base' || $_ eq 'MooseX::Types::Combine' } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 494 | 221 | @{ $self->class_isa }; | |||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | 8 | ▶ | sub explicit_export_names_match_values { | ||||||||||||||||||||||||||
|
Subroutine
explicit_export_names_match_values: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 498 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 499 | return | ||||||||||||||||||||||||||||
| 500 | 8 | join( q{}, sort $self->explicit_export_names ) eq | |||||||||||||||||||||||||||
| 501 | join( q{}, sort $self->explicit_export_values ); | ||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | 7 | ▶ | sub implicit_export_names_match_values { | ||||||||||||||||||||||||||
|
Subroutine
implicit_export_names_match_values: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 505 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 506 | return | ||||||||||||||||||||||||||||
| 507 | 7 | join( q{}, sort $self->implicit_export_names ) eq | |||||||||||||||||||||||||||
| 508 | join( q{}, sort $self->implicit_export_values ); | ||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | 258 | ▶ | sub _maybe_require_module { | ||||||||||||||||||||||||||
|
Subroutine
_maybe_require_module: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 512 | 258 | my $self = shift; | |||||||||||||||||||||||||||
| 513 | 258 | my $module_to_require = shift; | |||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | 258 | $self->logger->info("going to require $module_to_require"); | |||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | 258 | my $success; | |||||||||||||||||||||||||||
| 518 | 258 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 519 | 258 | require_module($module_to_require); | |||||||||||||||||||||||||||
| 520 | 258 | $success = 1; | |||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||
| 522 | 1 | ▶ | catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 523 | 1 | $self->logger->info("$module_to_require error. $_"); | |||||||||||||||||||||||||||
| 524 | 258 | }; | |||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | 258 | return $success; | |||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | 118 | 1; | |||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | # ABSTRACT: Inspect code for exportable symbols | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | __END__ | ||||||||||||||||||||||||||||