lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitVersionStrings.pm

filter: Statementstmt 97.0% 33 / 34 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 80.0% 4 / 5 totaltotal 93.1% 54 / 58 CC 5 SCAR 8.7
CC
5
Cov
93%
violates
5.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« lib/Perl/Critic/Policy/Variables/ProhibitAugmentedAssignmentInDeclaration.pm ↑ Summary lib/Perl/Critic/Exception/Configuration/Option/Policy/ParameterValue.pm »
1 package Perl::Critic::Policy::ValuesAndExpressions::ProhibitVersionStrings;
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 };
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 $DESC => q{Version string used};
16 40 Readonly::Scalar my $EXPL => q{Use a real number instead};
17  
18 #-----------------------------------------------------------------------------
19  
20 90 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
21 74 ▶sub default_severity { return $SEVERITY_MEDIUM }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
22 85 ▶sub default_themes { return qw(core pbp maintenance) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
23 31 ▶sub applies_to { return 'PPI::Statement::Include' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
24  
25 #-----------------------------------------------------------------------------
26  
27 57 ▶sub violates {
Subroutine violates: called CC=5 SCAR=16.4
Pod documented
28 57 my ($self, $elem, undef) = @_;
29  
30 57 my $version;
31  
32 57 ▶ if ( my $module = $elem->module() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $module = $elem->module) { } 55 2 57
33 55 ▶ return if $module eq 'lib';
Branch: 1 branch
BranchTrueFalseTotal
if $module eq "lib" 0 55 55
34  
35 55 $version = $elem->module_version();
36 } else {
37 2 $version = $elem->schild(1);
38 }
39  
40 57 ▶ return if not defined $version;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version 55 2 57
41 2 ▶ return if not $version->isa('PPI::Token::Number::Version');
Branch: 1 branch
BranchTrueFalseTotal
unless $version->isa("PPI::Token::Number::Version") 2 0 2
42  
43 0 return $self->violation($DESC, $EXPL, $elem);
44 }
45  
46 40 1;
47  
48 __END__
« lib/Perl/Critic/Policy/Variables/ProhibitAugmentedAssignmentInDeclaration.pm ↑ Summary lib/Perl/Critic/Exception/Configuration/Option/Policy/ParameterValue.pm »