line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::Reneeb::Capitalization; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: NamingConventions::Capitalization plus the ability to exempt "Full qualified package names" |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
3249
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
146
|
|
6
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
128
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
25
|
use base 'Perl::Critic::Policy::NamingConventions::Capitalization'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
3207
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '2.05'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub supported_parameters { |
13
|
15
|
|
|
15
|
1
|
130811
|
my ($self) = @_; |
14
|
|
|
|
|
|
|
|
15
|
15
|
|
|
|
|
150
|
my @params = $self->SUPER::supported_parameters(); |
16
|
|
|
|
|
|
|
|
17
|
15
|
|
|
|
|
725
|
push @params, { |
18
|
|
|
|
|
|
|
name => 'full_qualified_package_exemptions', |
19
|
|
|
|
|
|
|
description => 'Package names that are exempt from capitalization rules. The values here are regexes that will be surrounded by \A and \z.', |
20
|
|
|
|
|
|
|
default_string => 'main', |
21
|
|
|
|
|
|
|
behavior => 'string list', |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
15
|
|
|
|
|
71
|
return @params; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub initialize_if_enabled { |
28
|
4
|
|
|
4
|
1
|
21419
|
my ($self, $config) = @_; |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
33
|
my $return = $self->SUPER::initialize_if_enabled( $config ); |
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
8312
|
my $option = $self->{_full_qualified_package_exemptions}; |
33
|
|
|
|
|
|
|
|
34
|
4
|
|
|
|
|
20
|
my $configuration_exceptions = |
35
|
|
|
|
|
|
|
Perl::Critic::Exception::AggregateConfiguration->new(); |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
2843
|
for my $pattern ( sort keys %{$option} ) { |
|
4
|
|
|
|
|
34
|
|
38
|
4
|
|
|
|
|
17
|
my $regex; |
39
|
4
|
|
|
|
|
166
|
eval { $regex = qr{ \A $pattern \z }xms; } |
40
|
4
|
100
|
|
|
|
8
|
or do { |
41
|
1
|
|
|
|
|
41
|
$configuration_exceptions->add_exception( |
42
|
|
|
|
|
|
|
Perl::Critic::Exception::Configuration::Option::Policy::ParameterValue->new( |
43
|
|
|
|
|
|
|
policy => $self, |
44
|
|
|
|
|
|
|
option_name => '_full_qualified_package_exemptions', |
45
|
|
|
|
|
|
|
option_value => $pattern, |
46
|
|
|
|
|
|
|
message_suffix => |
47
|
|
|
|
|
|
|
"is not a valid regular expression: $@", |
48
|
|
|
|
|
|
|
) |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
4
|
100
|
|
|
|
1395
|
if ( $configuration_exceptions->has_exceptions ) { |
54
|
1
|
|
|
|
|
33
|
$configuration_exceptions->throw; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
140
|
return $return; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _package_capitalization { |
61
|
21
|
|
|
21
|
|
57777
|
my ($self, $elem) = @_; |
62
|
|
|
|
|
|
|
|
63
|
21
|
|
|
|
|
73
|
my $namespace = $elem->namespace(); |
64
|
21
|
|
|
|
|
580
|
my $option = $self->{_full_qualified_package_exemptions}; |
65
|
|
|
|
|
|
|
|
66
|
21
|
|
|
|
|
46
|
for my $pattern ( sort keys %{$option} ) { |
|
21
|
|
|
|
|
77
|
|
67
|
21
|
100
|
|
|
|
223
|
return if $namespace =~ m{\A $pattern \z}xms; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
16
|
|
|
|
|
74
|
return $self->SUPER::_package_capitalization( $elem ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=pod |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=encoding UTF-8 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 NAME |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Perl::Critic::Policy::Reneeb::Capitalization - NamingConventions::Capitalization plus the ability to exempt "Full qualified package names" |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 VERSION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
version 2.05 |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 METHODS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 supported_parameters |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Same parameters as for L<Perl::Critic::Policy::NamingConventions::Capitalization> plus |
94
|
|
|
|
|
|
|
C<full_qualified_package_exemptions>. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 initialize_if_enabled |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Checks the parameters |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Renee Baecker <reneeb@cpan.org> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This software is Copyright (c) 2015 by Renee Baecker. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This is free software, licensed under: |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |