3 ms·
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?
by apu 15y ago
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?
- pnathan 15y agopychecker and pyflakes are good for Python 2.7 or so. I've been pleasantly surprised by them.
- lclarkmichalek 15y agoPylint is also worth a mention, though its output is rather verbose.
- riffraff 15y agoFWIW, 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?
- pnathan 15y agoNo, it's limited in scope.
- spenrose 15y agopyflakes 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=PythonMode;id=PythonProgrammingInEmacs#toc9 http://www.emacswiki.org/emacs/?action=browse;oldid=PythonMo...
- riffraff 15y agoyes, I use pyflakes within vim via syntastic https://github.com/scrooloose/syntastic https://github.com/scrooloose/syntastic
- petercooper 15y agoRuby has a static analysis tool called LASER: http://carboni.ca/projects/laser http://carboni.ca/projects/laser http://confreaks.net/videos/711-rubyconf2011-laser-static-analysis-for-ruby-in-ruby http://confreaks.net/videos/711-rubyconf2011-laser-static-an... https://github.com/michaeledgar/laser https://github.com/michaeledgar/laser
- draegtun 15y agoFor 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/ http://perlcritic.com/ & https://metacpan.org/module/Perl::Critic https://metacpan.org/module/Perl::Critic
- nradov 15y agoJavascript has JSlint which works well
- gaconnet 15y agoCarmack'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 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 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#the-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.