You are not logged in.

#1 2011-11-03 00:08:50

Camus
Member
Registered: 2011-07-03
Posts: 71

Source code analysis

I've never used any tool to analyze the quality of my code, I usually just try to keep SLOC (or rather number of logical statements) as low as possible. I've found out there's Sonar, which is available in AUR, but I'm sure there are others available.
I'm mostly developing in Python, so I'm primarily looking for a tool with support for Python code. Just mentioning it since it's relevant.

But I'm more interested in how many of you use such tools and which of them do you use.

Offline

#2 2011-11-03 11:00:09

lunar
Member
Registered: 2010-10-04
Posts: 95

Re: Source code analysis

pylint and pyflakes are popular for Python.  Both check for logical errors, and are usually quite good at finding them. 

pylint also partially checks for PEP 8 conformance, and questionable or dangerous code.  For instance, it hints non-conforming names like classes starting with a lower case letter, unused variables or arguments, and constructs considered questionable by the pylint developers.  The latter includes among other things use of the builtin map and filter functions, and *args and **kwargs syntax, which is not agreed on by some Python users. You can however disable or configure warnings emitted by pylint in a very finely grained manner, and thus turn warnings of on per line, per block, per object, per file and per project basis.   By and large, pylint is used by most Python developers and projects, and more or less *the* error checker for Python code.  It is definitely recommendable, and already integrated in many IDEs (WingIDE, the Pydev plugin for Eclipse and others).

pyflakes only focuses on logical errors, and does neither check for coding style nor for "dangerous code".  It's output is consequently less verbose and it normally doesn't need any configuration.  When it comes to error checking, it is however not less recommendable than Pylint, though not as widely used among Python developers.

Concering coding style, there is another tool, named pep8, which rigidly checks for PEP 8 conformance, especially with regards to names.  PEP 8 is *the* Python style guide, and is adopted and partially enforced by many popular Python projects. If you contribute to such projects, or want to write code whose style is accepted by the vast majority of Python developers, or want to avoid nit-picky style remarks when showing your Python code in some Python forum, you may find this tool quite useful.

Offline

#3 2011-11-03 19:02:05

Google
Member
From: Mountain View, California
Registered: 2010-05-31
Posts: 484
Website

Re: Source code analysis

I like pylint. I haven't heard of pyflakes. I think pylint does a pretty good job about complaining, haha.

Offline

#4 2011-11-04 09:57:38

trontonic
Member
Registered: 2008-07-21
Posts: 80

Re: Source code analysis

profiling is relevant keyword in connection with analyzing source code.

Here is a question with several good answers, relating to profiling python code.

Last edited by trontonic (2011-11-04 09:58:01)

Offline

Board footer

Powered by FluxBB