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

filter: Statementstmt 100% 32 / 32 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 80.0% 4 / 5 totaltotal 94.4% 51 / 54 CC 4 SCAR 6.3
CC
4
Cov
95%
violates
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« lib/Perl/Critic/Policy/ControlStructures/ProhibitDeepNests.pm ↑ Summary lib/Perl/Critic/Policy/Modules/RequireEndWithOne.pm »
1 package Perl::Critic::Policy::ValuesAndExpressions::RequireNumberSeparators;
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{Long number not separated with underscores};
16 40 Readonly::Scalar my $EXPL => [ 59 ];
17  
18 #-----------------------------------------------------------------------------
19  
20 40 Readonly::Scalar my $MINIMUM_INTEGER_WITH_MULTIPLE_DIGITS => 10;
21  
22 91 ▶sub supported_parameters {
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
23 return (
24 {
25 91 name => 'min_value',
26 description => 'The minimum absolute value to require separators in.',
27 default_string => '10_000',
28 behavior => 'integer',
29 integer_minimum => $MINIMUM_INTEGER_WITH_MULTIPLE_DIGITS,
30 },
31 );
32 }
33  
34 88 ▶sub default_severity { return $SEVERITY_LOW }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
35 83 ▶sub default_themes { return qw( core pbp cosmetic ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
36 31 ▶sub applies_to { return 'PPI::Token::Number' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
37  
38 #-----------------------------------------------------------------------------
39  
40 78 ▶sub violates {
Subroutine violates: called CC=4 SCAR=14.0
Pod documented
41 78 my ( $self, $elem, undef ) = @_;
42  
43 78 ▶ return if $elem->isa( 'PPI::Token::Number::Version' ); # GitHub #856
Branch: 1 branch
BranchTrueFalseTotal
if $elem->isa("PPI::Token::Number::Version") 0 78 78
44  
45 78 my $min = $self->{_min_value};
46  
47 78 ▶ return if $elem !~ m{ \d{4} }xms;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem =~ / \d{4} /msx 64 14 78
48 14 ▶ return if abs $elem->literal() < $min;
Branch: 1 branch
BranchTrueFalseTotal
if abs $elem->literal < $min 0 14 14
49  
50 14 return $self->violation( $DESC, $EXPL, $elem );
51 }
52  
53 40 1;
54  
55 __END__
« lib/Perl/Critic/Policy/ControlStructures/ProhibitDeepNests.pm ↑ Summary lib/Perl/Critic/Policy/Modules/RequireEndWithOne.pm »