lib/Perl/Critic/Policy/BuiltinFunctions/ProhibitSleepViaSelect.pm

filter: Statementstmt 79.4% 31 / 39 Branchbran 10.0% 1 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 80.0% 4 / 5 totaltotal 71.6% 48 / 67 CC 6 SCAR 23.1
CC
6
Cov
65%
violates
28.1
__ANON__
2.0
BEGIN
1.0
CRAP 10.1
« lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitCommaSeparatedStatements.pm ↑ Summary lib/Perl/Critic/Policy/Modules/ProhibitEvilModules.pm »
1 package Perl::Critic::Policy::BuiltinFunctions::ProhibitSleepViaSelect;
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 40 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 40 ▶use List::SomeUtils qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 40 ▶use Perl::Critic::Utils qw{ :severities :classification :ppi };
Subroutine BEGIN: called CC=1 SCAR=0.0
10 40 ▶use parent 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 40 our $VERSION = '1.156';
13  
14 #-----------------------------------------------------------------------------
15  
16 40 Readonly::Scalar my $DESC => q{"select" used to emulate "sleep"};
17 40 Readonly::Scalar my $EXPL => [168];
18 40 Readonly::Scalar my $SELECT_ARGUMENT_COUNT => 4;
19  
20 #-----------------------------------------------------------------------------
21  
22 90 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
23 74 ▶sub default_severity { return $SEVERITY_HIGHEST }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
24 91 ▶sub default_themes { return qw( core pbp bugs ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
25 37 ▶sub applies_to { return 'PPI::Token::Word' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
26  
27 #-----------------------------------------------------------------------------
28  
29 361 ▶sub violates {
Subroutine violates: called CC=6 SCAR=33.4
Pod documented
30 361 my ($self, $elem, undef) = @_;
31  
32 361 ▶ return if $elem->content() ne 'select';
Branch: 1 branch
BranchTrueFalseTotal
if $elem->content ne "select" 361 0 361
33 0 ▶ return if ! is_function_call($elem);
Branch: 1 branch
BranchTrueFalseTotal
unless is_function_call($elem) 0 0 0
34  
35 0 my @arguments = parse_arg_list($elem);
36 0 ▶ return if $SELECT_ARGUMENT_COUNT != @arguments;
Branch: 1 branch
BranchTrueFalseTotal
if $SELECT_ARGUMENT_COUNT != @arguments 0 0 0
37  
38 0 ▶ return if any { $_->[0] ne 'undef' } @arguments[0..2];
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if &any(sub { $_->[0] ne "undef"; } , @arguments[0..2]) 0 0 0
39  
40 0 ▶ if ( $arguments[-1]->[0] ne 'undef' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arguments[-1][0] ne "undef") 0 0 0
41 0 return $self->violation( $DESC, $EXPL, $elem );
42 }
43  
44 0 return; #ok!
45 }
46  
47 40 1;
48  
49 __END__
« lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitCommaSeparatedStatements.pm ↑ Summary lib/Perl/Critic/Policy/Modules/ProhibitEvilModules.pm »