static analysis for bad and/or avoidable practices
mastool is available on pypi, you can install from source or simply:
pip install mastool
After installing mastool, flake8 would get equipped with mastool's checks.
$ flake8 [PATH]
Mastool also adds the following switch to flake8, which provides a quick suggestion about what to replace the reported code with.
$ flake8 --with-solutions
See here for more details or the summary below.
|M001||looping against dictionary keys|
|M002||simplifiable if condition|
|M003||joining path with plus|
|M004||assigning to built-in|
|M005||catching a generic exception|
|M006||catching a generic exception and passing it silently|
|M007||use of import star|
|M008||comparing to True or False|
|M009||poor choice of default argument|
|M010||use of "if" expression as statement|
|M011||use of a comprehension as statement|
|M012||use of a generator as statement|
Some of these issues are not bad/erroneous!
Yes, in various contexts sometimes it may be ok (and possibly unavoidable) to use these constructs, at which point you can ignore them using Flake8's config mechanism
Why did this tool become as a Flake8 extension?
Flake8 provides a magnificent base for static analysis, there's no point in reinventing the wheel.
What are some other similar tools?
You can find some informatin about the subject on my blog