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

filter: Statementstmt 87.5% 28 / 32 Branchbran 37.5% 3 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 80.0% 4 / 5 totaltotal 82.1% 46 / 56 CC 5 SCAR 14.2
CC
5
Cov
78%
violates
10.4
BEGIN
1.0
BEGIN
1.0
CRAP 4.1
« lib/Perl/Critic/Policy/Modules/RequireExplicitPackage.pm ↑ Summary lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitInterpolationOfLiterals.pm »
1 package Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep;
2  
3 # DEVELOPER NOTE: this module is used as an example in DEVELOPER.pod.
4 # If you make changes in here, please reflect those changes in the
5 # examples.
6  
7 40 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 40 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 40 ▶use Perl::Critic::Utils qw{ :severities :classification :ppi };
Subroutine BEGIN: called CC=1 SCAR=0.0
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 => q{Expression form of "grep"};
20 40 Readonly::Scalar my $EXPL => [ 169 ];
21  
22 #-----------------------------------------------------------------------------
23  
24 90 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
25 73 ▶sub default_severity { return $SEVERITY_HIGH }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
26 91 ▶sub default_themes { return qw( core bugs pbp ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
27 33 ▶sub applies_to { return 'PPI::Token::Word' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
28  
29 #-----------------------------------------------------------------------------
30  
31 349 ▶sub violates {
Subroutine violates: called CC=5 SCAR=23.4
Pod documented
32 349 my ( $self, $elem, undef ) = @_;
33  
34 349 ▶ return if $elem->content() ne 'grep';
Branch: 1 branch
BranchTrueFalseTotal
if $elem->content ne "grep" 346 3 349
35 3 ▶ return if ! is_function_call($elem);
Branch: 1 branch
BranchTrueFalseTotal
unless is_function_call($elem) 3 0 3
36  
37 0 my $arg = first_arg($elem);
38 0 ▶ return if !$arg;
Branch: 1 branch
BranchTrueFalseTotal
unless $arg 0 0 0
39 0 ▶ return if $arg->isa('PPI::Structure::Block');
Branch: 1 branch
BranchTrueFalseTotal
if $arg->isa("PPI::Structure::Block") 0 0 0
40  
41 0 return $self->violation( $DESC, $EXPL, $elem );
42 }
43  
44 40 1;
45  
46 __END__
« lib/Perl/Critic/Policy/Modules/RequireExplicitPackage.pm ↑ Summary lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitInterpolationOfLiterals.pm »