| 1 | package Perl::Critic::Policy::ValuesAndExpressions::ProhibitDescendingRanges 0.001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Do not write a range that counts down: Perl gives an empty list for it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use re '/aa'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Scalar::Util qw{looks_like_number}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use Perl::Critic::Utils qw{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | :characters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | :severities | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | is_method_call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | is_perl_builtin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | is_perl_builtin_with_list_context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | is_perl_builtin_with_zero_and_or_one_arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | precedence_of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use parent qw{Perl::Critic::Policy}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | Readonly::Scalar my $EXPL => q{Perl's .. counts only up, so a range whose left end is greater than its right end gives an empty list. To count down, write reverse( LOW .. HIGH )}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # Operators that bind tighter than .. have a lower number here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | Readonly::Scalar my $RANGE => precedence_of(q{..}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | Readonly::Hash my %RANGE_OPERATOR => map { $_ => 1 } qw{.. ...}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # Statement modifiers, and the words of the compound statements that take one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | Readonly::Hash my %SCALAR_MODIFIER => map { $_ => 1 } qw{if unless while until}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | Readonly::Hash my %LIST_MODIFIER => map { $_ => 1 } qw{for foreach}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # The operators that a list goes on past, to the left: a comma list and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # branches of a ternary have the context of the whole expression. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | Readonly::Hash my %LIST_SEPARATOR => map { $_ => 1 } ( $COMMA, $FATCOMMA, q{?}, $COLON ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # Words that an expression follows, and that are not a term of it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | Readonly::Hash my %NOT_A_TERM => map { $_ => 1 } qw{if unless while until for foreach my our local state return}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # The blocks whose value is a list, and the blocks after which a list follows. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | Readonly::Hash my %LIST_BLOCK => map { $_ => 1 } qw{map}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | Readonly::Hash my %BLOCK_THEN_LIST => map { $_ => 1 } qw{map grep sort}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 3 | ▶ | sub supported_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | name => 'largest_end', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | description => 'The largest right end to report for a range whose left end is an expression', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | default_string => '1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | behavior => 'integer', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 79 | ▶ | sub default_severity { return $SEVERITY_HIGH } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub default_themes { return qw{bugs} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_themes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 130 | ▶ | sub applies_to { return 'PPI::Token::Operator' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 309 | ▶ | my $is_operator = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 309 | my ( $e, $content ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 309 | ▶ | return $e && $e->isa('PPI::Token::Operator') && $e->content eq $content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$e && $e->isa('PPI::Token::Operator') && $e->content eq $content
$e and $e->isa("PPI::Token::Operator")
MC/DC100%3/3
$e && $e->isa('PPI::Token::Operator') && $e->content eq $content
$e
$e->isa("PPI::Token::Operator")
$e->content eq $content
Truth table100%4/4
A and B && C
A= $eB= $e->isa("PPI::Token::Operator")C= $e->content eq $content
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 83 | ▶ | my $binds_tighter = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 83 | my ($operator) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 83 | my $precedence = precedence_of($operator); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 83 | ▶ | return defined $precedence && $precedence < $RANGE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $precedence && $precedence < $RANGE
MC/DC50%1/2
defined $precedence && $precedence < $RANGE
defined $precedence
$precedence < $RANGE
Truth table66%2/3
A && B
A= defined $precedenceB= $precedence < $RANGE
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 6 | ▶ | my $follows_word = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 6 | my ( $e, $words ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 6 | my $word = $e->sprevious_sibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 6 | ▶ | return $word && $word->isa('PPI::Token::Word') && $words->{ $word->content } ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$word and $word->isa("PPI::Token::Word") and $$words{$word->content}
$word and $word->isa("PPI::Token::Word")
MC/DC66%2/3
$word and $word->isa("PPI::Token::Word") and $$words{$word->content}
$word
$word->isa("PPI::Token::Word")
$$words{$word->content}
Truth table75%3/4
A and B and C
A= $wordB= $word->isa("PPI::Token::Word")C= $$words{$word->content}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # The elements of the left operand of $elem, and the element before them. An | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # element binds to the operand if it is a term, or an operator that binds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # tighter than .., which is where Perl would end the operand. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 191 | ▶ | my $left_operand = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=24.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 191 | my ($elem) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 191 | my @operand; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 191 | my $before = $elem->sprevious_sibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 191 | ▶ | while ($before) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 240 | my $binds = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 240 | ▶ | if ( $before->isa('PPI::Token::Operator') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 73 | $binds = $binds_tighter->($before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | elsif ( $before->isa('PPI::Token::Structure') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $binds = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | elsif ( $before->isa('PPI::Token::Word') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 14 | my $after = $before->snext_sibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 14 | ▶ | $binds = !$NOT_A_TERM{ $before->content } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%9/12
!$NOT_A_TERM{$before->content} && (is_method_call($before) || is_perl_builtin_with_zero_and_or_one_arguments($before) || $after && $after->isa('PPI::Structure::List'))
is_method_call($before) or is_perl_builtin_with_zero_and_or_one_arguments($before) or $after and $after->isa("PPI::Structure::List")
is_method_call($before) or is_perl_builtin_with_zero_and_or_one_arguments($before)
$after and $after->isa("PPI::Structure::List")
MC/DC60%3/5
!$NOT_A_TERM{$before->content} && (is_method_call($before) || is_perl_builtin_with_zero_and_or_one_arguments($before) || $after && $after->isa('PPI::Structure::List'))
!$NOT_A_TERM{$before->content}
is_method_call($before)
is_perl_builtin_with_zero_and_or_one_arguments($before)
$after
$after->isa("PPI::Structure::List")
Truth table66%4/6
not(A) && B or C or D and E
A= !$NOT_A_TERM{$before->content}B= is_method_call($before)C= is_perl_builtin_with_zero_and_or_one_arguments($before)D= $afterE= $after->isa("PPI::Structure::List")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | && ( is_method_call($before) || is_perl_builtin_with_zero_and_or_one_arguments($before) || ( $after && $after->isa('PPI::Structure::List') ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | elsif ( $before->isa('PPI::Structure::Block') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # The block of map, grep or sort ends the operand: the list follows it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | $binds = !$follows_word->( $before, \%BLOCK_THEN_LIST ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 240 | ▶ | last unless $binds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 158 | unshift @operand, $before; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 158 | $before = $before->sprevious_sibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 191 | return ( \@operand, $before ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 180 | ▶ | my $right_operand = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 180 | my ($elem) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 180 | my @operand; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 180 | my $after = $elem->snext_sibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 180 | ▶ | while ($after) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 212 | my $binds = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 212 | ▶ | if ( $after->isa('PPI::Token::Operator') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 10 | $binds = $binds_tighter->($after); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | elsif ( $after->isa('PPI::Token::Structure') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 65 | $binds = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | elsif ( $after->isa('PPI::Token::Word') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | ▶ | $binds = !( $SCALAR_MODIFIER{ $after->content } || $LIST_MODIFIER{ $after->content } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$SCALAR_MODIFIER{$after->content} || $LIST_MODIFIER{$after->content}
MC/DC0%0/2
$SCALAR_MODIFIER{$after->content} || $LIST_MODIFIER{$after->content}
$SCALAR_MODIFIER{$after->content}
$LIST_MODIFIER{$after->content}
Truth table33%1/3
A || B
A= $SCALAR_MODIFIER{$after->content}B= $LIST_MODIFIER{$after->content}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 212 | ▶ | last unless $binds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 139 | push @operand, $after; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 139 | $after = $after->snext_sibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 180 | return ( \@operand, $after ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # The source of a run of sibling elements, with the whitespace between them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 172 | ▶ | my $source = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 172 | my (@elements) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 172 | my ( $first, $last ) = @elements[ 0, -1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 172 | my $text = q{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 172 | ▶ | for ( my $e = $first; $e; $e = $e->next_sibling ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 206 | $text .= $e->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 206 | ▶ | last if $e == $last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 172 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # The value of an operand that is one literal, as { value => ..., number => 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # for a number and { value => ... } for a string, or undef for anything else. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 264 | ▶ | my $literal = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=13 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 264 | my (@operand) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 264 | my $sign = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 264 | ▶ | if ( @operand == 2 && $is_operator->( $operand[0], q{-} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@operand == 2 and &$is_operator($operand[0], "-")
MC/DC100%2/2
@operand == 2 and &$is_operator($operand[0], "-")
@operand == 2
&$is_operator($operand[0], "-")
Truth table100%3/3
A and B
A= @operand == 2B= &$is_operator($operand[0], "-")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 3 | $sign = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 3 | shift @operand; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 264 | ▶ | return if @operand != 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 256 | my ($e) = @operand; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 256 | ▶ | if ( $e->isa('PPI::Token::Number') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # A version string is a literal, and not a number that the policy can compare. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 171 | ▶ | return {} if $e->isa('PPI::Token::Number::Version'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 170 | my $value = $e->literal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 170 | ▶ | return defined $value ? { value => $sign * $value, number => 1 } : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # -'a' is the string '-a', which is not a number the policy can compare. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 85 | ▶ | return if $sign < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 84 | ▶ | return { value => $e->literal } if $e->isa('PPI::Token::Quote::Single') || $e->isa('PPI::Token::Quote::Literal'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$e->isa("PPI::Token::Quote::Single") or $e->isa("PPI::Token::Quote::Literal")
MC/DC100%2/2
$e->isa("PPI::Token::Quote::Single") or $e->isa("PPI::Token::Quote::Literal")
$e->isa("PPI::Token::Quote::Single")
$e->isa("PPI::Token::Quote::Literal")
Truth table100%3/3
A or B
A= $e->isa("PPI::Token::Quote::Single")B= $e->isa("PPI::Token::Quote::Literal")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 27 | ▶ | if ( $e->isa('PPI::Token::Quote::Double') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 4 | my $string = $e->string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 4 | ▶ | return if $e->interpolations || index( $string, q{\\} ) >= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$e->interpolations or index($string, "\\") != -1
MC/DC50%1/2
$e->interpolations or index($string, "\\") != -1
$e->interpolations
index($string, "\\") != -1
Truth table66%2/3
A or B
A= $e->interpolationsB= index($string, "\\") != -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | return { value => $string }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 23 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # Whether a word gives list context to the expression after it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 17 | ▶ | my $gives_a_list = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 17 | my ($word) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 17 | my $name = $word->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 17 | ▶ | return 0 if $SCALAR_MODIFIER{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 11 | ▶ | return 1 if $LIST_MODIFIER{$name} || $name eq 'return' || is_method_call($word); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$LIST_MODIFIER{$name} or $name eq "return" or is_method_call($word)
$LIST_MODIFIER{$name} or $name eq "return"
MC/DC100%3/3
$LIST_MODIFIER{$name} or $name eq "return" or is_method_call($word)
$LIST_MODIFIER{$name}
$name eq "return"
is_method_call($word)
Truth table100%4/4
A or B or C
A= $LIST_MODIFIER{$name}B= $name eq "return"C= is_method_call($word)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 6 | ▶ | return 1 if is_perl_builtin_with_list_context($word); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | ▶ | return is_perl_builtin($word) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | ▶ | my $after_list_cast = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | my ($e) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 3 | my $cast = $e->sprevious_sibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 3 | ▶ | return $cast && $cast->isa('PPI::Token::Cast') && $cast->content =~ m/\A[\@%]\z/xs ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$cast and $cast->isa("PPI::Token::Cast") and $cast->content =~ /\A[\@%]\z/aasx
$cast and $cast->isa("PPI::Token::Cast")
MC/DC33%1/3
$cast and $cast->isa("PPI::Token::Cast") and $cast->content =~ /\A[\@%]\z/aasx
$cast
$cast->isa("PPI::Token::Cast")
$cast->content =~ /\A[\@%]\z/aasx
Truth table50%2/4
A and B and C
A= $castB= $cast->isa("PPI::Token::Cast")C= $cast->content =~ /\A[\@%]\z/aasx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # Whether a subscript takes a slice rather than one element: after an array or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # a hash, after @{...} or %{...}, or after ->@ or ->%. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 7 | ▶ | my $is_slice = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 7 | my ($subscript) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 7 | my $before = $subscript->sprevious_sibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 7 | ▶ | return 0 unless $before; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 7 | ▶ | return 1 if $before->isa('PPI::Token::Symbol') && $before->content =~ m/\A[\@%]/xs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$before->isa("PPI::Token::Symbol") and $before->content =~ /\A[\@%]/aasx
MC/DC100%2/2
$before->isa("PPI::Token::Symbol") and $before->content =~ /\A[\@%]/aasx
$before->isa("PPI::Token::Symbol")
$before->content =~ /\A[\@%]/aasx
Truth table100%3/3
A and B
A= $before->isa("PPI::Token::Symbol")B= $before->content =~ /\A[\@%]/aasx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 4 | ▶ | return 1 if $before->isa('PPI::Token::Cast') && $before->content =~ m/\A[\@%]\z/xs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$before->isa("PPI::Token::Cast") and $before->content =~ /\A[\@%]\z/aasx
MC/DC50%1/2
$before->isa("PPI::Token::Cast") and $before->content =~ /\A[\@%]\z/aasx
$before->isa("PPI::Token::Cast")
$before->content =~ /\A[\@%]\z/aasx
Truth table66%2/3
A and B
A= $before->isa("PPI::Token::Cast")B= $before->content =~ /\A[\@%]\z/aasx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 3 | ▶ | return $before->isa('PPI::Structure::Block') && $after_list_cast->($before) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$before->isa("PPI::Structure::Block") and &$after_list_cast($before)
MC/DC0%0/2
$before->isa("PPI::Structure::Block") and &$after_list_cast($before)
$before->isa("PPI::Structure::Block")
&$after_list_cast($before)
Truth table33%1/3
A and B
A= $before->isa("PPI::Structure::Block")B= &$after_list_cast($before)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # Whether the range at $at, whose left operand starts after $before, is in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # list context. It walks out to the left, past a comma list, a ternary and a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # bare parenthesised group, to the first thing that gives an expression a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # context. Where it cannot tell, the answer is no, so that a flip-flop is never | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # reported. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 101 | ▶ | my $in_list_context = sub { ## no critic (ProhibitSingleUseLexicalSubs) Inlined, it takes the score of violates past 40 for CognitiveComplexity. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=45 SCAR=38.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 101 | my ( $at, $before ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 101 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 158 | ▶ | if ( !$before ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 80 | my $statement = $at->parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 80 | ▶ | my $holder = $statement ? $statement->parent : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 80 | ▶ | return 0 unless $holder; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 80 | ▶ | return 1 if $holder->isa('PPI::Structure::Constructor'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 77 | ▶ | return 0 if $holder->isa('PPI::Structure::Subscript') && !$is_slice->($holder); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$holder->isa("PPI::Structure::Subscript") and not &$is_slice($holder)
MC/DC100%2/2
$holder->isa("PPI::Structure::Subscript") and not &$is_slice($holder)
$holder->isa("PPI::Structure::Subscript")
not &$is_slice($holder)
Truth table100%3/3
A and not(B)
A= $holder->isa("PPI::Structure::Subscript")B= not &$is_slice($holder)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 74 | ▶ | return 1 if $holder->isa('PPI::Structure::Subscript'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 71 | ▶ | return 0 if $holder->isa('PPI::Structure::Block') && !$follows_word->( $holder, \%LIST_BLOCK ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$holder->isa("PPI::Structure::Block") and not &$follows_word($holder, \%LIST_BLOCK)
MC/DC100%2/2
$holder->isa("PPI::Structure::Block") and not &$follows_word($holder, \%LIST_BLOCK)
$holder->isa("PPI::Structure::Block")
not &$follows_word($holder, \%LIST_BLOCK)
Truth table100%3/3
A and not(B)
A= $holder->isa("PPI::Structure::Block")B= not &$follows_word($holder, \%LIST_BLOCK)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 70 | ▶ | return 1 if $holder->isa('PPI::Structure::Block'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 69 | ▶ | return 0 unless $holder->isa('PPI::Structure::List'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 61 | my $compound = $holder->parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 61 | ▶ | return 0 if $compound->isa('PPI::Statement::Compound') && $compound->type ne 'foreach'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$compound->isa("PPI::Statement::Compound") and $compound->type ne "foreach"
MC/DC0%0/2
$compound->isa("PPI::Statement::Compound") and $compound->type ne "foreach"
$compound->isa("PPI::Statement::Compound")
$compound->type ne "foreach"
Truth table66%2/3
A and B
A= $compound->isa("PPI::Statement::Compound")B= $compound->type ne "foreach"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 61 | ▶ | return 1 if $compound->isa('PPI::Statement::Compound'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # The list of a call: of a word, of a code reference, or of &name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 54 | my $caller = $holder->sprevious_sibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 54 | ▶ | return 0 if $caller && $caller->isa('PPI::Token::Word') && !$gives_a_list->($caller); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$caller and $caller->isa("PPI::Token::Word") and not &$gives_a_list($caller)
$caller and $caller->isa("PPI::Token::Word")
MC/DC100%3/3
$caller and $caller->isa("PPI::Token::Word") and not &$gives_a_list($caller)
$caller
$caller->isa("PPI::Token::Word")
not &$gives_a_list($caller)
Truth table100%4/4
A and B and not(C)
A= $callerB= $caller->isa("PPI::Token::Word")C= not &$gives_a_list($caller)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 53 | ▶ | return 1 if $caller && ( $caller->isa('PPI::Token::Word') || $is_operator->( $caller, q{->} ) || ( $caller->isa('PPI::Token::Symbol') && index( $caller->content, q{&} ) == 0 ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition91%11/12
$caller and $caller->isa("PPI::Token::Word") || &$is_operator($caller, "->") || $caller->isa("PPI::Token::Symbol") && index($caller->content, "&") == 0
$caller->isa("PPI::Token::Word") or &$is_operator($caller, "->") or $caller->isa("PPI::Token::Symbol") and index($caller->content, "&") == 0
$caller->isa("PPI::Token::Word") or &$is_operator($caller, "->")
$caller->isa("PPI::Token::Symbol") and index($caller->content, "&") == 0
MC/DC80%4/5
$caller and $caller->isa("PPI::Token::Word") || &$is_operator($caller, "->") || $caller->isa("PPI::Token::Symbol") && index($caller->content, "&") == 0
$caller
$caller->isa("PPI::Token::Word")
&$is_operator($caller, "->")
$caller->isa("PPI::Token::Symbol")
index($caller->content, "&") == 0
Truth table83%5/6
A and B or C or D and E
A= $callerB= $caller->isa("PPI::Token::Word")C= &$is_operator($caller, "->")D= $caller->isa("PPI::Token::Symbol")E= index($caller->content, "&") == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # A bare group, which has the context of the place where it is. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 46 | my ( undef, $past ) = $right_operand->($holder); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 46 | ▶ | return 0 if $is_operator->( $past, q{?} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | # ( LIST )[ ... ], which PPI gives as a list and then a subscript, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # or a list and then an anonymous array. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 45 | my $next = $holder->snext_sibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 45 | ▶ | return 1 if $next && ( $next->isa('PPI::Structure::Subscript') || $next->isa('PPI::Structure::Constructor') ) && $next->start->content eq q{[}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$next and $next->isa("PPI::Structure::Subscript") || $next->isa("PPI::Structure::Constructor") and $next->start->content eq "["
$next and $next->isa("PPI::Structure::Subscript") || $next->isa("PPI::Structure::Constructor")
$next->isa("PPI::Structure::Subscript") or $next->isa("PPI::Structure::Constructor")
MC/DC50%2/4
$next and $next->isa("PPI::Structure::Subscript") || $next->isa("PPI::Structure::Constructor") and $next->start->content eq "["
$next
$next->isa("PPI::Structure::Subscript")
$next->isa("PPI::Structure::Constructor")
$next->start->content eq "["
Truth table50%3/6
A and B or C and D
A= $nextB= $next->isa("PPI::Structure::Subscript")C= $next->isa("PPI::Structure::Constructor")D= $next->start->content eq "["
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 44 | ( undef, $before ) = $left_operand->($holder); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 44 | $at = $holder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 44 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 78 | ▶ | if ( $is_operator->( $before, q{=} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # An array, a hash, a list or a slice on the left takes a list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 50 | my $lhs = $before->sprevious_sibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 50 | ▶ | return 0 unless $lhs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 50 | ▶ | return 1 if $lhs->isa('PPI::Structure::List'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 49 | ▶ | return 1 if $lhs->isa('PPI::Token::Symbol') && $lhs->content =~ m/\A[\@%]/xs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$lhs->isa("PPI::Token::Symbol") and $lhs->content =~ /\A[\@%]/aasx
MC/DC100%2/2
$lhs->isa("PPI::Token::Symbol") and $lhs->content =~ /\A[\@%]/aasx
$lhs->isa("PPI::Token::Symbol")
$lhs->content =~ /\A[\@%]/aasx
Truth table100%3/3
A and B
A= $lhs->isa("PPI::Token::Symbol")B= $lhs->content =~ /\A[\@%]/aasx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 4 | ▶ | return 1 if ( $lhs->isa('PPI::Token::Symbol') || $lhs->isa('PPI::Structure::Block') ) && $after_list_cast->($lhs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$lhs->isa("PPI::Token::Symbol") || $lhs->isa("PPI::Structure::Block") and &$after_list_cast($lhs)
$lhs->isa("PPI::Token::Symbol") or $lhs->isa("PPI::Structure::Block")
MC/DC100%3/3
$lhs->isa("PPI::Token::Symbol") || $lhs->isa("PPI::Structure::Block") and &$after_list_cast($lhs)
$lhs->isa("PPI::Token::Symbol")
$lhs->isa("PPI::Structure::Block")
&$after_list_cast($lhs)
Truth table80%4/5
A or B and C
A= $lhs->isa("PPI::Token::Symbol")B= $lhs->isa("PPI::Structure::Block")C= &$after_list_cast($lhs)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | ▶ | return 1 if $lhs->isa('PPI::Structure::Subscript') && $is_slice->($lhs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$lhs->isa("PPI::Structure::Subscript") and &$is_slice($lhs)
MC/DC50%1/2
$lhs->isa("PPI::Structure::Subscript") and &$is_slice($lhs)
$lhs->isa("PPI::Structure::Subscript")
&$is_slice($lhs)
Truth table66%2/3
A and B
A= $lhs->isa("PPI::Structure::Subscript")B= &$is_slice($lhs)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 28 | ▶ | if ( $before->isa('PPI::Token::Operator') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | # A range operator here ends an earlier range in the same list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 14 | ▶ | return 0 unless $LIST_SEPARATOR{ $before->content } || $RANGE_OPERATOR{ $before->content }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$LIST_SEPARATOR{$before->content} or $RANGE_OPERATOR{$before->content}
MC/DC100%2/2
$LIST_SEPARATOR{$before->content} or $RANGE_OPERATOR{$before->content}
$LIST_SEPARATOR{$before->content}
$RANGE_OPERATOR{$before->content}
Truth table100%3/3
A or B
A= $LIST_SEPARATOR{$before->content}B= $RANGE_OPERATOR{$before->content}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 13 | $at = $before; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 13 | ( undef, $before ) = $left_operand->($before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 13 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 14 | ▶ | return 0 if $before->isa('PPI::Token::Word') && !$gives_a_list->($before); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$before->isa("PPI::Token::Word") and not &$gives_a_list($before)
MC/DC100%2/2
$before->isa("PPI::Token::Word") and not &$gives_a_list($before)
$before->isa("PPI::Token::Word")
not &$gives_a_list($before)
Truth table100%3/3
A and not(B)
A= $before->isa("PPI::Token::Word")B= not &$gives_a_list($before)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 8 | ▶ | return 1 if $before->isa('PPI::Token::Word') || $before->isa('PPI::Structure::Block'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$before->isa("PPI::Token::Word") or $before->isa("PPI::Structure::Block")
MC/DC0%0/2
$before->isa("PPI::Token::Word") or $before->isa("PPI::Structure::Block")
$before->isa("PPI::Token::Word")
$before->isa("PPI::Structure::Block")
Truth table66%2/3
A or B
A= $before->isa("PPI::Token::Word")B= $before->isa("PPI::Structure::Block")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 259 | ▶ | sub violates { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
violates: called CC=28 SCAR=33.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 259 | my ( $self, $elem ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 259 | ▶ | return () unless $RANGE_OPERATOR{ $elem->content }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 134 | my ( $left_elements, $before ) = $left_operand->($elem); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 134 | my ( $right_elements, $after ) = $right_operand->($elem); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 134 | ▶ | return () unless @$left_elements && @$right_elements; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@$left_elements and @$right_elements
MC/DC50%1/2
@$left_elements and @$right_elements
@$left_elements
@$right_elements
Truth table66%2/3
A and B
A= @$left_elementsB= @$right_elements
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # The condition of a ternary is in boolean context: a flip-flop. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 133 | ▶ | return () if $is_operator->( $after, q{?} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # What Perl gives for the range, as the end of the message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 132 | my $left = $literal->(@$left_elements); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 132 | my $right = $literal->(@$right_elements); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 132 | ▶ | return () unless defined $right; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 124 | my $gives; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 124 | ▶ | if ( !defined $left ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 22 | ▶ | return () unless $right->{number}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 20 | my $end = int $right->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 20 | ▶ | return () if $end < 0 || $end > $self->{_largest_end}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$end < 0 or $end > $self->{"_largest_end"}
MC/DC100%2/2
$end < 0 or $end > $self->{"_largest_end"}
$end < 0
$end > $self->{"_largest_end"}
Truth table100%3/3
A or B
A= $end < 0B= $end > $self->{"_largest_end"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 14 | $gives = 'gives an empty list when ' . $source->(@$left_elements) . " is more than $end"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 102 | my ( $from, $to ) = ( $left->{value}, $right->{value} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 102 | ▶ | return () unless defined $from && defined $to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $from and defined $to
MC/DC50%1/2
defined $from and defined $to
defined $from
defined $to
Truth table66%2/3
A and B
A= defined $fromB= defined $to
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # Perl counts by numbers, as pp_flop decides, with a number at either | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | # end, or two strings that look like numbers where the left one does | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | # not start with 0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 101 | ▶ | if ( $left->{number} || $right->{number} || ( looks_like_number($from) && index( $from, q{0} ) != 0 && looks_like_number($to) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition91%11/12
$left->{"number"} or $right->{"number"} or &looks_like_number($from) and index($from, 0) != 0 and &looks_like_number($to)
$left->{"number"} or $right->{"number"}
&looks_like_number($from) and index($from, 0) != 0 and &looks_like_number($to)
&looks_like_number($from) and index($from, 0) != 0
MC/DC80%4/5
$left->{"number"} or $right->{"number"} or &looks_like_number($from) and index($from, 0) != 0 and &looks_like_number($to)
$left->{"number"}
$right->{"number"}
&looks_like_number($from)
index($from, 0) != 0
&looks_like_number($to)
Truth table83%5/6
A or B or C and D and E
A= $left->{"number"}B= $right->{"number"}C= &looks_like_number($from)D= index($from, 0) != 0E= &looks_like_number($to)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 75 | ▶ | return () unless looks_like_number($from) && looks_like_number($to); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
&looks_like_number($from) and &looks_like_number($to)
MC/DC50%1/2
&looks_like_number($from) and &looks_like_number($to)
&looks_like_number($from)
&looks_like_number($to)
Truth table66%2/3
A and B
A= &looks_like_number($from)B= &looks_like_number($to)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 74 | ▶ | return () if int $from <= int $to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 68 | $gives = 'gives an empty list'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | elsif ( length $from > length $to ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 3 | $gives = 'gives an empty list'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 23 | ▶ | return () if length $from < length $to || $from le $to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
length $from < length $to or $from le $to
MC/DC100%2/2
length $from < length $to or $from le $to
length $from < length $to
$from le $to
Truth table100%3/3
A or B
A= length $from < length $toB= $from le $to
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # The same length, and $from sorts after $to. Perl counts up from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # $from by the magic increment, never meets $to, and stops before | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | # the first string that is longer. A string that is not letters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # then digits does not increment, so Perl gives it alone. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 16 | ▶ | my $last = $from =~ m/\A[[:alpha:]]*[[:digit:]]*\z/xs ? join q{}, map { m/[[:digit:]]/xs ? q{9} : m/[[:upper:]]/xs ? q{Z} : q{z} } split m//xs, $from : $from; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 16 | ▶ | $gives = $last eq $from ? "gives only ('$from')" : "gives every string from '$from' up to '$last', and never reaches '$to'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 101 | ▶ | return () unless $in_list_context->( $elem, $before ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 79 | my $range = join q{ }, $source->(@$left_elements), $elem->content, $source->(@$right_elements); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 79 | return $self->violation( "$range $gives", $EXPL, $elem ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||