1 ##############################################################################
2 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/NamingConventions/ProhibitMixedCaseSubs.pm $
3 # $Date: 2008-07-03 10:19:10 -0500 (Thu, 03 Jul 2008) $
6 ##############################################################################
8 package Perl::Critic::Policy::NamingConventions::ProhibitMixedCaseSubs;
15 use Perl::Critic::Utils qw{ :severities };
17 use base 'Perl::Critic::Policy';
19 our $VERSION = '1.088';
21 #-----------------------------------------------------------------------------
23 Readonly::Scalar my $UPPER_LOWER => qr/ [[:upper:]] [[:lower:]] /xm;
24 Readonly::Scalar my $LOWER_UPPER => qr/ [[:lower:]] [[:upper:]] /xm;
25 Readonly::Scalar my $MIXED_RX => qr{ $UPPER_LOWER | $LOWER_UPPER }xmo;
26 Readonly::Scalar my $DESC => 'Mixed-case subroutine name';
27 Readonly::Scalar my $EXPL => [ 44 ];
29 #-----------------------------------------------------------------------------
31 sub supported_parameters { return () }
32 sub default_severity { return $SEVERITY_LOWEST }
33 sub default_themes { return qw( core pbp cosmetic ) }
34 sub applies_to { return 'PPI::Statement::Sub' }
36 #-----------------------------------------------------------------------------
39 my ( $self, $elem, undef ) = @_;
40 (my $name = $elem->name() ) =~ s/\A.*:://mx;
41 if ( $name =~ m/$MIXED_RX/xms ) {
42 return $self->violation( $DESC, $EXPL, $elem );
51 #-----------------------------------------------------------------------------
57 Perl::Critic::Policy::NamingConventions::ProhibitMixedCaseSubs - Write C<sub my_function{}> instead of C<sub MyFunction{}>.
61 This Policy is part of the core L<Perl::Critic> distribution.
66 Conway's recommended naming convention is to use lower-case words
67 separated by underscores. Well-recognized acronyms can be in ALL
68 CAPS, but must be separated by underscores from other parts of the
76 sub Some::Class::foo{} #ok, grudgingly
86 This Policy is not configurable except for the standard options.
91 L<Perl::Critic::Policy::NamingConventions::ProhibitMixedCaseVars>
95 Jeffrey Ryan Thalhammer <thaljef@cpan.org>
99 Copyright (c) 2005-2008 Jeffrey Ryan Thalhammer. All rights reserved.
101 This program is free software; you can redistribute it and/or modify
102 it under the same terms as Perl itself. The full text of this license
103 can be found in the LICENSE file included with this module.
109 # cperl-indent-level: 4
111 # indent-tabs-mode: nil
112 # c-indentation-style: bsd
114 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :