How can I analyze Python code to identify problematic areas?
For measuring cyclomatic complexity, there's a nice tool available at traceback.org. The page also gives a good overview of how to interpret the results.
+1 for pylint. It is great at verifying adherence to coding standards (be it PEP8 or your own organization's variant), which can in the end help to reduce cyclomatic complexity.
For static analysis there is pylint and pychecker. Personally I use pylint as it seems to be more comprehensive than pychecker.
For cyclomatic complexity you can try this perl program, or this article which introduces a python program to do the same
For cyclomatic complexity you can use radon
: https://github.com/rubik/radon
(Use pip
to install it: pip install radon
)
Additionally it also has these features:
- raw metrics (these include SLOC, comment lines, blank lines, &c.)
- Halstead metrics (all of them)
- Maintainability Index (the one used in Visual Studio)