| 1 | package Perl::Critic::Policy::logicLAB::ProhibitShellDispatch; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use base 'Perl::Critic::Policy'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Perl::Critic::Utils qw{ $SEVERITY_MEDIUM }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use 5.008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 4 | our $VERSION = '0.05'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 4 | Readonly::Scalar my $EXPL => q{Use Perl builtin instead}; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use constant supported_parameters => (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use constant default_severity => $SEVERITY_MEDIUM; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use constant default_themes => qw(logiclab); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 6 | ▶ | sub applies_to { | ||||||||||||||||||||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | return ( | ||||||||||||||||||||||||||||
| 20 | 6 | qw( | |||||||||||||||||||||||||||
| 21 | PPI::Statement | ||||||||||||||||||||||||||||
| 22 | PPI::Token::QuoteLike::Command | ||||||||||||||||||||||||||||
| 23 | PPI::Token::QuoteLike::Backtick | ||||||||||||||||||||||||||||
| 24 | ) | ||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 10 | ▶ | sub violates { | ||||||||||||||||||||||||||
|
Subroutine
violates: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 10 | my ( $self, $elem ) = @_; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | #first element PPI::Token::Word (system or exec) | ||||||||||||||||||||||||||||
| 32 | 10 | ▶ | if ( ref $elem eq 'PPI::Statement' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 7 | my $word = $elem->find_first('PPI::Token::Word'); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 7 | ▶ | if ( $word | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$word and $word =~ /
\A #beginning of string
(system|exec)
\Z #end of string
/msx
MC/DC100%2/2
$word and $word =~ /
\A #beginning of string
(system|exec)
\Z #end of string
/msx
$word
$word =~ /
\A #beginning of string
(system|exec)
\Z #end of string
/msx
Truth table100%3/3
A and B
A= $wordB= $word =~ /
\A #beginning of string
(system|exec)
\Z #end of string
/msx
| |||||||||||||||||||||||||||||
| 37 | and $word =~ m{ | ||||||||||||||||||||||||||||
| 38 | \A #beginning of string | ||||||||||||||||||||||||||||
| 39 | (system|exec) | ||||||||||||||||||||||||||||
| 40 | \Z #end of string | ||||||||||||||||||||||||||||
| 41 | }xsm | ||||||||||||||||||||||||||||
| 42 | ) | ||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | #previous significant sibling | ||||||||||||||||||||||||||||
| 46 | 3 | my $sibling = $word->sprevious_sibling; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 3 | ▶ | if ( $sibling and $sibling eq '->' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$sibling and $sibling eq "->"
MC/DC50%1/2
$sibling and $sibling eq "->"
$sibling
$sibling eq "->"
Truth table66%2/3
A and B
A= $siblingB= $sibling eq "->"
| |||||||||||||||||||||||||||||
| 49 | 1 | return; | |||||||||||||||||||||||||||
| 50 | } else { | ||||||||||||||||||||||||||||
| 51 | 2 | return $self->violation( | |||||||||||||||||||||||||||
| 52 | q{Do not use 'system' or 'exec' statements}, | ||||||||||||||||||||||||||||
| 53 | $EXPL, $elem ); | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | 4 | return; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 3 | ▶ | if ( ref $elem eq 'PPI::Token::QuoteLike::Command' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 1 | return $self->violation( q{Do not use 'qx' statements}, $EXPL, | |||||||||||||||||||||||||||
| 61 | $elem ); | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 2 | ▶ | if ( ref $elem eq 'PPI::Token::QuoteLike::Backtick' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 1 | return $self->violation( q{Do not use 'backticks' statements}, | |||||||||||||||||||||||||||
| 66 | $EXPL, $elem ); | ||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 1 | return; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 4 | 1; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | __END__ | ||||||||||||||||||||||||||||