Pylint also finds unused imports, variables etc...
I have written a little script to get only errors and scores out of pylint.
It works recursively looking for *.py scripts within a directory passed to it on the command line, or (if that is missing) within the current working directory.
Posted here in case it is of any use to anyone.
#! /usr/bin/env python
this module runs pylint on all python scripts found in a directory tree
total = 0.0
count = 0
apply pylint to the file specified if it is a *.py file
global total, count
if module[-3:] == ".py":
print "CHECKING ", module
pout = os.popen('pylint %s'% module, 'r')
for line in pout:
if re.match("E....:.", line):
if "Your code has been rated at" in line:
score = re.findall("\d.\d\d", line)
total += float(score)
count += 1
if __name__ == "__main__":
BASE_DIRECTORY = sys.argv
print "no directory specified, defaulting to current working directory"
BASE_DIRECTORY = os.getcwd()
print "looking for *.py scripts in subdirectories of ", BASE_DIRECTORY
for root, dirs, files in os.walk(BASE_DIRECTORY):
for name in files:
filepath = os.path.join(root, name)
print "==" * 50
print "%d modules found"% count
print "AVERAGE SCORE = %.02f"% (total / count)