« Policy/ValuesAndExpressions/ProhibitNullStatements.pm
↑ Summary
Policy/Modules/ProhibitPOSIXimport.pm »
| 1 | # Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2021 Kevin Ryde | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # This file is part of Perl-Critic-Pulp. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # Perl-Critic-Pulp is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # it under the terms of the GNU General Public License as published by the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # Free Software Foundation; either version 3, or (at your option) any later | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Perl-Critic-Pulp is distributed in the hope that it will be useful, but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # You should have received a copy of the GNU General Public License along | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # with Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | package Perl::Critic::Pulp::Utils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 41 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 41 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 41 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 41 | ▶ | use version (); # but don't import qv() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 41 | our $VERSION = 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 41 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 41 | our @EXPORT_OK = qw(parameter_parse_version | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | version_if_valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | include_module_version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | elem_package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | elem_in_BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | elem_is_comma_operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | %COMMA); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 41 | our %COMMA = (',' => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | '=>' => 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 92 | ▶ | sub parameter_parse_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parameter_parse_version: called CC=4 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 92 | my ($self, $parameter, $str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 92 | my $version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 92 | ▶ | if (defined $str && $str ne '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $str and $str ne ""
MC/DC0%0/2
defined $str and $str ne ""
defined $str
$str ne ""
Truth table33%1/3
A and B
A= defined $strB= $str ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $version = version_if_valid ($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if (! defined $version) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $self->throw_parameter_value_exception | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ($parameter->get_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | $str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | undef, # source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 'invalid version number string'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 92 | $self->__set_parameter_value ($parameter, $version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # return a version.pm object, or undef if $str is invalid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 20 | ▶ | sub version_if_valid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version_if_valid: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 20 | my ($str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # this is a nasty hack to notice "not a number" warnings, and for version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # 0.81 possibly throwing errors too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 20 | my $good = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 20 | my $version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | { local $SIG{'__WARN__'} = sub { $good = 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 20 | eval { $version = version->new($str) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 20 | ▶ | return ($good ? $version : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # This regexp is what Perl's toke.c S_force_version() demands, as of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # versions 5.004 through 5.8.9. A version number in a "use" must start with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # a digit and then have only digits, dots and underscores. In particular | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # other normal numeric forms like hex or exponential are not taken to be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # version numbers, and even omitting the 0 from a decimal like ".25" is not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # a version number. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 41 | our $use_module_version_number_re = qr/^v?[0-9][0-9._]*$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 416 | ▶ | sub include_module_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
include_module_version: called CC=10 SCAR=23.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 416 | my ($inc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # only a module style "use Foo", not a perl version num like "use 5.010" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 416 | ▶ | defined ($inc->module) || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 416 | ▶ | my $ver = $inc->schild(2) || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$inc->schild(2) || (return undef)
MC/DC100%1/1
$inc->schild(2) || (return undef)
$inc->schild(2)
Truth table100%2/2
A
A= $inc->schild(2)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # ENHANCE-ME: when PPI recognises v-strings may have to extend this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 407 | ▶ | $ver->isa('PPI::Token::Number') || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 162 | ▶ | $ver->content =~ $use_module_version_number_re or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # must be followed by whitespace, or comment, or end of statement, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # use Foo 10 -3; <- version 10, arg -3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # use Foo 10-3; <- arg 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # use Foo 10# <- version 10, arg -3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # -3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 154 | ▶ | if (my $after = $ver->next_sibling) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 139 | ▶ | unless ($after->isa('PPI::Token::Whitespace') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$after->isa("PPI::Token::Whitespace") or $after->isa("PPI::Token::Comment") or $after->isa("PPI::Token::Structure") and $after eq ";"
$after->isa("PPI::Token::Whitespace") or $after->isa("PPI::Token::Comment")
$after->isa("PPI::Token::Structure") and $after eq ";"
MC/DC50%2/4
$after->isa("PPI::Token::Whitespace") or $after->isa("PPI::Token::Comment") or $after->isa("PPI::Token::Structure") and $after eq ";"
$after->isa("PPI::Token::Whitespace")
$after->isa("PPI::Token::Comment")
$after->isa("PPI::Token::Structure")
$after eq ";"
Truth table60%3/5
A or B or C and D
A= $after->isa("PPI::Token::Whitespace")B= $after->isa("PPI::Token::Comment")C= $after->isa("PPI::Token::Structure")D= $after eq ";"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | || $after->isa('PPI::Token::Comment') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | || ($after->isa('PPI::Token::Structure') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | && $after eq ';')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 26 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 128 | return $ver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # $inc is a PPI::Statement::Include. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # Return the element which is the start of the first argument to its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # import() or unimport(), for "use" or "no" respectively. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # A "require" is treated the same as "use" and "no", but arguments to it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # like "require Foo::Bar '-init';" is in fact a syntax error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 288 | ▶ | sub include_module_first_arg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
include_module_first_arg: called CC=7 SCAR=19.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 288 | my ($inc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 288 | ▶ | defined ($inc->module) || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 288 | my $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 288 | ▶ | if (my $ver = include_module_version ($inc)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 72 | $arg = $ver->snext_sibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # eg. "use Foo 'xxx'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 216 | $arg = $inc->schild(2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # don't return terminating ";" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 288 | ▶ | if ($arg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$arg and $arg->isa("PPI::Token::Structure") and $arg->content eq ";" and not $arg->snext_sibling
$arg and $arg->isa("PPI::Token::Structure") and $arg->content eq ";"
$arg and $arg->isa("PPI::Token::Structure")
MC/DC50%2/4
$arg and $arg->isa("PPI::Token::Structure") and $arg->content eq ";" and not $arg->snext_sibling
$arg
$arg->isa("PPI::Token::Structure")
$arg->content eq ";"
not $arg->snext_sibling
Truth table60%3/5
A and B and C and not(D)
A= $argB= $arg->isa("PPI::Token::Structure")C= $arg->content eq ";"D= not $arg->snext_sibling
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | && $arg->isa('PPI::Token::Structure') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | && $arg->content eq ';' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | && ! $arg->snext_sibling) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 41 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 247 | return $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # Hack to set Perl::Critic::Violation location to $linenum in $doc_str. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # Have thought about validating _location and _source fields before mangling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # them, but hopefully there'll be a documented interface to use before long. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 193 | ▶ | sub _violation_override_linenum { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_violation_override_linenum: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 193 | my ($violation, $doc_str, $linenum) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # if ($violation->can('set_line_number_offset')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # $violation->set_line_number_offset ($linenum - 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 193 | bless $violation, 'Perl::Critic::Pulp::PodMinimumVersionViolation'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 193 | $violation->{_Pulp_linenum_offset} = $linenum - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 193 | $violation->{'_source'} = _str_line_n ($doc_str, $linenum); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 193 | return $violation; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # starting contents of line number $n within $str | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # $n==0 is the first line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 199 | ▶ | sub _str_line_n { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_str_line_n: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 199 | my ($str, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 199 | $n--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 199 | ▶ | return ($str =~ /^(.*\n){$n}(.*)/ ? $2 : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 96 | ▶ | sub elem_package { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
elem_package: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 96 | my ($elem) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 96 | for (;;) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 273 | ▶ | $elem = $elem->sprevious_sibling || $elem->parent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
$elem->sprevious_sibling || $elem->parent || (return undef)
$elem->sprevious_sibling or $elem->parent
MC/DC100%2/2
$elem->sprevious_sibling || $elem->parent || (return undef)
$elem->sprevious_sibling
$elem->parent
Truth table100%3/3
A or B
A= $elem->sprevious_siblingB= $elem->parent
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 265 | ▶ | if ($elem->isa ('PPI::Statement::Package')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 88 | return $elem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 12 | ▶ | sub elem_in_BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
elem_in_BEGIN: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 12 | my ($elem) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 12 | ▶ | while ($elem = $elem->parent) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 29 | ▶ | if ($elem->isa('PPI::Statement::Scheduled')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 9 | return ($elem->type eq 'BEGIN'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 487 | ▶ | sub elem_is_comma_operator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
elem_is_comma_operator: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 487 | my ($elem) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | return ($elem->isa('PPI::Token::Operator') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 487 | ▶ | && $Perl::Critic::Pulp::Utils::COMMA{$elem}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$elem->isa('PPI::Token::Operator') && $Perl::Critic::Pulp::Utils::COMMA{$elem}
MC/DC100%2/2
$elem->isa('PPI::Token::Operator') && $Perl::Critic::Pulp::Utils::COMMA{$elem}
$elem->isa('PPI::Token::Operator')
$Perl::Critic::Pulp::Utils::COMMA{$elem}
Truth table100%3/3
A && B
A= $elem->isa('PPI::Token::Operator')B= $Perl::Critic::Pulp::Utils::COMMA{$elem}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 41 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||