« Policy/ValuesAndExpressions/RequireNumericVersion.pm
↑ Summary
Policy/Documentation/ProhibitDuplicateHeadings.pm »
| 1 | # Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2021 Kevin Ryde | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # Perl-Critic-Pulp is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # it under the terms of the GNU General Public License as published by the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # Free Software Foundation; either version 3, or (at your option) any later | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # Perl-Critic-Pulp is distributed in the hope that it will be useful, but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # You should have received a copy of the GNU General Public License along | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # with Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | package Perl::Critic::Policy::CodeLayout::RequireTrailingCommaAtNewline; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 40 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 40 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 40 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 40 | ▶ | use List::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 40 | ▶ | use base 'Perl::Critic::Policy'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 40 | ▶ | use Perl::Critic::Utils qw(is_function_call is_method_call); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 40 | ▶ | use Perl::Critic::Pulp::Utils 'elem_is_comma_operator'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # uncomment this to run the ### lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | #use Smart::Comments; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 40 | our $VERSION = 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 40 | ▶ | use constant supported_parameters => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ({ name => 'except_function_calls', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | description => 'Don\'t demand a trailing comma in function call argument lists.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | behavior => 'boolean', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | default_string => '0', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 40 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 40 | ▶ | use constant default_severity => $Perl::Critic::Utils::SEVERITY_LOW; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 40 | ▶ | use constant default_themes => qw(pulp cosmetic); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 40 | ▶ | use constant applies_to => qw(PPI::Structure::List | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 40 | PPI::Structure::Constructor); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 44 | ▶ | sub violates { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
violates: called CC=14 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 44 | my ($self, $elem, $document) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ### elem: ref($elem) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ### content: "$elem" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 44 | ▶ | if ($self->{'_except_function_calls'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | my $prev; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 4 | ▶ | if (($prev = $elem->sprevious_sibling) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$prev = $elem->sprevious_sibling and $prev->isa("PPI::Token::Word") and is_function_call($prev) || is_method_call($prev)
$prev = $elem->sprevious_sibling and $prev->isa("PPI::Token::Word")
is_function_call($prev) or is_method_call($prev)
MC/DC25%1/4
$prev = $elem->sprevious_sibling and $prev->isa("PPI::Token::Word") and is_function_call($prev) || is_method_call($prev)
$prev = $elem->sprevious_sibling
$prev->isa("PPI::Token::Word")
is_function_call($prev)
is_method_call($prev)
Truth table60%3/5
A and B and C or D
A= $prev = $elem->sprevious_siblingB= $prev->isa("PPI::Token::Word")C= is_function_call($prev)D= is_method_call($prev)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | && $prev->isa('PPI::Token::Word') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | && (is_function_call($prev) || is_method_call($prev))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ### is_function_call: !! is_function_call($prev) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ### is_method_call: !! is_method_call($prev) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 41 | my @children = $elem->children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 41 | ▶ | @children = map {$_->isa('PPI::Statement') ? $_->children : $_} @children; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ### children: "@children" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 41 | ▶ | if (_is_list_single_expression($elem)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ### an expression not a list as such ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 9 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 32 | my $newline = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 32 | my $after; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 32 | foreach my $child (reverse @children) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 84 | ▶ | if ($child->isa('PPI::Token::Whitespace') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$child->isa("PPI::Token::Whitespace") or $child->isa("PPI::Token::Comment")
MC/DC100%2/2
$child->isa("PPI::Token::Whitespace") or $child->isa("PPI::Token::Comment")
$child->isa("PPI::Token::Whitespace")
$child->isa("PPI::Token::Comment")
Truth table100%3/3
A or B
A= $child->isa("PPI::Token::Whitespace")B= $child->isa("PPI::Token::Comment")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | || $child->isa('PPI::Token::Comment')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ### HWS ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 56 | ▶ | $newline ||= ($child->content =~ /\n/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$newline ||= $child->content =~ /\n/
MC/DC100%2/2
$newline ||= $child->content =~ /\n/
$newline
$child->content =~ /\n/
Truth table100%3/3
A ||= B
A= $newlineB= $child->content =~ /\n/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ### $newline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 56 | $after = $child; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 28 | ▶ | if ($newline && ! elem_is_comma_operator($child)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$newline and not elem_is_comma_operator($child)
MC/DC100%2/2
$newline and not elem_is_comma_operator($child)
$newline
not elem_is_comma_operator($child)
Truth table100%3/3
A and not(B)
A= $newlineB= not elem_is_comma_operator($child)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 18 | return $self->violation | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ('Put a trailing comma at last of a list ending with a newline', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | $after); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 10 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 14 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # $elem is any PPI::Element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # Return true if it's a PPI::Structure::List which contains just a single | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # expression. Any "," or "=>" in the list is multiple expressions, but also | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # the various rules of the policy are applied as to what is list context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # (array assignments, function calls). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 41 | ▶ | sub _is_list_single_expression { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_list_single_expression: called CC=16 SCAR=28.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 41 | my ($elem) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 41 | ▶ | $elem->isa('PPI::Structure::List') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 35 | my @children = $elem->schildren; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # eg. PPI::Structure::List | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # PPI::Statement::Expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # PPI::Token::Number '1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # PPI::Token::Operator ',' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # so descend through PPI::Statement::Expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 35 | ▶ | @children = map { $_->isa('PPI::Statement::Expression') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | ? ($_->schildren) : ($_)} @children; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 35 | ▶ | if (List::Util::first {elem_is_comma_operator($_)} @children) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | ### contains comma operator, so not an expression ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 13 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 22 | ▶ | if (my $prev = $elem->sprevious_sibling) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 22 | ▶ | if ($prev->isa('PPI::Token::Word')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 9 | ▶ | if ($prev eq 'return') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | ### return statement without commas, is reckoned a single expression ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 7 | ▶ | if (is_function_call($prev) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
is_function_call($prev) or is_method_call($prev)
MC/DC0%0/2
is_function_call($prev) or is_method_call($prev)
is_function_call($prev)
is_method_call($prev)
Truth table66%2/3
A or B
A= is_function_call($prev)B= is_method_call($prev)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | || is_method_call($prev)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ### function or method call ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 7 | ▶ | if ($children[-1] && $children[-1]->isa('PPI::Token::HereDoc')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$children[-1] and $children[-1]->isa("PPI::Token::HereDoc")
MC/DC100%2/2
$children[-1] and $children[-1]->isa("PPI::Token::HereDoc")
$children[-1]
$children[-1]->isa("PPI::Token::HereDoc")
Truth table100%3/3
A and B
A= $children[-1]B= $children[-1]->isa("PPI::Token::HereDoc")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 5 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ▶ | } elsif ($prev->isa('PPI::Token::Operator') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$prev->isa("PPI::Token::Operator") and $prev eq "=" and _is_preceded_by_array($prev)
$prev->isa("PPI::Token::Operator") and $prev eq "="
MC/DC33%1/3
$prev->isa("PPI::Token::Operator") and $prev eq "=" and _is_preceded_by_array($prev)
$prev->isa("PPI::Token::Operator")
$prev eq "="
_is_preceded_by_array($prev)
Truth table50%2/4
A and B and C
A= $prev->isa("PPI::Token::Operator")B= $prev eq "="C= _is_preceded_by_array($prev)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | && $prev eq '=' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | && _is_preceded_by_array($prev)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ### array assignment, not a single expression ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 10 | ▶ | if ($children[-1] && $children[-1]->isa('PPI::Token::HereDoc')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$children[-1] and $children[-1]->isa("PPI::Token::HereDoc")
MC/DC100%2/2
$children[-1] and $children[-1]->isa("PPI::Token::HereDoc")
$children[-1]
$children[-1]->isa("PPI::Token::HereDoc")
Truth table100%3/3
A and B
A= $children[-1]B= $children[-1]->isa("PPI::Token::HereDoc")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 8 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ### no commas, not a call, so is an expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 13 | ▶ | sub _is_preceded_by_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_preceded_by_array: called CC=9 SCAR=22.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 13 | my ($elem) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ### _is_preceded_by_array: "$elem" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 13 | ▶ | my $prev = $elem->sprevious_sibling || return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$elem->sprevious_sibling || (return 0)
MC/DC0%0/1
$elem->sprevious_sibling || (return 0)
$elem->sprevious_sibling
Truth table50%1/2
A
A= $elem->sprevious_sibling
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 13 | ▶ | while ($prev->isa('PPI::Structure::Subscript') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$prev->isa("PPI::Structure::Subscript") or $prev->isa("PPI::Structure::Block")
MC/DC100%2/2
$prev->isa("PPI::Structure::Subscript") or $prev->isa("PPI::Structure::Block")
$prev->isa("PPI::Structure::Subscript")
$prev->isa("PPI::Structure::Block")
Truth table100%3/3
A or B
A= $prev->isa("PPI::Structure::Subscript")B= $prev->isa("PPI::Structure::Block")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | || $prev->isa('PPI::Structure::Block')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ### skip: ref $prev | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 5 | ▶ | $prev = $prev->sprevious_sibling || return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$prev->sprevious_sibling || (return 0)
MC/DC0%0/1
$prev->sprevious_sibling || (return 0)
$prev->sprevious_sibling
Truth table50%1/2
A
A= $prev->sprevious_sibling
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ### prev: ref $prev | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 13 | ▶ | if ($prev->isa('PPI::Token::Symbol')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 12 | my $cast; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 12 | ▶ | if (($cast = $prev->sprevious_sibling) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$cast = $prev->sprevious_sibling and $cast->isa("PPI::Token::Cast")
MC/DC50%1/2
$cast = $prev->sprevious_sibling and $cast->isa("PPI::Token::Cast")
$cast = $prev->sprevious_sibling
$cast->isa("PPI::Token::Cast")
Truth table66%2/3
A and B
A= $cast = $prev->sprevious_siblingB= $cast->isa("PPI::Token::Cast")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | && $cast->isa('PPI::Token::Cast')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | return ($cast->content eq '@'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ### raw_type: $prev->raw_type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 11 | return ($prev->raw_type eq '@'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | ▶ | if ($prev->isa('PPI::Token::Cast')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | return ($prev->content eq '@'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 40 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||