line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::Reneeb::RequirePostderef; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Require Postdereferencing which became stable in Perl 5.24 |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
3839
|
use 5.006001; |
|
5
|
|
|
|
|
22
|
|
6
|
5
|
|
|
5
|
|
31
|
use strict; |
|
5
|
|
|
|
|
31
|
|
|
5
|
|
|
|
|
202
|
|
7
|
5
|
|
|
5
|
|
29
|
use warnings; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
166
|
|
8
|
5
|
|
|
5
|
|
40
|
use Readonly; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
302
|
|
9
|
5
|
|
|
5
|
|
39
|
use List::Util qw(first); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
591
|
|
10
|
|
|
|
|
|
|
|
11
|
5
|
|
|
5
|
|
40
|
use Perl::Critic::Utils qw{ :severities }; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
275
|
|
12
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
|
663
|
use base 'Perl::Critic::Policy'; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
1803
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '2.05'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Use postderef (e.g. $ref->@*) instead of the "old" dereferencing (e.g. @{$ref})}; |
20
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => [ ]; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
23
|
|
|
|
|
|
|
|
24
|
22
|
|
|
22
|
1
|
1862
|
sub default_severity { return $SEVERITY_MEDIUM } |
25
|
1
|
|
|
1
|
1
|
644
|
sub default_themes { return qw<reneeb> } |
26
|
|
|
|
|
|
|
sub applies_to { |
27
|
23
|
|
|
23
|
1
|
300420
|
return qw< |
28
|
|
|
|
|
|
|
PPI::Token::Cast |
29
|
|
|
|
|
|
|
>; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub violates { |
35
|
20
|
|
|
20
|
1
|
442
|
my ( $self, $elem, $doc ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# postderence syntax do also have a PPI::Token::Cast object, |
38
|
|
|
|
|
|
|
# but that looks different |
39
|
20
|
50
|
|
20
|
|
103
|
return if !first{ $elem->content ne $_ }qw($ @ * % &),'$#'; |
|
20
|
|
|
|
|
73
|
|
40
|
|
|
|
|
|
|
|
41
|
20
|
|
|
|
|
184
|
my $sibling = $elem->snext_sibling; |
42
|
20
|
100
|
|
|
|
962
|
return if !$sibling; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# grep in boolean or void context isn't checked |
45
|
17
|
100
|
100
|
|
|
129
|
return if !$sibling->isa('PPI::Structure::Block') && !$sibling->isa('PPI::Token::Symbol'); |
46
|
|
|
|
|
|
|
|
47
|
13
|
|
|
|
|
49
|
return $self->violation( $DESC, $EXPL, $elem ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=pod |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=encoding UTF-8 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Perl::Critic::Policy::Reneeb::RequirePostderef - Require Postdereferencing which became stable in Perl 5.24 |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 VERSION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
version 2.05 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 DESCRIPTION |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Use postderef (e.g. $ref->@*) instead of the "old" dereferencing (e.g. @{$ref}) |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 AUTHOR |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Renee Baecker <reneeb@cpan.org> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This software is Copyright (c) 2015 by Renee Baecker. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This is free software, licensed under: |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|