line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
1
|
|
|
1
|
|
354
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
5
|
|
|
|
|
|
|
use Perl::Critic::Utils qw(:severities :classification :ppi); |
6
|
1
|
|
|
1
|
|
4
|
use parent 'Perl::Critic::Policy'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
7
|
1
|
|
|
1
|
|
287
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
8
|
|
|
|
|
|
|
our $VERSION = 'v1.0.3'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use constant DESC => 'Using -w switch'; |
11
|
1
|
|
|
1
|
|
84
|
use constant EXPL => 'Don\'t use -w (or -W), it\'s too eager. use warnings; instead.'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
12
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
196
|
|
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
0
|
19970
|
my ($self, $elem) = @_; |
15
|
6
|
|
|
6
|
1
|
85
|
my $shebang = $elem->first_token; |
16
|
0
|
|
|
0
|
1
|
0
|
return () unless $shebang->isa('PPI::Token::Comment') and $shebang->content =~ m/^#!/; |
17
|
8
|
|
|
8
|
1
|
27582
|
|
18
|
|
|
|
|
|
|
return $self->violation(DESC, EXPL, $elem) if $shebang->content =~ m/\h-[a-zA-Z]*[wW]/; |
19
|
|
|
|
|
|
|
|
20
|
8
|
|
|
8
|
1
|
69
|
return (); |
21
|
8
|
|
|
|
|
37
|
} |
22
|
8
|
100
|
66
|
|
|
202
|
|
23
|
|
|
|
|
|
|
1; |
24
|
7
|
100
|
|
|
|
47
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
26
|
1
|
|
|
|
|
7
|
|
27
|
|
|
|
|
|
|
Perl::Critic::Policy::Community::WarningsSwitch - Scripts should not use the -w |
28
|
|
|
|
|
|
|
switch on the shebang line |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
The C<-w> switch enables warnings globally in a perl program, including for any |
33
|
|
|
|
|
|
|
modules that did not explicitly enable or disable any warnings. The C<-W> |
34
|
|
|
|
|
|
|
switch enables warnings even for modules that explicitly disabled them. The |
35
|
|
|
|
|
|
|
primary issue with this is enabling warnings for code that you did not write. |
36
|
|
|
|
|
|
|
Some of these modules may not be designed to run with warnings enabled, but |
37
|
|
|
|
|
|
|
still work fine. Instead, use L<warnings> within your own code only. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#!/usr/bin/perl -w # not ok |
40
|
|
|
|
|
|
|
#!/usr/bin/perl -W # not ok |
41
|
|
|
|
|
|
|
use warnings; # ok |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 AFFILIATION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This policy is part of L<Perl::Critic::Community>. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 CONFIGURATION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This policy is not configurable except for the standard options. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 AUTHOR |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Dan Book, C<dbook@cpan.org> |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Copyright 2015, Dan Book. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This library is free software; you may redistribute it and/or modify it under |
60
|
|
|
|
|
|
|
the terms of the Artistic License version 2.0. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SEE ALSO |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
L<Perl::Critic>, L<warnings> |