lib/Perl/Critic/Policy/ErrorHandling/RequireCheckingReturnValueOfEval.pm

filter: Statementstmt 26.6% 36 / 135 Branchbran 0.9% 1 / 104 Conditioncond 0.0% 0 / 42 MC/DCmcdc 0.0% 0 / 25 Subroutinesub 57.1% 12 / 21 Podpod 80.0% 4 / 5 totaltotal 15.9% 53 / 332 CC 67 SCAR 44.4
CC
67
Cov
13%
_is_in_correct_position_in_a_structure_condition
182.0
_is_in_postfix_expression
132.0
violates
122.9
CRAP 84.4
« lib/Perl/Critic/Policy/Subroutines/ProhibitUnusedPrivateSubroutines.pm ↑ Summary lib/Perl/Critic/Policy/BuiltinFunctions/ProhibitReverseSortBlock.pm »
1 package Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval;
2  
3 40 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 40 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 40 ▶use Scalar::Util qw< refaddr >;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 40 ▶use Perl::Critic::Utils qw< :booleans :characters :severities hashify
Subroutine BEGIN: called CC=1 SCAR=0.0
12 40 precedence_of >;
13 40 ▶use parent 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 40 our $VERSION = '1.156';
16  
17 #-----------------------------------------------------------------------------
18  
19 40 Readonly::Scalar my $DESC => 'Return value of eval not tested.';
20 ## no critic (RequireInterpolationOfMetachars)
21 40 Readonly::Scalar my $EXPL =>
22 q<You can't depend upon the value of $@/$EVAL_ERROR to tell whether an eval failed.>;
23 ## use critic
24  
25 40 Readonly::Hash my %BOOLEAN_OPERATORS => hashify qw< || && // or and >;
26 40 Readonly::Hash my %POSTFIX_OPERATORS =>
27 hashify qw< for foreach if unless while until >;
28  
29 40 Readonly::Scalar my $PRECEDENCE_OF_EQUALS => precedence_of( q{=} );
30  
31 #-----------------------------------------------------------------------------
32  
33 90 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
34 74 ▶sub default_severity { return $SEVERITY_MEDIUM }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
35 73 ▶sub default_themes { return qw( core bugs ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
36 2 ▶sub applies_to { return 'PPI::Token::Word' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
37  
38 #-----------------------------------------------------------------------------
39  
40 12 ▶sub violates {
Subroutine violates: called CC=12 SCAR=48.1
Pod documented
41 12 my ( $self, $elem, undef ) = @_;
42  
43 12 ▶ return if $elem->content() ne 'eval';
Branch: 1 branch
BranchTrueFalseTotal
if $elem->content ne "eval" 12 0 12
44  
45 0 ▶ my $evaluated = $elem->snext_sibling() or return; # Nothing to eval!
Branch: 1 branch
BranchTrueFalseTotal
my $evaluated = $elem->snext_sibling or return 0 0 0
46 0 my $following = $evaluated->snext_sibling();
47  
48 0 ▶ return if _is_returned( $elem ); # GitHub #324
Branch: 1 branch
BranchTrueFalseTotal
if _is_returned($elem) 0 0 0
49 0 ▶ return if _is_in_right_hand_side_of_assignment($elem);
Branch: 1 branch
BranchTrueFalseTotal
if _is_in_right_hand_side_of_assignment($elem) 0 0 0
50 0 ▶ return if _is_in_postfix_expression($elem);
Branch: 1 branch
BranchTrueFalseTotal
if _is_in_postfix_expression($elem) 0 0 0
51 return if
52 0 ▶ _is_in_correct_position_in_a_condition_or_foreach_loop_collection(
Branch: 1 branch
BranchTrueFalseTotal
if _is_in_correct_position_in_a_condition_or_foreach_loop_collection($elem, $following) 0 0 0
53 $elem,
54 $following,
55 );
56  
57 0 ▶ return if _scan_backwards_for_grep( $elem ); # RT 69489
Branch: 1 branch
BranchTrueFalseTotal
if _scan_backwards_for_grep($elem) 0 0 0
58  
59 0 ▶ if ( $following and $following->isa('PPI::Token::Operator') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($following and $following->isa("PPI::Token::Operator")) 0 0 0
Condition0%0/3
$following and $following->isa("PPI::Token::Operator")
!ll&&!rl&&r
000
MC/DC0%0/2
$following and $following->isa("PPI::Token::Operator")
$following $following->isa("PPI::Token::Operator")
Truth table0%0/3
A and B
A= $followingB= $following->isa("PPI::Token::Operator")
ABresult
0X0
100
111
60 0 ▶ return if $BOOLEAN_OPERATORS{ $following->content() };
Branch: 1 branch
BranchTrueFalseTotal
if $BOOLEAN_OPERATORS{$following->content} 0 0 0
61 0 ▶ return if q{?} eq $following->content;
Branch: 1 branch
BranchTrueFalseTotal
if "?" eq $following->content 0 0 0
62 }
63  
64 0 return $self->violation($DESC, $EXPL, $elem);
65 }
66  
67 #-----------------------------------------------------------------------------
68  
69 0 ▶sub _is_in_right_hand_side_of_assignment {
Subroutine _is_in_right_hand_side_of_assignment: not called CC=7 SCAR=40.3
70 0 my ($elem) = @_;
71  
72 0 my $previous = $elem->sprevious_sibling();
73  
74 0 ▶ if (not $previous) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($previous) 0 0 0
75 0 $previous =
76 _grandparent_for_is_in_right_hand_side_of_assignment($elem);
77 }
78  
79 0 ▶ while ($previous) {
Branch: 1 branch
BranchTrueFalseTotal
if ($previous) 0 0 0
80 0 my $base_previous = $previous;
81  
82 EQUALS_SCAN:
83 0 ▶ while ($previous) {
Branch: 1 branch
BranchTrueFalseTotal
if ($previous) 0 0 0
84 0 ▶ if ( $previous->isa('PPI::Token::Operator') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($previous->isa("PPI::Token::Operator")) 0 0 0
85 0 ▶ return $TRUE if $previous->content() =~ m/= \Z/xms;
Branch: 1 branch
BranchTrueFalseTotal
if $previous->content =~ /= \Z/msx 0 0 0
86 0 ▶ last EQUALS_SCAN if _is_effectively_a_comma($previous);
Branch: 1 branch
BranchTrueFalseTotal
if _is_effectively_a_comma($previous) 0 0 0
87 }
88 0 $previous = $previous->sprevious_sibling();
89 }
90  
91 $previous =
92 0 _grandparent_for_is_in_right_hand_side_of_assignment($base_previous);
93 }
94  
95 0 return;
96 }
97  
98 0 ▶sub _grandparent_for_is_in_right_hand_side_of_assignment {
Subroutine _grandparent_for_is_in_right_hand_side_of_assignment: not called CC=6 SCAR=37.4
99 0 my ($elem) = @_;
100  
101 0 ▶ my $parent = $elem->parent() or return;
Branch: 1 branch
BranchTrueFalseTotal
my $parent = $elem->parent or return 0 0 0
102 0 ▶ $parent->isa('PPI::Statement') or return;
Branch: 1 branch
BranchTrueFalseTotal
$parent->isa("PPI::Statement") or return 0 0 0
103  
104 0 ▶ my $grandparent = $parent->parent() or return;
Branch: 1 branch
BranchTrueFalseTotal
my $grandparent = $parent->parent or return 0 0 0
105  
106 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($grandparent->isa("PPI::Structure::Constructor") or $grandparent->isa("PPI::Structure::List")) 0 0 0
Condition0%0/3
$grandparent->isa("PPI::Structure::Constructor") or $grandparent->isa("PPI::Structure::List")
l!l&&r!l&&!r
000
MC/DC0%0/2
$grandparent->isa("PPI::Structure::Constructor") or $grandparent->isa("PPI::Structure::List")
$grandparent->isa("PPI::Structure::Constructor") $grandparent->isa("PPI::Structure::List")
Truth table0%0/3
A or B
A= $grandparent->isa("PPI::Structure::Constructor")B= $grandparent->isa("PPI::Structure::List")
ABresult
1X1
011
000
107 $grandparent->isa('PPI::Structure::Constructor')
108 or $grandparent->isa('PPI::Structure::List')
109 ) {
110 0 return $grandparent;
111 }
112  
113 0 return;
114 }
115  
116 #-----------------------------------------------------------------------------
117  
118 40 Readonly::Scalar my $CONDITION_POSITION_IN_C_STYLE_FOR_LOOP => 1;
119  
120 0 ▶sub _is_in_correct_position_in_a_condition_or_foreach_loop_collection {
Subroutine _is_in_correct_position_in_a_condition_or_foreach_loop_collection: not called CC=9 SCAR=45.0
121 0 my ($elem, $following) = @_;
122  
123 0 my $parent = $elem->parent();
124 0 ▶ while ($parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent) 0 0 0
125 0 ▶ if ( $parent->isa('PPI::Structure::Condition') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent->isa("PPI::Structure::Condition")) 0 0 0
126 return
127 0 _is_in_correct_position_in_a_structure_condition(
128 $elem, $parent, $following,
129 );
130 }
131  
132 # TECHNICAL DEBT: This code is basically shared with
133 # ProhibitUnusedCapture. I don't want to put this code
134 # into Perl::Critic::Utils::*, but I don't have time to sort out
135 # PPIx::Utilities::Structure::List yet.
136 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($parent->isa("PPI::Structure::List") and my $parent_statement = $parent->statement) 0 0 0
Condition0%0/3
$parent->isa("PPI::Structure::List") and my $parent_statement = $parent->statement
!ll&&!rl&&r
000
MC/DC0%0/2
$parent->isa("PPI::Structure::List") and my $parent_statement = $parent->statement
$parent->isa("PPI::Structure::List") my $parent_statement = $parent->statement
Truth table0%0/3
A and B
A= $parent->isa("PPI::Structure::List")B= my $parent_statement = $parent->statement
ABresult
0X0
100
111
137 $parent->isa('PPI::Structure::List')
138 and my $parent_statement = $parent->statement()
139 ) {
140 0 ▶ return $TRUE if
Branch: 1 branch
BranchTrueFalseTotal
if $parent_statement->isa("PPI::Statement::Compound") and $parent_statement->type eq "foreach" 0 0 0
Condition0%0/3
$parent_statement->isa("PPI::Statement::Compound") and $parent_statement->type eq "foreach"
!ll&&!rl&&r
000
MC/DC0%0/2
$parent_statement->isa("PPI::Statement::Compound") and $parent_statement->type eq "foreach"
$parent_statement->isa("PPI::Statement::Compound") $parent_statement->type eq "foreach"
Truth table0%0/3
A and B
A= $parent_statement->isa("PPI::Statement::Compound")B= $parent_statement->type eq "foreach"
ABresult
0X0
100
111
141 $parent_statement->isa('PPI::Statement::Compound')
142 and $parent_statement->type() eq 'foreach';
143 }
144  
145 0 ▶ if ( $parent->isa('PPI::Structure::For') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent->isa("PPI::Structure::For")) 0 0 0
146 0 my @for_loop_components = $parent->schildren();
147  
148 0 ▶ my $condition =
Branch: 1 branch
BranchTrueFalseTotal
my $condition = $for_loop_components[$CONDITION_POSITION_IN_C_STYLE_FOR_LOOP] or return 0 0 0
149 $for_loop_components[$CONDITION_POSITION_IN_C_STYLE_FOR_LOOP]
150 or return;
151  
152 0 return _descendant_of($elem, $condition);
153 }
154  
155 0 $parent = $parent->parent();
156 }
157  
158 0 return;
159 }
160  
161 0 ▶sub _is_in_correct_position_in_a_structure_condition {
Subroutine _is_in_correct_position_in_a_structure_condition: not called CC=13 SCAR=52.0
162 0 my ($elem, $parent, $following) = @_;
163  
164 0 my $level = $elem;
165 0 ▶ while ($level and refaddr $level != $parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($level and builtin::refaddr($level) != $parent) 0 0 0
Condition0%0/3
$level and builtin::refaddr($level) != $parent
!ll&&!rl&&r
000
MC/DC0%0/2
$level and builtin::refaddr($level) != $parent
$level builtin::refaddr($level) != $parent
Truth table0%0/3
A and B
A= $levelB= builtin::refaddr($level) != $parent
ABresult
0X0
100
111
166 0 ▶ my $cursor = refaddr $elem == refaddr $level ? $following : $level;
Branch: 1 branch
BranchTrueFalseTotal
builtin::refaddr($elem) == builtin::refaddr($level) ? : 0 0 0
167  
168 IS_FINAL_EXPRESSION_AT_DEPTH:
169 0 ▶ while ($cursor) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cursor) 0 0 0
170 0 ▶ if ( _is_effectively_a_comma($cursor) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_effectively_a_comma($cursor)) 0 0 0
171 0 $cursor = $cursor->snext_sibling();
172 0 ▶ while ( _is_effectively_a_comma($cursor) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_effectively_a_comma($cursor)) 0 0 0
173 0 $cursor = $cursor->snext_sibling();
174 }
175  
176 # Semicolon would be a syntax error here.
177 0 ▶ return if $cursor;
Branch: 1 branch
BranchTrueFalseTotal
if $cursor 0 0 0
178 0 last IS_FINAL_EXPRESSION_AT_DEPTH;
179 }
180  
181 0 $cursor = $cursor->snext_sibling();
182 }
183  
184 0 my $statement = $level->parent();
185 0 ▶ return $TRUE if not $statement; # Shouldn't happen.
Branch: 1 branch
BranchTrueFalseTotal
unless $statement 0 0 0
186 0 ▶ return $TRUE if not $statement->isa('PPI::Statement'); # Shouldn't happen.
Branch: 1 branch
BranchTrueFalseTotal
unless $statement->isa("PPI::Statement") 0 0 0
187  
188 0 $level = $statement->parent();
189 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
unless ($level and $level->isa("PPI::Structure::List") || $level->isa("PPI::Structure::Condition")) 0 0 0
Condition0%0/6
$level and $level->isa("PPI::Structure::List") || $level->isa("PPI::Structure::Condition")
!ll&&!rl&&r
000
$level->isa("PPI::Structure::List") or $level->isa("PPI::Structure::Condition")
l!l&&r!l&&!r
000
MC/DC0%0/3
$level and $level->isa("PPI::Structure::List") || $level->isa("PPI::Structure::Condition")
$level $level->isa("PPI::Structure::List") $level->isa("PPI::Structure::Condition")
Truth table0%0/4
A and B or C
A= $levelB= $level->isa("PPI::Structure::List")C= $level->isa("PPI::Structure::Condition")
ABCresult
0XX0
1000
11X1
1011
190 not $level
191 or (
192 not $level->isa('PPI::Structure::List')
193 and not $level->isa('PPI::Structure::Condition')
194 )
195 ) {
196 # Shouldn't happen.
197 0 return $TRUE;
198 }
199 }
200  
201 0 return $TRUE;
202 }
203  
204 # Replace with PPI implementation once it is released.
205 0 ▶sub _descendant_of {
Subroutine _descendant_of: not called CC=4 SCAR=30.0
206 0 my ($cursor, $potential_ancestor) = @_;
207  
208 0 ▶ return $EMPTY if not $potential_ancestor;
Branch: 1 branch
BranchTrueFalseTotal
unless $potential_ancestor 0 0 0
209  
210 0 ▶ while ( refaddr $cursor != refaddr $potential_ancestor ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::refaddr($cursor) != builtin::refaddr($potential_ancestor)) 0 0 0
211 0 ▶ $cursor = $cursor->parent() or return $EMPTY;
Branch: 1 branch
BranchTrueFalseTotal
$cursor = $cursor->parent or return $Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::EMPTY 0 0 0
212 }
213  
214 0 return 1;
215 }
216  
217 #-----------------------------------------------------------------------------
218  
219 0 ▶sub _is_in_postfix_expression {
Subroutine _is_in_postfix_expression: not called CC=11 SCAR=48.8
220 0 my ($elem) = @_;
221  
222 0 my $current_base = $elem;
223 0 ▶ while ($TRUE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::TRUE) 0 0 0
224 0 my $previous = $current_base->sprevious_sibling();
225 0 ▶ while ($previous) {
Branch: 1 branch
BranchTrueFalseTotal
if ($previous) 0 0 0
226 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($previous->isa("PPI::Token::Word") and $POSTFIX_OPERATORS{$previous->content}) 0 0 0
Condition0%0/3
$previous->isa("PPI::Token::Word") and $POSTFIX_OPERATORS{$previous->content}
!ll&&!rl&&r
000
MC/DC0%0/2
$previous->isa("PPI::Token::Word") and $POSTFIX_OPERATORS{$previous->content}
$previous->isa("PPI::Token::Word") $POSTFIX_OPERATORS{$previous->content}
Truth table0%0/3
A and B
A= $previous->isa("PPI::Token::Word")B= $POSTFIX_OPERATORS{$previous->content}
ABresult
0X0
100
111
227 $previous->isa('PPI::Token::Word')
228 and $POSTFIX_OPERATORS{ $previous->content() }
229 ) {
230 0 return $TRUE;
231 }
232 0 $previous = $previous->sprevious_sibling();
233 } # end while
234  
235 0 ▶ my $parent = $current_base->parent() or return;
Branch: 1 branch
BranchTrueFalseTotal
my $parent = $current_base->parent or return 0 0 0
236 0 ▶ if ( $parent->isa('PPI::Statement') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent->isa('PPI::Statement')) { } 0 0 0
237 0 ▶ return if $parent->specialized();
Branch: 1 branch
BranchTrueFalseTotal
if $parent->specialized 0 0 0
238  
239 0 ▶ my $grandparent = $parent->parent() or return;
Branch: 1 branch
BranchTrueFalseTotal
my $grandparent = $parent->parent or return 0 0 0
240 0 ▶ return if not $grandparent->isa('PPI::Structure::List');
Branch: 1 branch
BranchTrueFalseTotal
unless $grandparent->isa("PPI::Structure::List") 0 0 0
241  
242 0 $current_base = $grandparent;
243 } else {
244 0 $current_base = $parent;
245 }
246  
247 0 ▶ return if not $current_base->isa('PPI::Structure::List');
Branch: 1 branch
BranchTrueFalseTotal
unless $current_base->isa("PPI::Structure::List") 0 0 0
248 }
249  
250 0 return;
251 }
252  
253 #-----------------------------------------------------------------------------
254  
255 0 ▶sub _scan_backwards_for_grep {
Subroutine _scan_backwards_for_grep: not called CC=7 SCAR=40.3
256 0 my ( $elem ) = @_;
257  
258 0 ▶ while ( $elem ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem) 0 0 0
259  
260 0 my $parent = $elem->parent();
261  
262 0 ▶ while ( $elem = $elem->sprevious_sibling() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem = $elem->sprevious_sibling) 0 0 0
263 0 ▶ $elem->isa( 'PPI::Token::Word' )
Branch: 1 branch
BranchTrueFalseTotal
$elem->isa("PPI::Token::Word") and "grep" eq $elem->content and return $Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::TRUE 0 0 0
Condition0%0/3
$elem->isa("PPI::Token::Word") and "grep" eq $elem->content
!ll&&!rl&&r
000
MC/DC0%0/2
$elem->isa("PPI::Token::Word") and "grep" eq $elem->content
$elem->isa("PPI::Token::Word") "grep" eq $elem->content
Truth table0%0/3
A and B
A= $elem->isa("PPI::Token::Word")B= "grep" eq $elem->content
ABresult
0X0
100
111
264 and 'grep' eq $elem->content()
265 and return $TRUE;
266 0 ▶ $elem->isa( 'PPI::Token::Operator' )
Branch: 1 branch
BranchTrueFalseTotal
$elem->isa("PPI::Token::Operator") and precedence_of($elem) >= $PRECEDENCE_OF_EQUALS and return $Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::FALSE 0 0 0
Condition0%0/3
$elem->isa("PPI::Token::Operator") and precedence_of($elem) >= $PRECEDENCE_OF_EQUALS
!ll&&!rl&&r
000
MC/DC0%0/2
$elem->isa("PPI::Token::Operator") and precedence_of($elem) >= $PRECEDENCE_OF_EQUALS
$elem->isa("PPI::Token::Operator") precedence_of($elem) >= $PRECEDENCE_OF_EQUALS
Truth table0%0/3
A and B
A= $elem->isa("PPI::Token::Operator")B= precedence_of($elem) >= $PRECEDENCE_OF_EQUALS
ABresult
0X0
100
111
267 and precedence_of( $elem ) >= $PRECEDENCE_OF_EQUALS
268 and return $FALSE;
269 }
270  
271 0 $elem = $parent;
272 }
273  
274 0 return $FALSE;
275  
276 }
277  
278 #-----------------------------------------------------------------------------
279  
280 0 ▶sub _is_effectively_a_comma {
Subroutine _is_effectively_a_comma: not called CC=4 SCAR=30.0
281 0 my ($elem) = @_;
282  
283 0 ▶ return if not $elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 0 0
284  
285 return
286 0 ▶ $elem->isa('PPI::Token::Operator')
Condition0%0/6
$elem->isa('PPI::Token::Operator') && ($elem->content eq $Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::COMMA || $elem->content eq $Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::FATCOMMA)
!ll&&!rl&&r
000
$elem->content eq $Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::COMMA or $elem->content eq $Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::FATCOMMA
l!l&&r!l&&!r
000
MC/DC0%0/3
$elem->isa('PPI::Token::Operator') && ($elem->content eq $Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::COMMA || $elem->content eq $Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::FATCOMMA)
$elem->isa('PPI::Token::Operator') $elem->content eq $Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::COMMA $elem->content eq $Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::FATCOMMA
Truth table0%0/4
A && B or C
A= $elem->isa('PPI::Token::Operator')B= $elem->content eq $Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::COMMAC= $elem->content eq $Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval::FATCOMMA
ABCresult
0XX0
1000
11X1
1011
287 && (
288 $elem->content() eq $COMMA
289 || $elem->content() eq $FATCOMMA
290 );
291 }
292  
293 #-----------------------------------------------------------------------------
294 # GitHub #324 (https://github.com/Perl-Critic/Perl-Critic/issues/324)
295 {
296 40 Readonly::Scalar my $RETURN => 'return';
297  
298 0 ▶ sub _is_returned {
Subroutine _is_returned: not called CC=3 SCAR=24.8
299 0 my ( $elem ) = @_;
300 0 my $prev = $elem->sprevious_sibling();
301 return
302 0 ▶ $prev
Condition0%0/6
$prev && $prev->isa('PPI::Token::Word') && $RETURN eq $prev->content
!ll&&!rl&&r
000
$prev and $prev->isa("PPI::Token::Word")
!ll&&!rl&&r
000
MC/DC0%0/3
$prev && $prev->isa('PPI::Token::Word') && $RETURN eq $prev->content
$prev $prev->isa("PPI::Token::Word") $RETURN eq $prev->content
Truth table0%0/4
A and B && C
A= $prevB= $prev->isa("PPI::Token::Word")C= $RETURN eq $prev->content
ABCresult
0XX0
10X0
1100
1111
303 &&
304 $prev->isa( 'PPI::Token::Word' )
305 &&
306 $RETURN eq $prev->content();
307 }
308 }
309  
310 #-----------------------------------------------------------------------------
311  
312 40 1;
313  
314 __END__
« lib/Perl/Critic/Policy/Subroutines/ProhibitUnusedPrivateSubroutines.pm ↑ Summary lib/Perl/Critic/Policy/BuiltinFunctions/ProhibitReverseSortBlock.pm »