From: Shawn M Moore Date: Tue, 28 Apr 2009 08:25:01 +0000 (-0400) Subject: Better public-builder descriptions, including names! X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=336800ce224f268b960d923aa6d9af4e2bebde12;p=gitmo%2FPerl-Critic-Dynamic-Moose.git Better public-builder descriptions, including names! --- diff --git a/lib/Perl/Critic/Policy/DynamicMoose/ProhibitPublicBuilders.pm b/lib/Perl/Critic/Policy/DynamicMoose/ProhibitPublicBuilders.pm index c6003fa..03bb8f6 100644 --- a/lib/Perl/Critic/Policy/DynamicMoose/ProhibitPublicBuilders.pm +++ b/lib/Perl/Critic/Policy/DynamicMoose/ProhibitPublicBuilders.pm @@ -2,13 +2,14 @@ package Perl::Critic::Policy::DynamicMoose::ProhibitPublicBuilders; use Moose; extends 'Perl::Critic::Policy::DynamicMoose'; -Readonly::Scalar my $DESC => q{Builder method name without a leading underscore}; Readonly::Scalar my $EXPL => q{Prefix builder method names with an underscore}; sub violates_metaclass { my $self = shift; my $meta = shift; + my $classname = $meta->name; + my @violations; my $attributes = $meta->get_attribute_map; @@ -17,8 +18,11 @@ sub violates_metaclass { next if !$attribute->has_builder; - if ($attribute->builder !~ /^_/) { - push @violations, $self->violation($DESC, $EXPL); + my $builder = $attribute->builder; + + if ($builder !~ /^_/) { + my $desc = "Builder method '$builder' of attribute '$attribute' of class '$classname' is public"; + push @violations, $self->violation($desc, $EXPL); } }