PyLint results?

Alexandre Fayolle alexandre.fayolle at logilab.fr
Tue Apr 25 02:22:13 EDT 2006


Others have answered most of your questions, I won't repeat the answers
here, but only join the choir to stress that pylint needs tuning to
your coding style. An obvious case is camelCaseMethodNames versus
underscored_method_names, but there are also a lot of issues. The
default pylint settings match Logilab's coding standards. The coding
metrics were heavily inspired by Steve McConnell's Code Complete book,
but the figures provided therein have been heavily downscaled to match
for Python's expressivity (Code Complete deals mostly with C/C++/Java
code). 

Le 21-04-2006, Michael <m.yanowitz at kearfott.com> nous disait:

> 2) C:  0: Missing required attribute "__revision__"
>    What is this? Is that for CVS? I don't use CVS (we use SVN). I have not
>    seen any sample code which includes this tag yet. But if I include
>    __revision 1.0  somewhere in the code it will remove that warning?


We generally have a 
__revision__ = '$Id$' 

statement at module top level, which gets replaced a check in time by
CVS, which makes it easy to know who checked in the HEAD revision of the
module. This behaviour can be emulated with subversion properties. 



> 5) R:547:readDiscreteData: Too many branches (28/12)
>    Python doesn't have the switch/case statements that C/C++ have. So I
>    could have a large block if/elif/else statements.
>    Is there any way to avoid that?
>
> 6) R:722:waitDiscretes: Too many local variables (38/15)
>    That's new to me. What is wrong with too many local variables?
>    Can anything be done to improve that besides having too many globals?

For these two, I strongly recommend giving a look at Martin Fowler's
Refactoring book (published by Addison Wesley). These are typical so
called "code smells" which can be solved using for instance the "Extract
Method" refactoring.

Of course, it all depends on the kind of program you are working, and
sometimes using intermediate variables helps understanding the code (by
providing useful names, for instance). What pylint tells you is "there
could be an issue here, you should check."


-- 
Alexandre Fayolle                              LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org



More information about the Python-list mailing list