File Coverage

blib/lib/Perl/Critic/Policy/Storable/ProhibitStoreOrFreeze.pm
Criterion Covered Total %
statement 20 21 95.2
branch 5 8 62.5
condition n/a
subroutine 7 8 87.5
pod 4 4 100.0
total 36 41 87.8


line stmt bran cond sub pod time code
1             package Perl::Critic::Policy::Storable::ProhibitStoreOrFreeze;
2              
3 1     1   257141 use strict;
  1         2  
  1         32  
4 1     1   5 use warnings;
  1         3  
  1         58  
5              
6 1     1   6 use Perl::Critic::Utils;
  1         5  
  1         26  
7 1     1   1688 use base qw( Perl::Critic::Policy );
  1         2  
  1         1186  
8              
9             our $VERSION = '0.01';
10              
11             my $DESCRIPTION = q{Use of store or freeze from Storable.pm};
12             my $EXPLANATION = q{Don't use store or freeze, use nstore or nfreeze instead.};
13              
14 6     6 1 69 sub default_severity { return $SEVERITY_MEDIUM } # What do we think?
15 0     0 1 0 sub default_themes { return qw(storable) }
16 12     12 1 104684 sub applies_to { return 'PPI::Token::Word' }
17              
18             sub violates {
19 12     12 1 277 my ( $self, $elem, $doc ) = @_;
20              
21 12 100       48 return if $elem !~ /^(?:Storable::)?(?:(?:lock_)?store|freeze)$/x;
22              
23 6 50       64 return if is_method_call( $elem );
24 6 50       236 return if is_hash_key( $elem );
25 6 50       509 return if is_subroutine_name( $elem );
26              
27 6         222 return $self->violation( $DESCRIPTION, $EXPLANATION, $elem );
28             }
29              
30             1;
31              
32             __END__
33              
34             =head1 NAME
35              
36             Perl::Critic::Policy::Storable::ProhibitStoreOrFreeze - do not use store or
37             freeze in Storable.pm
38              
39             =head1 VERSION
40              
41             version 0.01
42              
43             =head1 DESCRIPTION
44              
45             Imagine the scenario, you've got some Perl code running on a server that uses
46             Storable's freeze and thaw to serialise Perl data to and from a shared store.
47             The load on the server increases so you add another one to share the work. The
48             two of them are happily sharing the workload both reading and writing each
49             others serialised data, but then you need to add yet another server to handle
50             the load, but this one is a different hardware platform and bang, your Perl
51             code breaks.
52              
53             Why? Because you didn't use the network-aware nfreeze, nstore, or lock_nstore.
54              
55             =head1 AUTHOR
56              
57             Matt Dainty <matt@bodgit-n-scarper.com>
58              
59             =head1 COPYRIGHT
60              
61             Copyright (c) 2008 Matt Dainty.
62              
63             This program is free software; you can redistribute is and/or modify it under
64             the same terms as Perl itself.
65              
66             =cut