background preloader

Static Analysis of Python Code

Facebook Twitter

Pep8 0.6. Pep8nazi 0.1. Package Index > pep8nazi > 0.1 Not Logged In Status.

pep8nazi 0.1

Flake8: Your Tool For Style Guide Enforcement — flake8 3.3.0 documentation. Installation¶ To install Flake8, open an interactive shell and run:

Flake8: Your Tool For Style Guide Enforcement — flake8 3.3.0 documentation

SLOCCount. This is the home page of "SLOCCount", a set of tools for counting physical Source Lines of Code (SLOC) in a large number of languages of a potentially large set of programs. This suite of tools was used in my papers More than a Gigabuck: Estimating GNU/Linux's Size and Estimating Linux's Size to measure the SLOC of entire GNU/Linux distributions, and my essay Linux Kernel 2.6: It's Worth More!

Others have measured Debian GNU/Linux and the Perl CPAN library using this tool suite. SLOCCount runs on GNU/Linux, FreeBSD, Apple Mac OS X, Windows, and hopefully on other systems too. To run on Windows, you have to install Cygwin first to create a Unix-like environment for SLOCCount (Cygwin users: be sure to use ``Unix'' newlines, not ``DOS'' newlines, when you install Cygwin). SLOCCount is released under the General Public License (GPL), so you can immediately download it -- at no cost! Pylint. Pylint is a source code bug and quality checker for the Python programming language.


It follows the style recommended by PEP 8, the Python style guide.[2] It is similar to Pychecker but includes the following features: Checking the length of each lineChecking if variable names are well-formed according to the project's coding standardChecking if declared interfaces are truly implemented[3] Clean Code starts in your IDE. Static Code Analyzers for Python - Doug Hellmann. Old-school developers remember lint, the static code analysis tool for C programs.

Static Code Analyzers for Python - Doug Hellmann

There are several similar programs available for Python, and they can all help you clean up your act. This month we continue examining Python development tools you have told me you can’t live without. A fair number of you have mentioned that you use a static analysis tool such as PyChecker, pylint, or PyFlakes. I have to admit, I was a bit skeptical of how useful any of them would be with Python. In a past life, when I used to write a lot of C, I used lint occasionally. The Test Program A static analysis tool reads your source code without executing it and looks for common mistakes. In order to compare the three tools I’ll be discussing this month, I needed to write some sample code with known mistakes in it. Listing 1 PyChecker One of the oldest lint tools for Python is PyChecker, by Eric Newton, John Shue, and Neal Norwitz. Snakefood: Python Dependency Graphs. Generate dependency graphs from Python code.

snakefood: Python Dependency Graphs

This dependency tracker package has a few distinguishing characteristics: It uses the AST to parse the Python files. This is very reliable, it always runs.No module is loaded. Loading modules to figure out dependencies is almost always problem, because a lot of codebases run initialization code in the global namespace, which often requires additional setup. Pyflakes in Launchpad. PyChecker: Python Code Analysis. PyChecker is a cool tool for checking Python scripts for bugs.

PyChecker: Python Code Analysis

It works with Python 2.0 – 2.7. In this article, we will write some crappy code to see what PyChecker can pick up on. Then we’ll improve the code according to what we find until the code checks out. According to PyChecker’s website, it can detect the following problems: No global found (e.g., using a module without importing it)Passing the wrong number of parameters to functions/methods/constructorsPassing the wrong number of parameters to builtin functions & methodsUsing format strings that don’t match argumentsUsing class methods and attributes that don’t existChanging signature when overriding a methodRedefining a function/class/method in the same scopeUsing a variable before setting itself is not the first parameter defined for a methodUnused globals and locals (module or variable)Unused function/method arguments (can ignore self)No doc strings in modules, classes, functions, and methods Getting Started Other Tips.

Ns-3: The script will test and reformat code according to the ns-3 coding style posted at It requires that you install 'uncrustify'.


More... Clone Digger.