Finish renaming
[gitmo/Perl-Critic-Dynamic-Moose.git] / lib / Perl / Critic / Policy / DynamicMoose / RequireMakeImmutable.pm
1 package Perl::Critic::Policy::DynamicMoose::RequireMakeImmutable;
2 use Moose;
3 extends 'Perl::Critic::DynamicMoosePolicy';
4
5 use Perl::Critic::Utils ':severities';
6 use Perl::Critic::Utils::Moose 'meta_type';
7
8 Readonly::Scalar my $EXPL => q{Moose can't optimize itself if classes remain mutable.};
9 sub default_severity { $SEVERITY_HIGH }
10
11 sub violates_metaclass {
12     my $self = shift;
13     my $meta = shift;
14
15     return if $meta->is_immutable;
16
17     my $desc = "The " . $meta->name . " " . meta_type($meta) . " was not made immutable.";
18
19     return $self->violation($desc, $EXPL);
20 }
21
22 no Moose;
23
24 1;
25
26 __END__
27
28 =head1 NAME
29
30 Perl::Critic::Policy::DynamicMoose::RequireMakeImmutable
31
32 =head1 DESCRIPTION
33
34
35 =head1 WARNING
36
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).
45
46 For this Policy to work, all the modules included in your code must be
47 installed locally, and must compile without error.
48
49 =head1 AUTHOR
50
51 Shawn M Moore, C<sartak@bestpractical.com>
52
53 =cut
54