lib/Perl/Critic/Policy/Modules/RequireEndWithOne.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 4 / 4 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 13 / 13 Podpod 83.3% 5 / 6 totaltotal 92.7% 64 / 69 CC 5 SCAR 6.2
CC
5
Cov
96%
violates
4.0
_is_code
2.3
BEGIN
1.0
CRAP 1.9
« lib/Perl/Critic/Policy/ValuesAndExpressions/RequireNumberSeparators.pm ↑ Summary lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitSpecialLiteralHeredocTerminator.pm »
1 package Perl::Critic::Policy::Modules::RequireEndWithOne;
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 Perl::Critic::Utils qw{ :severities :classification };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 40 ▶use parent 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 40 our $VERSION = '1.156';
12  
13 #-----------------------------------------------------------------------------
14  
15 40 Readonly::Scalar my $EXPL => q{Must end with a recognizable true value};
16 40 Readonly::Scalar my $DESC => q{Module does not end with "1;"};
17  
18 #-----------------------------------------------------------------------------
19  
20 90 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
21 80 ▶sub default_severity { return $SEVERITY_HIGH }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
22 91 ▶sub default_themes { return qw( core bugs pbp certrule ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
23 32 ▶sub applies_to { return 'PPI::Document' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
24  
25 #-----------------------------------------------------------------------------
26  
27 33 ▶sub prepare_to_scan_document {
Subroutine prepare_to_scan_document: called CC=1 SCAR=0.0
Pod documented
28 33 my ( undef, $document ) = @_;
29  
30 33 return $document->is_module(); # Must be a library or module.
31 }
32  
33 32 ▶sub violates {
Subroutine violates: called CC=4 SCAR=13.9
Pod documented
34 32 my ( $self, undef, $doc ) = @_;
35  
36 # Last statement should be just "1;"
37 32 my @significant = grep { _is_code($_) } $doc->schildren();
38 32 my $match = $significant[-1];
39 32 ▶ return if !$match;
Branch: 1 branch
BranchTrueFalseTotal
unless $match 2 30 32
40 30 ▶ return if ((ref $match) eq 'PPI::Statement' &&
Branch: 1 branch
BranchTrueFalseTotal
if ref $match eq "PPI::Statement" and $match =~ /\A 1 \s* ; \z/msx 24 6 30
Condition100%3/3
ref $match eq "PPI::Statement" and $match =~ /\A 1 \s* ; \z/msx
!ll&&!rl&&r
5124
MC/DC100%2/2
ref $match eq "PPI::Statement" and $match =~ /\A 1 \s* ; \z/msx
ref $match eq "PPI::Statement" $match =~ /\A 1 \s* ; \z/msx
Truth table100%3/3
A and B
A= ref $match eq "PPI::Statement"B= $match =~ /\A 1 \s* ; \z/msx
ABresult
0X0
100
111
41 $match =~ m{\A 1 \s* ; \z}xms );
42  
43 # Must be a violation...
44 6 return $self->violation( $DESC, $EXPL, $match );
45 }
46  
47 247 ▶sub _is_code {
Subroutine _is_code: called CC=2 SCAR=8.1
48 247 my $elem = shift;
49 247 ▶ return ! ( $elem->isa('PPI::Statement::End')
Condition33%1/3
$elem->isa('PPI::Statement::End') || $elem->isa('PPI::Statement::Data')
l!l&&r!l&&!r
00247
MC/DC0%0/2
$elem->isa('PPI::Statement::End') || $elem->isa('PPI::Statement::Data')
$elem->isa('PPI::Statement::End') $elem->isa('PPI::Statement::Data')
Truth table33%1/3
A || B
A= $elem->isa('PPI::Statement::End')B= $elem->isa('PPI::Statement::Data')
ABresult
1X1
011
000
50 || $elem->isa('PPI::Statement::Data'));
51 }
52  
53 40 1;
54  
55 __END__
« lib/Perl/Critic/Policy/ValuesAndExpressions/RequireNumberSeparators.pm ↑ Summary lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitSpecialLiteralHeredocTerminator.pm »