line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
1
|
|
|
1
|
|
362
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
5
|
|
|
|
|
|
|
use Perl::Critic::Utils qw(:severities :classification :ppi); |
6
|
1
|
|
|
1
|
|
4
|
use parent 'Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
7
|
1
|
|
|
1
|
|
308
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
our $VERSION = 'v1.0.3'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
1
|
59048
|
1; |
12
|
0
|
|
|
0
|
1
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Perl::Critic::Policy::Community::AmpersandSubCalls - Don't use & to call |
16
|
|
|
|
|
|
|
subroutines |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Ampersands (C<&>) were once needed to call subroutines, but in modern Perl they |
21
|
|
|
|
|
|
|
are not only unnecessary but actually change the behavior from what you may |
22
|
|
|
|
|
|
|
expect. Calling a subroutine with an ampersand ignores the subroutine's |
23
|
|
|
|
|
|
|
prototype if any, which may change what arguments the subroutine receives. |
24
|
|
|
|
|
|
|
Additionally, calling a subroutine as C<&foo;> with no arguments will pass on |
25
|
|
|
|
|
|
|
the contents of C<@_> from the current subroutine, which may be quite |
26
|
|
|
|
|
|
|
surprising. Unless used intentionally for this behavior, the ampersand should |
27
|
|
|
|
|
|
|
simply be omitted. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $value = &foo(); # not ok |
30
|
|
|
|
|
|
|
my $sum = &foo(1,2); # not ok |
31
|
|
|
|
|
|
|
my $value = foo(); # ok |
32
|
|
|
|
|
|
|
my $sum = foo 1,2; # ok |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This policy is a subclass of the core policy |
35
|
|
|
|
|
|
|
L<Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils>, and performs the |
36
|
|
|
|
|
|
|
same function but in the C<community> theme. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 AFFILIATION |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
This policy is part of L<Perl::Critic::Community>. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 CONFIGURATION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This policy is not configurable except for the standard options. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 AUTHOR |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Dan Book, C<dbook@cpan.org> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Copyright 2015, Dan Book. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This library is free software; you may redistribute it and/or modify it under |
55
|
|
|
|
|
|
|
the terms of the Artistic License version 2.0. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SEE ALSO |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
L<Perl::Critic> |