Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I know that "more lax" languages like python make static code analysis much tougher, but does anyone have any experience with good tools for it?



Carmack's article inspired me greatly. For the past month I have been churning a product idea for a code analysis & program transformation tool for Python. Seeing someone like Carmack recommend tools like these feels like substantial validation of their usefulness.

While investigating the feasibility of my product idea, I have run across 3 interesting Python analysis tools that are often overshadowed by pyflakes & pychecker. You may find them relevant to your question:

- pylint (http://www.logilab.org/card/pylintfeatures): Already mentioned here, but the list of checks it will perform is humbling.

- Pyntch (http://www.unixuser.org/~euske/python/pyntch/index.html): Type inference via graph analysis.

- Pypy's Annotation Pass (http://readthedocs.org/docs/pypy/en/latest/translation.html#...): Type inference via control flow graphs.

Anyone maintaining large Django or other Python projects who wants to chat about my product idea, email me (my HN username at Google's email service)! I am especially interested in any constructive skepticism you send my way. I am looking to refine my ideas into something that genuinely advances programming.


For Perl there is Perl::Critic which also highlights when you're not adhering to best practice idioms.

I use it regularly on client projects (it's like giving your code a certification!) and its heavily used/recommended in the Perl community.

See http://perlcritic.com/ & https://metacpan.org/module/Perl::Critic


pychecker and pyflakes are good for Python 2.7 or so. I've been pleasantly surprised by them.


Pylint is also worth a mention, though its output is rather verbose.


FWIW, I have found pyflakes really useful in fixing the most common bugs I encounter in a python program (using a wrong identifier) but I haven't noticed anything deep about it (such as detecting _obvious_ AttributeErrors), does pychecker work better in this sense?


No, it's limited in scope.


pyflakes compiles your code, pychecker imports it, which is not idempotent -- all top-level statements are executed. pyflakes will throw some false positives, but not many. pychecker will fill your terminal with opinions. pyflakes is IMHO a much superior tool. Plugging it into emacs via flymake is a no-brainer; I believe there are solutions for vi as well: http://www.emacswiki.org/emacs/?action=browse;oldid=PythonMo...


yes, I use pyflakes within vim via syntastic https://github.com/scrooloose/syntastic


Javascript has JSlint which works well




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: