Policy/ErrorHandling/RequireUseOfExceptions.pm

filter: Statementstmt 100% 28 / 28 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 80.0% 4 / 5 totaltotal 97.9% 47 / 48 CC 3 SCAR 3.8
CC
3
Cov
100%
violates
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« Policy/CodeLayout/RequireASCII.pm ↑ Summary More.pm »
1 ##############################################################################
2 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/Perl-Critic-More/lib/Perl/Critic/Policy/ErrorHandling/RequireUseOfExceptions.pm $
3 # $Date: 2013-10-29 09:39:11 -0700 (Tue, 29 Oct 2013) $
4 # $Author: thaljef $
5 # $Revision: 4222 $
6 ##############################################################################
7  
8 package Perl::Critic::Policy::ErrorHandling::RequireUseOfExceptions;
9  
10 7 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 7 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 7 ▶use Perl::Critic::Utils qw{ :severities :classification :data_conversion };
Subroutine BEGIN: called CC=1 SCAR=0.0
18 7 ▶use base 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 7 our $VERSION = '1.003';
21  
22 #-----------------------------------------------------------------------------
23  
24 10 ▶sub default_severity { return $SEVERITY_HIGH }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
25 1 ▶sub default_themes { return qw< more maintenance > }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
26 2 ▶sub applies_to { return 'PPI::Token::Word' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
27 3 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
28  
29 #-----------------------------------------------------------------------------
30  
31 7 Readonly::Hash my %FATAL_FUNCTIONS => hashify(qw< die croak confess >);
32  
33 33 ▶sub violates {
Subroutine violates: called CC=3 SCAR=11.0
Pod documented
34 33 my ( $self, $elem, undef ) = @_;
35  
36 33 ▶ return if not exists $FATAL_FUNCTIONS{$elem};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $FATAL_FUNCTIONS{$elem} 15 18 33
37  
38 18 ▶ return if not is_function_call($elem);
Branch: 1 branch
BranchTrueFalseTotal
unless is_function_call($elem) 9 9 18
39  
40 9 return $self->violation(
41 "Found use of $elem. Use an exception instead.",
42 'Exception objects should be used instead of the standard Perl error mechanism.',
43 $elem,
44 );
45 }
46  
47 7 1;
48  
49 __END__
« Policy/CodeLayout/RequireASCII.pm ↑ Summary More.pm »