Utils/_Common.pm

filter: Statementstmt 89.2% 25 / 28 Branchbran 58.3% 7 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 2 totaltotal 77.0% 37 / 48 CC 7 SCAR 16.9
CC
7
Cov
80%
is_ppi_simple_statement
12.0
is_ppi_expression_or_generic_statement
5.0
BEGIN
1.0
CRAP 5.4
« Utils/Classification.pm ↑ Summary Utils.pm »
1 package PPIx::Utils::_Common;
2 # See the README of this distribution for copyright and license information.
3  
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Scalar::Util 'blessed';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 our $VERSION = '0.002';
10  
11 3 our @EXPORT_OK = qw(
12 is_ppi_expression_or_generic_statement
13 is_ppi_simple_statement
14 );
15  
16 3 our %EXPORT_TAGS = (all => [@EXPORT_OK]);
17  
18 # From Perl::Critic::Utils::PPI
19 sub is_ppi_expression_or_generic_statement {
20 19 ▶ my $element = shift;
Subroutine is_ppi_expression_or_generic_statement: called CC=5 SCAR=16.1
Pod undocumented
21  
22 19 ▶ return undef if not $element;
Branch: 1 branch
BranchTrueFalseTotal
unless $element 1 18 19
23 18 ▶ return undef if not $element->isa('PPI::Statement');
Branch: 1 branch
BranchTrueFalseTotal
unless $element->isa("PPI::Statement") 1 17 18
24 17 ▶ return 1 if $element->isa('PPI::Statement::Expression');
Branch: 1 branch
BranchTrueFalseTotal
if $element->isa("PPI::Statement::Expression") 3 14 17
25  
26 14 my $element_class = blessed($element);
27  
28 14 ▶ return undef if not $element_class;
Branch: 1 branch
BranchTrueFalseTotal
unless $element_class 0 14 14
29 14 return $element_class eq 'PPI::Statement';
30 }
31  
32 3 my %SIMPLE_STATEMENT_CLASS = map { $_ => 1 } qw<
33 PPI::Statement
34 PPI::Statement::Break
35 PPI::Statement::Include
36 PPI::Statement::Null
37 PPI::Statement::Package
38 PPI::Statement::Variable
39 >;
40  
41 sub is_ppi_simple_statement {
42 0 ▶ my $element = shift or return undef;
Subroutine is_ppi_simple_statement: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $element = shift() or return undef 0 0 0
43  
44 0 ▶ my $element_class = blessed( $element ) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $element_class = builtin::blessed($element) or return undef 0 0 0
45  
46 0 return $SIMPLE_STATEMENT_CLASS{ $element_class };
47 }
48 # End from Perl::Critic::Utils::PPI
49  
50 3 1;
51  
52 =for Pod::Coverage *EVERYTHING*
53  
54 =cut
« Utils/Classification.pm ↑ Summary Utils.pm »