| 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
|
4
|
|
|
4
|
|
2703
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
121
|
|
|
6
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
105
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
22
|
use base 'Perl::Critic::Policy::NamingConventions::Capitalization'; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
2417
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '2.03'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub supported_parameters { |
|
13
|
14
|
|
|
14
|
1
|
123949
|
my ($self) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
14
|
|
|
|
|
115
|
my @params = $self->SUPER::supported_parameters(); |
|
16
|
|
|
|
|
|
|
|
|
17
|
14
|
|
|
|
|
694
|
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
|
14
|
|
|
|
|
66
|
return @params; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub initialize_if_enabled { |
|
28
|
4
|
|
|
4
|
1
|
21674
|
my ($self, $config) = @_; |
|
29
|
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
25
|
my $return = $self->SUPER::initialize_if_enabled( $config ); |
|
31
|
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
8255
|
my $option = $self->{_full_qualified_package_exemptions}; |
|
33
|
|
|
|
|
|
|
|
|
34
|
4
|
|
|
|
|
18
|
my $configuration_exceptions = |
|
35
|
|
|
|
|
|
|
Perl::Critic::Exception::AggregateConfiguration->new(); |
|
36
|
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
2873
|
for my $pattern ( sort keys %{$option} ) { |
|
|
4
|
|
|
|
|
29
|
|
|
38
|
4
|
|
|
|
|
13
|
my $regex; |
|
39
|
4
|
|
|
|
|
229
|
eval { $regex = qr{ \A $pattern \z }xms; } |
|
40
|
4
|
100
|
|
|
|
43
|
or do { |
|
41
|
1
|
|
|
|
|
31
|
$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
|
|
|
|
1425
|
if ( $configuration_exceptions->has_exceptions ) { |
|
54
|
1
|
|
|
|
|
33
|
$configuration_exceptions->throw; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
151
|
return $return; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _package_capitalization { |
|
61
|
21
|
|
|
21
|
|
56872
|
my ($self, $elem) = @_; |
|
62
|
|
|
|
|
|
|
|
|
63
|
21
|
|
|
|
|
72
|
my $namespace = $elem->namespace(); |
|
64
|
21
|
|
|
|
|
763
|
my $option = $self->{_full_qualified_package_exemptions}; |
|
65
|
|
|
|
|
|
|
|
|
66
|
21
|
|
|
|
|
38
|
for my $pattern ( sort keys %{$option} ) { |
|
|
21
|
|
|
|
|
80
|
|
|
67
|
21
|
100
|
|
|
|
210
|
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.03 |
|
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 |