[openstack-dev] Bring pylint check to gate nova

Yun Mao yunmao at gmail.com
Thu Aug 16 18:15:24 UTC 2012


Pylint is a python static analysis tool to help you find bugs. It was
part of the gating test long time ago but was abandoned due to the
cumulative high false positives. However, I believe it still has its
values. For example, I was able to use it to find many bugs,
especially for those big refactor commits.

I'd like to propose to bring pylint gate back, with a new effort to
reduce the false positives as much as possible. The high-level idea is
to only complain the *new* errors introduced from the current commit
in review. Along with a few other tricks, this should reduce the false
positive errors to a very low level. If an error is indeed a false
positive, the author is responsible for getting rid of it in the
source with the traditional pylint comment, or preferably (use
automatic tools to) note it as a pylint exception rule in the commit
so that: 1) it won't show up again in future commits, 2) the reviewers
have a chance to look at the diff of the exception rules and decide
whether that's a false positive or not.

The pylint exception rules are stored in tools/pylint_exceptions. It's
a list of sorted json objects, each of which consists of an error
message and optionally the source code that causes the error. This
way, revisions that change the line numbers or white spaces wouldn't
affect the rules, and should have little merge conflicts.

The tool is called lintstack in tools/lintstack.py. It has two modes:
1) auto generate pylint_exception file based on the current commit; 2)
run pylint, use existing pylint_exception (most likely inherited from
the previous commit) to validate the current commit.

To bootstrap, we can start from accepting all errors in pylint as
exceptions so that the master branch would pass the validation. Note
that many of them are actual bugs. After one of the bugs is fixed, the
pylint_exceptions file chould be regenerated to get rid of the
corresponding rule.

I have back tested the previous 1000 commits and some of the ongoing
patch in review, and found it work very well (way more bugs revealed
than false positives). The code is here
https://review.openstack.org/#/c/11444/

Your feedback is welcome. Thanks,

Yun



More information about the OpenStack-dev mailing list