line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::OTRS::ProhibitSomeCoreFunctions; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Some core functions should not be used |
4
|
|
|
|
|
|
|
|
5
|
24
|
|
|
24
|
|
14589
|
use strict; |
|
24
|
|
|
|
|
57
|
|
|
24
|
|
|
|
|
657
|
|
6
|
24
|
|
|
24
|
|
119
|
use warnings; |
|
24
|
|
|
|
|
46
|
|
|
24
|
|
|
|
|
679
|
|
7
|
|
|
|
|
|
|
|
8
|
24
|
|
|
24
|
|
124
|
use Perl::Critic::Utils qw{ :severities :classification :ppi }; |
|
24
|
|
|
|
|
54
|
|
|
24
|
|
|
|
|
1311
|
|
9
|
24
|
|
|
24
|
|
8310
|
use base 'Perl::Critic::Policy'; |
|
24
|
|
|
|
|
58
|
|
|
24
|
|
|
|
|
2603
|
|
10
|
|
|
|
|
|
|
|
11
|
24
|
|
|
24
|
|
165
|
use Readonly; |
|
24
|
|
|
|
|
64
|
|
|
24
|
|
|
|
|
8744
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Use of "print", "die", and "exit" in modules is not allowed}; |
16
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{Use methods of LayoutObject or MainObject instead.}; |
17
|
|
|
|
|
|
|
|
18
|
12
|
|
|
12
|
1
|
28517
|
sub supported_parameters { return; } |
19
|
12
|
|
|
12
|
1
|
96
|
sub default_severity { return $SEVERITY_HIGHEST; } |
20
|
1
|
|
|
1
|
1
|
727
|
sub default_themes { return qw( otrs otrs_lt_3_3 ) } |
21
|
3
|
|
|
3
|
1
|
205813
|
sub applies_to { return 'PPI::Token::Word' } |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my @prohibited = qw(print die exit); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub violates { |
26
|
31
|
|
|
31
|
1
|
2262
|
my ( $self, $elem ) = @_; |
27
|
|
|
|
|
|
|
|
28
|
31
|
100
|
|
|
|
50
|
return if !grep{ $elem eq $_ || $elem eq 'CORE::' . $_ }@prohibited; |
|
93
|
100
|
|
|
|
1166
|
|
29
|
11
|
50
|
|
|
|
207
|
return if $self->_is_script( $elem ); |
30
|
11
|
|
|
|
|
34
|
return $self->violation( $DESC, $EXPL, $elem ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _is_script { |
34
|
11
|
|
|
11
|
|
20
|
my ( $self, $elem ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
11
|
|
|
|
|
33
|
my $document = $elem->document; |
37
|
11
|
|
|
|
|
225
|
my $filename = $document->logical_filename; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# This applies only to modules, not scripts. |
40
|
11
|
|
|
|
|
278
|
my $is_module = $filename =~ m{ \.pm \z }xms; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# For now, only run this for controller modules (Kernel/Modules/*, Kernel/Output/HTML/) |
43
|
11
|
|
33
|
|
|
49
|
$is_module &&= $filename =~ m{ Kernel/Modules }xms; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# this is for the test modules |
46
|
11
|
|
|
|
|
27
|
$is_module = $filename =~ m{ (^|/)t/Module }xms; |
47
|
|
|
|
|
|
|
|
48
|
11
|
|
|
|
|
29
|
return !$is_module; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=encoding UTF-8 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Perl::Critic::Policy::OTRS::ProhibitSomeCoreFunctions - Some core functions should not be used |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 VERSION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
version 0.09 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 METHODS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 supported_parameters |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
There are no supported parameters. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Renee Baecker <info@perl-services.de> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Renee Baecker. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This is free software, licensed under: |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |