File Coverage

blib/lib/Perl/Critic/Policy/Community/ModPerl.pm
Criterion Covered Total %
statement 23 25 92.0
branch 1 2 50.0
condition 1 2 50.0
subroutine 10 11 90.9
pod 4 5 80.0
total 39 45 86.6


line stmt bran cond sub pod time code
1              
2             use strict;
3 1     1   356 use warnings;
  1         1  
  1         23  
4 1     1   6  
  1         2  
  1         23  
5             use Perl::Critic::Utils qw(:severities :classification :ppi);
6 1     1   4 use parent 'Perl::Critic::Policy';
  1         1  
  1         42  
7 1     1   301  
  1         1  
  1         5  
8             our $VERSION = 'v1.0.3';
9              
10             use constant DESC => 'Using mod_perl';
11 1     1   65 use constant EXPL => 'mod_perl is not designed for writing Perl web applications. Try a Plack-based framework (Web::Simple, Dancer2, Catalyst) or Mojolicious for a modern approach.';
  1         2  
  1         45  
12 1     1   5  
  1         2  
  1         169  
13              
14 3     3 0 85064 my %modules = (
15 8     8 1 246 'Apache' => 1,
16 0     0 1 0 'Apache::Constants' => 1,
17 3     3 1 16901 'Apache::Registry' => 1,
18             'Apache::Request' => 1,
19             'Apache2::Const' => 1,
20             'Apache2::Request' => 1,
21             'ModPerl::Const' => 1,
22             'ModPerl::Registry' => 1,
23             );
24              
25             my ($self, $elem) = @_;
26             return $self->violation(DESC, EXPL, $elem) if exists $modules{$elem->module//''};
27             return ();
28             }
29              
30             1;
31 8     8 1 961  
32 8 50 50     23 =head1 NAME
33 0            
34             Perl::Critic::Policy::Community::ModPerl - Don't use mod_perl to write web
35             applications
36              
37             =head1 DESCRIPTION
38              
39             L<mod_perl|http://perl.apache.org/> is an embedded Perl interpreter for the
40             L<Apache|http://www.apache.org/> web server. It allows you to dynamically
41             configure and mod Apache. It is not a generally good solution for writing web
42             applications. Frameworks using L<Plack> (L<Web::Simple>, L<Dancer2>,
43             L<Catalyst>) and L<Mojolicious> are much more flexible, powerful, and stable.
44             A web application written in one of these frameworks can be deployed using a
45             Perl HTTP server such as L<Starman> or L<Mojo::Server::Hypnotoad>; by proxy
46             from Apache or nginx; or even run as if they were regular CGI scripts.
47              
48             =head1 AFFILIATION
49              
50             This policy is part of L<Perl::Critic::Community>.
51              
52             =head1 CONFIGURATION
53              
54             This policy is not configurable except for the standard options.
55              
56             =head1 AUTHOR
57              
58             Dan Book, C<dbook@cpan.org>
59              
60             =head1 COPYRIGHT AND LICENSE
61              
62             Copyright 2015, Dan Book.
63              
64             This library is free software; you may redistribute it and/or modify it under
65             the terms of the Artistic License version 2.0.
66              
67             =head1 SEE ALSO
68              
69             L<Perl::Critic>