1 package Perl::Critic::Policy::DynamicMoose::ProhibitPublicBuilders;
3 extends 'Perl::Critic::Policy::DynamicMoose';
5 Readonly::Scalar my $EXPL => q{Prefix builder method names with an underscore};
7 sub violates_metaclass {
11 my $classname = $meta->name;
15 my $attributes = $meta->get_attribute_map;
16 for my $name (keys %$attributes) {
17 my $attribute = $attributes->{$name};
19 next if !$attribute->has_builder;
21 my $builder = $attribute->builder;
23 if ($builder !~ /^_/) {
24 my $desc = "Builder method '$builder' of attribute '$attribute' of class '$classname' is public";
25 push @violations, $self->violation($desc, $EXPL);