X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FPerl%2FCritic%2FPolicy%2FDynamicMoose%2FProhibitPublicBuilders.pm;h=afa82159e904ef06195312e2463df78cd3adf147;hb=501e8f35f8ff75c77860a52ffd5db93085e4ee90;hp=27a6011d52ea2d4f8d50711ca48f78b938719b3a;hpb=e3f2864cbcd6d2d10accce1c5c5dc482faa4ce48;p=gitmo%2FPerl-Critic-Dynamic-Moose.git diff --git a/lib/Perl/Critic/Policy/DynamicMoose/ProhibitPublicBuilders.pm b/lib/Perl/Critic/Policy/DynamicMoose/ProhibitPublicBuilders.pm index 27a6011..afa8215 100644 --- a/lib/Perl/Critic/Policy/DynamicMoose/ProhibitPublicBuilders.pm +++ b/lib/Perl/Critic/Policy/DynamicMoose/ProhibitPublicBuilders.pm @@ -18,9 +18,8 @@ sub violates_metaclass { my @violations; - my $attributes = $meta->get_attribute_map; - for my $name (keys %$attributes) { - my $attribute = $attributes->{$name}; + for my $name ($meta->get_attribute_list) { + my $attribute = $meta->get_attribute($name); my $builder; if (blessed($attribute)) { @@ -47,3 +46,37 @@ no Moose; 1; +__END__ + +=head1 NAME + +Perl::Critic::Policy::DynamicMoose::ProhibitPublicBuilders + +=head1 DESCRIPTION + +An attribute's L method is used to provide a default value +for that attribute. Such methods are rarely intended for external use, and +should not be considered part of that class's public API. Thus we recommend +that your attribute builder methods' names are prefixed with an underscore +to mark them private. + +=head1 WARNING + +B Most L Policies (including all the ones that +ship with Perl::Critic> use pure static analysis -- they never compile nor +execute any of the code that they analyze. However, this policy is very +different. It actually attempts to compile your code and then compares the +subroutines mentioned in your code to those found in the symbol table. +Therefore you should B use this Policy on any code that you do not trust, +or may have undesirable side-effects at compile-time (such as connecting to the +network or mutating files). + +For this Policy to work, all the modules included in your code must be +installed locally, and must compile without error. + +=head1 AUTHOR + +Shawn M Moore, C + +=cut +