lib/Perl/ToPerl6/Transformer/Pragmas/RewritePragmas.pm

filter: Statementstmt 90.6% 29 / 32 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 92.3% 12 / 13 Podpod 60.0% 3 / 5 totaltotal 78.6% 48 / 61 CC 4 SCAR 7.7
CC
4
Cov
82%
__ANON__
5.4
transform
2.0
applies_to
1.1
CRAP 2.2
« lib/Perl/ToPerl6/Exception/Configuration/Option/Global/ParameterValue.pm ↑ Summary lib/Perl/ToPerl6/Transformer.pm »
1 package Perl::ToPerl6::Transformer::Pragmas::RewritePragmas;
2  
3 17 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 17 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 17 ▶use Perl::ToPerl6::Utils qw{ :severities };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 17 ▶use Perl::ToPerl6::Utils::PPI qw{ is_version_number is_pragma };
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 17 ▶use base 'Perl::ToPerl6::Transformer';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 #-----------------------------------------------------------------------------
14  
15 17 Readonly::Scalar my $DESC => q{Delete unnecessary pragmas};
16 17 Readonly::Scalar my $EXPL =>
17 q{Pragmas such as 'strict', 'warnings', 'utf8' and 'version' are unnecessary or redundant};
18  
19 #-----------------------------------------------------------------------------
20  
21 17 my %map = (
22 v6 => 1,
23 constant => 1, # 'use constant FOO => 1' --> 'constant FOO = 1' later
24 base => 1, # 'use base "Foo::Mommy' --> 'class Foo is Foo::Mommy' later
25 parent => 1, # 'use parent "Foo::Mommy' --> 'class Foo is Foo::Mommy' later
26 );
27  
28 #-----------------------------------------------------------------------------
29  
30 38 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
31 26 ▶sub default_necessity { return $NECESSITY_HIGHEST }
Subroutine default_necessity: called CC=1 SCAR=0.0
Pod documented
32 24 ▶sub default_themes { return qw( core ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
33 5 ▶sub applies_to {
Subroutine applies_to: called CC=1 SCAR=0.6
Pod documented
34 74 ▶ return sub {
Subroutine __ANON__: called CC=4 SCAR=16.9
35 $_[1]->isa('PPI::Statement::Include') and
36 ( is_version_number($_[1]->child(2)) or
37 is_pragma($_[1]->child(2)) ) and
38 74 ▶ not exists $map{$_[1]->child(2)->content}
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Include") and is_version_number($_[1]->child(2)) || is_pragma($_[1]->child(2)) and not exists $map{$_[1]->child(2)->content} 0 74 74
Condition50%3/6
$_[1]->isa("PPI::Statement::Include") and is_version_number($_[1]->child(2)) || is_pragma($_[1]->child(2))
!ll&&!rl&&r
7310
is_version_number($_[1]->child(2)) or is_pragma($_[1]->child(2))
l!l&&r!l&&!r
001
MC/DC0%0/3
$_[1]->isa("PPI::Statement::Include") and is_version_number($_[1]->child(2)) || is_pragma($_[1]->child(2))
$_[1]->isa("PPI::Statement::Include") is_version_number($_[1]->child(2)) is_pragma($_[1]->child(2))
Truth table50%2/4
A and B or C
A= $_[1]->isa("PPI::Statement::Include")B= is_version_number($_[1]->child(2))C= is_pragma($_[1]->child(2))
ABCresult
0XX0
1000
11X1
1011
39 }
40 5 }
41  
42 #-----------------------------------------------------------------------------
43  
44 #
45 # 'use strict;' --> ''
46 # 'use warnings;' --> ''
47 # 'no strict;' --> ''
48 # 'no warnings;' --> ''
49 # 'use 5.6;' --> ''
50 # 'use v6;' --> 'use v6;'
51 # 'use constant;' --> 'use constant;'
52 #
53 0 ▶sub transform {
Subroutine transform: not called CC=1 SCAR=6.9
Pod undocumented
54 0 my ($self, $elem, $doc) = @_;
55  
56 0 $elem->remove;
57  
58 0 return $self->transformation( $DESC, $EXPL, $elem );
59 }
60  
61 17 1;
62  
63 #-----------------------------------------------------------------------------
64  
65 __END__
« lib/Perl/ToPerl6/Exception/Configuration/Option/Global/ParameterValue.pm ↑ Summary lib/Perl/ToPerl6/Transformer.pm »