1 package Perl::Critic::Policy::DynamicMoose::RequireMakeImmutable;
3 extends 'Perl::Critic::Policy::DynamicMoose';
5 use Perl::Critic::Utils ':severities';
6 use Perl::Critic::Utils::Moose 'meta_type';
8 Readonly::Scalar my $EXPL => q{Moose can't optimize itself if classes remain mutable.};
9 sub default_severity { $SEVERITY_HIGH }
11 sub violates_metaclass {
15 return if $meta->is_immutable;
17 my $desc = "The " . $meta->name . " " . meta_type($meta) . " was not made immutable.";
19 return $self->violation($desc, $EXPL);
30 Perl::Critic::Policy::DynamicMoose::RequireMakeImmutable
37 B<VERY IMPORTANT:> Most L<Perl::Critic> Policies (including all the ones that
38 ship with Perl::Critic> use pure static analysis -- they never compile nor
39 execute any of the code that they analyze. However, this policy is very
40 different. It actually attempts to compile your code and then compares the
41 subroutines mentioned in your code to those found in the symbol table.
42 Therefore you should B<not> use this Policy on any code that you do not trust,
43 or may have undesirable side-effects at compile-time (such as connecting to the
44 network or mutating files).
46 For this Policy to work, all the modules included in your code must be
47 installed locally, and must compile without error.
51 Shawn M Moore, C<sartak@bestpractical.com>