« blib/lib/Perl/Critic/Policy/Modules/ProhibitExcessMainComplexity.pm
↑ Summary
blib/lib/Perl/Critic/Policy/ClassHierarchies/ProhibitExplicitISA.pm »
| 1 | package Perl::Critic::Policy::ClassHierarchies::ProhibitAutoloading; | ||||||||||
| 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.150'; | |||||||||
| 12 | |||||||||||
| 13 | #----------------------------------------------------------------------------- | ||||||||||
| 14 | |||||||||||
| 15 | 40 | Readonly::Scalar my $DESC => q{AUTOLOAD method declared}; | |||||||||
| 16 | 40 | Readonly::Scalar my $EXPL => [ 393 ]; | |||||||||
| 17 | |||||||||||
| 18 | #----------------------------------------------------------------------------- | ||||||||||
| 19 | |||||||||||
| 20 | 90 | ▶ | sub supported_parameters { return () } | ||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 21 | 74 | ▶ | sub default_severity { return $SEVERITY_MEDIUM } | ||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 22 | 86 | ▶ | sub default_themes { return qw( core maintenance pbp ) } | ||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 23 | 31 | ▶ | sub applies_to { return 'PPI::Statement::Sub' } | ||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 24 | |||||||||||
| 25 | #----------------------------------------------------------------------------- | ||||||||||
| 26 | |||||||||||
| 27 | sub violates { | ||||||||||
| 28 | 5 | ▶ | my ($self, $elem, undef) = @_; | ||||||||
|
Subroutine
violates: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||
| 29 | |||||||||||
| 30 | 5 | ▶ | if( $elem->name eq 'AUTOLOAD' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | return $self->violation( $DESC, $EXPL, $elem ); | |||||||||
| 32 | } | ||||||||||
| 33 | 5 | return; #ok! | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 40 | 1; | |||||||||
| 37 | |||||||||||
| 38 | #----------------------------------------------------------------------------- | ||||||||||
| 39 | |||||||||||
| 40 | __END__ | ||||||||||
| 41 | |||||||||||
| 42 | =pod | ||||||||||
| 43 | |||||||||||
| 44 | =head1 NAME | ||||||||||
| 45 | |||||||||||
| 46 | Perl::Critic::Policy::ClassHierarchies::ProhibitAutoloading - AUTOLOAD methods should be avoided. | ||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | =head1 AFFILIATION | ||||||||||
| 50 | |||||||||||
| 51 | This Policy is part of the core L<Perl::Critic|Perl::Critic> | ||||||||||
| 52 | distribution. | ||||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | =head1 DESCRIPTION | ||||||||||
| 56 | |||||||||||
| 57 | Declaring a subroutine with the name C<"AUTOLOAD"> will violate this | ||||||||||
| 58 | Policy. The C<AUTOLOAD> mechanism is an easy way to generate methods | ||||||||||
| 59 | for your classes, but unless they are carefully written, those classes | ||||||||||
| 60 | are difficult to inherit from. And over time, the C<AUTOLOAD> method | ||||||||||
| 61 | will become more and more complex as it becomes responsible for | ||||||||||
| 62 | dispatching more and more functions. You're better off writing | ||||||||||
| 63 | explicit accessor methods. Editor macros can help make this a little | ||||||||||
| 64 | easier. | ||||||||||
| 65 | |||||||||||
| 66 | |||||||||||
| 67 | =head1 CONFIGURATION | ||||||||||
| 68 | |||||||||||
| 69 | This Policy is not configurable except for the standard options. | ||||||||||
| 70 | |||||||||||
| 71 | |||||||||||
| 72 | =head1 AUTHOR | ||||||||||
| 73 | |||||||||||
| 74 | Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> | ||||||||||
| 75 | |||||||||||
| 76 | |||||||||||
| 77 | =head1 COPYRIGHT | ||||||||||
| 78 | |||||||||||
| 79 | Copyright (c) 2006-2011 Imaginative Software Systems. All rights reserved. | ||||||||||
| 80 | |||||||||||
| 81 | This program is free software; you can redistribute it and/or modify | ||||||||||
| 82 | it under the same terms as Perl itself. | ||||||||||
| 83 | |||||||||||
| 84 | =cut | ||||||||||
| 85 | |||||||||||
| 86 | # Local Variables: | ||||||||||
| 87 | # mode: cperl | ||||||||||
| 88 | # cperl-indent-level: 4 | ||||||||||
| 89 | # fill-column: 78 | ||||||||||
| 90 | # indent-tabs-mode: nil | ||||||||||
| 91 | # c-indentation-style: bsd | ||||||||||
| 92 | # End: | ||||||||||
| 93 | # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : | ||||||||||