File Coverage

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