[Freeipa-devel] [PATCH] 250 fix some pylint/pychecker errors

David Malcolm dmalcolm at redhat.com
Tue Aug 11 21:22:51 UTC 2009


On Tue, 2009-08-11 at 17:12 -0400, Rob Crittenden wrote:
> Taking David Malcolm's advice I ran pylint and pychecker against a lot 
> of the IPA code. Much of what it turned up was warnings/complaints about 
> variable names, minor formatting, things like that. But it did also turn 
> up a few bugs (using undefined exceptions, some references to 
> non-existent variables, etc).
> 
> There are still a lot of places where we shadow built-in functions 
> (filter is a common one). I see this as a first-pass at it.
> 
> I'll consider trying to come up with a config file we can pass to this 
> so we can do some sort of 'make check' to catch errors. Right now the 
> output is so copious it is difficult to tell wheat from chaff without 
> reading carefully.

In case this is helpful, in another project, I had something like this
in the specfile (having created a pylintrc to suppress the various
warnings that I felt weren't important within that code)...



%define use_pylint 1

%if %{use_pylint}
BuildRequires:  pylint
%endif


and within the %build section:

%if %{use_pylint}
# Run pylint.  Halt the build if there are errors
# There doesn't seem to be a good way to get the result of pylint as an
# exit code.  (upstream bug: http://www.logilab.org/ticket/4691 )

# Capture the output:
pylint --rcfile=pylintrc . > pylint.log

# Ensure the pylint log makes it to the rpm build log:
cat pylint.log

# Analyse the "Messages by category" part of the report, looking for
# non-zero results:
# The table should look like this:
#   +-----------+-------+---------+-----------+
#   |type       |number |previous |difference |
#   +===========+=======+=========+===========+
#   |convention |0      |0        |=          |
#   +-----------+-------+---------+-----------+
#   |refactor   |0      |0        |=          |
#   +-----------+-------+---------+-----------+
#   |warning    |0      |0        |=          |
#   +-----------+-------+---------+-----------+
#   |error      |0      |0        |=          |
#   +-----------+-------+---------+-----------+
#   
# Halt the build if any are non-zero:
grep -E "^\|convention[ ]*\|0[ ]*\|" pylint.log || exit 1
grep -E "^\|refactor[ ]*\|0[ ]*\|" pylint.log || exit 1
grep -E "^\|warning[ ]*\|0[ ]*\|" pylint.log || exit 1
grep -E "^\|error[ ]*\|0[ ]*\|" pylint.log || exit 1
%endif


(Suggestions for improvements welcome)




More information about the Freeipa-devel mailing list