1B::Lint(3)            User Contributed Perl Documentation           B::Lint(3)
2
3
4

NAME

6       B::Lint - Perl lint
7

SYNOPSIS

9       perl -MO=Lint[,OPTIONS] foo.pl
10

DESCRIPTION

12       The B::Lint module is equivalent to an extended version of the -w
13       option of perl. It is named after the program lint which carries out a
14       similar process for C programs.
15

OPTIONS AND LINT CHECKS

17       Option words are separated by commas (not whitespace) and follow the
18       usual conventions of compiler backend options. Following any options
19       (indicated by a leading -) come lint check arguments. Each such
20       argument (apart from the special all and none options) is a word
21       representing one possible lint check (turning on that check) or is no-
22       foo (turning off that check). Before processing the check arguments, a
23       standard list of checks is turned on. Later options override earlier
24       ones. Available options are:
25
26       magic-diamond
27               Produces a warning whenever the magic "<>" readline is used.
28               Internally it uses perl's two-argument open which itself treats
29               filenames with special characters specially. This could allow
30               interestingly named files to have unexpected effects when
31               reading.
32
33                 % touch 'rm *|'
34                 % perl -pe 1
35
36               The above creates a file named "rm *|". When perl opens it with
37               "<>" it actually executes the shell program "rm *". This makes
38               "<>" dangerous to use carelessly.
39
40       context Produces a warning whenever an array is used in an implicit
41               scalar context. For example, both of the lines
42
43                   $foo = length(@bar);
44                   $foo = @bar;
45
46               will elicit a warning. Using an explicit scalar() silences the
47               warning. For example,
48
49                   $foo = scalar(@bar);
50
51       implicit-read and implicit-write
52               These options produce a warning whenever an operation
53               implicitly reads or (respectively) writes to one of Perl's
54               special variables.  For example, implicit-read will warn about
55               these:
56
57                   /foo/;
58
59               and implicit-write will warn about these:
60
61                   s/foo/bar/;
62
63               Both implicit-read and implicit-write warn about this:
64
65                   for (@a) { ... }
66
67       bare-subs
68               This option warns whenever a bareword is implicitly quoted, but
69               is also the name of a subroutine in the current package.
70               Typical mistakes that it will trap are:
71
72                   use constant foo => 'bar';
73                   @a = ( foo => 1 );
74                   $b{foo} = 2;
75
76               Neither of these will do what a naive user would expect.
77
78       dollar-underscore
79               This option warns whenever $_ is used either explicitly
80               anywhere or as the implicit argument of a print statement.
81
82       private-names
83               This option warns on each use of any variable, subroutine or
84               method name that lives in a non-current package but begins with
85               an underscore ("_"). Warnings aren't issued for the special
86               case of the single character name "_" by itself (e.g. $_ and
87               @_).
88
89       undefined-subs
90               This option warns whenever an undefined subroutine is invoked.
91               This option will only catch explicitly invoked subroutines such
92               as "foo()" and not indirect invocations such as "&$subref()" or
93               "$obj->meth()". Note that some programs or modules delay
94               definition of subs until runtime by means of the AUTOLOAD
95               mechanism.
96
97       regexp-variables
98               This option warns whenever one of the regexp variables "$`", $&
99               or "$'" is used. Any occurrence of any of these variables in
100               your program can slow your whole program down. See perlre for
101               details.
102
103       all     Turn all warnings on.
104
105       none    Turn all warnings off.
106

NON LINT-CHECK OPTIONS

108       -u Package
109               Normally, Lint only checks the main code of the program
110               together with all subs defined in package main. The -u option
111               lets you include other package names whose subs are then
112               checked by Lint.
113

EXTENDING LINT

115       Lint can be extended by with plugins. Lint uses Module::Pluggable to
116       find available plugins. Plugins are expected but not required to inform
117       Lint of which checks they are adding.
118
119       The "B::Lint->register_plugin( MyPlugin => \@new_checks )" method adds
120       the list of @new_checks to the list of valid checks. If your module
121       wasn't loaded by Module::Pluggable then your class name is added to the
122       list of plugins.
123
124       You must create a "match( \%checks )" method in your plugin class or
125       one of its parents. It will be called on every op as a regular method
126       call with a hash ref of checks as its parameter.
127
128       The class methods "B::Lint->file" and "B::Lint->line" contain the
129       current filename and line number.
130
131         package Sample;
132         use B::Lint;
133         B::Lint->register_plugin( Sample => [ 'good_taste' ] );
134
135         sub match {
136             my ( $op, $checks_href ) = shift @_;
137             if ( $checks_href->{good_taste} ) {
138                 ...
139             }
140         }
141

TODO

143       while(<FH>) stomps $_
144       strict oo
145       unchecked system calls
146       more tests, validate against older perls
147

BUGS

149       This is only a very preliminary version.
150

AUTHOR

152       Malcolm Beattie, mbeattie@sable.ox.ac.uk.
153

ACKNOWLEDGEMENTS

155       Sebastien Aperghis-Tramoni - bug fixes
156
157
158
159perl v5.16.3                      2013-01-26                        B::Lint(3)
Impressum