Branch Coverage

blib/lib/Perl/Critic/Policy/ValuesAndExpressions/PreventSQLInjection.pm
Criterion Covered Total %
branch 105 120 87.5


line true false branch
131 37 79 unless $self->is_sql_statement($element)
135 10 69 if $self->is_in_safe_context($element)
141 36 33 defined $sql_injections && scalar @$sql_injections != 0 ? :
164 93 243 if ($token->isa('PPI::Token::HereDoc') or $token->isa('PPI::Token::Quote')) { }
61 182 elsif ($token->isa('PPI::Token::Operator') and $token->content eq '.') { }
56 126 elsif ($token->isa('PPI::Token::Structure') and $token->content eq ';') { }
3 123 elsif ($token->isa('PPI::Token::Operator') and $token->content eq ':') { }
1 122 elsif ($token->isa('PPI::Token::Operator') and $token->content eq ',') { }
25 97 elsif ($token->isa('PPI::Token::Symbol')) { }
25 72 elsif ($token->isa('PPI::Token::Word')) { }
170 0 93 unless analyze_string_injections($self, $token)
209 19 6 unless ($is_quoted)
213 13 6 unless exists $safe_elements->{$variable}
224 9 16 if (defined $function_name and not $is_quoted)
228 4 5 unless exists $$safe_elements{'&' . $function_name}
243 0 25 unless $token->isa('PPI::Token::Word')
248 0 25 if not defined $next_sibling or $next_sibling eq ''
253 6 19 if ($next_sibling->isa('PPI::Token::Operator') and $next_sibling->content eq '->') { }
18 1 elsif ($next_sibling->isa('PPI::Structure::List')) { }
258 0 6 if not defined $function or $function eq ''
260 2 4 unless $function->isa('PPI::Token::Word')
278 12 6 if $previous_sibling->isa('PPI::Token::Operator') and $previous_sibling->content eq '->'
284 3 3 if (not $content =~ /::/) { }
301 1 9 defined $self->{'_safe_functions_regex'} && $full_name =~ /$self->{'_safe_functions_regex'}/ ? :
311 0 25 unless $token->isa('PPI::Token::Symbol')
319 0 64 if not defined $sibling or $sibling eq ''
321 22 42 if ($sibling->isa('PPI::Token::Operator') and $sibling->content eq '->') { }
17 25 elsif ($sibling->isa('PPI::Structure::Subscript')) { }
6 19 elsif ($sibling->isa('PPI::Token::Word') and $sibling->method_call and defined $self->{'_quoting_methods_regex'} and $sibling->content =~ /$self->{'_quoting_methods_regex'}/) { }
348 4 8 if ($token->isa('PPI::Token::HereDoc') and $token eq '<<"SQL"' || $token eq '<<SQL')
355 2 110 if (not $probably_sql and $self->{'_prefer_upper_case_keywords'})
368 0 79 unless $self->{'_safe_context_regex'}
372 1 78 if not defined $sprevious_sibling or $sprevious_sibling eq ''
373 67 11 unless $sprevious_sibling->isa('PPI::Token::Word')
383 22 166 if ($token->isa('PPI::Token::HereDoc')) { }
166 0 elsif ($token->isa('PPI::Token::Quote')) { }
403 21 72 if $token->isa('PPI::Token::Quote::Single')
418 10 62 $is_heredoc ? :
432 1 42 if ($var =~ /^( \$ |@ |% ) \{ \s* ( \w+ ) \s* \}$/x)
443 61 11 if ($token->isa('PPI::Token::Quote::Double')) { }
1 10 elsif ($token->isa('PPI::Token::Quote::Interpolate')) { }
10 0 elsif ($is_heredoc) { }
444 12 49 if scalar @$unsafe_variables != 0
450 0 1 unless defined $lead
454 0 1 if $lead eq 'q'
456 1 0 if scalar @$unsafe_variables != 0
461 1 9 unless $str->interpolates
463 6 3 if scalar @$unsafe_variables != 0
474 19 74 defined $sql_injections ? :
485 0 100 unless defined $self->{'_sqlsafe'}
486 0 100 unless defined $line_number and $line_number =~ /\A\d+\Z/
491 58 42 unless exists $self->{'_sqlsafe'}{$line_number}
503 41 75 if defined $self->{'_sqlsafe'}
512 2 27 unless defined $safe_elements
529 74 42 unless (exists $self->{'_quoting_methods_regex'})
530 73 1 if ($self->{'_quoting_methods'} =~ /\w/) { }
543 74 42 unless (exists $self->{'_safe_functions_regex'})
544 1 73 if ($self->{'_safe_functions'} =~ /\w/) { }
557 74 42 unless (exists $self->{'_safe_context_regex'})
558 74 0 if ($self->{'_safe_context'} =~ /\w/) { }