Lints and Hints: What tools are available for checking and correcting the conventions, style and common errors in my language (lint tools), and are there tools that can automatically fix them (hint tools)?

This is a follow-up to a comment posted on Is there a place for automated code reviews?

Would a list of static analysis tools help jumpstart this? – h.j.k. 34 mins ago

Let's list a few tools that people can use to address easy and common issues in their code before they ask their questions, and that can help reviewers gather "easy" points to mention in their CR answers...:


To keep this organized, please post one tool/language per answer; if it's a paid/commercial tool, please mention it. Also please include a link to the website.

share
1  
This should also help: en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis –  JaDogg May 2 at 4:34
    

24 Answers 24

VBA

share
4  
You might want to add that this one is written by you and ducky –  Simon Forsberg May 2 at 11:13

JavaScript

For Javascript, there's JSLint: JSLint on Wikipedia and also JSHint: JSHint on Wikipedia

Note that all major browsers and other interpreters support the "use strict"; proclamation in code, and will ensure that many common mistakes in code are identified before running the code. See: What does “use strict” do in JavaScript, and what is the reasoning behind it?

share
    
Don't forget jshint either –  Flambino May 1 at 23:08
    
@Flambino - thanks, I added it, but I am also sure there's more. Feel free to edit to improve in whatever way you see fit. –  rolfl May 2 at 2:27

Python

The standard for Python style and layout is PEP 8: Style Guide for Python Code.

There's an online style checker: pep8online.com

Pylint is a static analyzer.

Prospector is a static analyzer that combines multiple python static analyzers including Pylint.

Sublime text has the SublimeLinter plugin which can lint to both PEP8 and PEP257 automatically and adds warning icons to the gutter

Mypy is a static type checker that is working on implementing PEP 484

share
1  
The python IDE pycharm automatically checks for pep-8 compliance and also can suggest a number of conformity changes –  Vogel612 May 2 at 12:13
    
Sublime text has the SublimeLinter plugin which can lint to both PEP8 and PEP257 automatically and adds warning icons to the gutter. –  Christopher Pearson May 5 at 5:40
    
@ChristopherPearson - Why don't you edit that in to the answer itself. Appreciated. –  rolfl May 5 at 10:20
    
@rolfl - I don't have enough rep to edit community wiki's. –  Christopher Pearson May 5 at 16:06

HTML5, XHTML, CSS

Tool: Markup validation checker

Also, there are beautifiers to help improve formatting, CodeBeautify.org has a good one.

share

VB.NET

  • ReSharper (commercial)

    A paid Visual Studio extension (possibility for open-source "community" license though) with a free 30-day trial.

share
    
As of the Visual Studio 2015 RC, some of this functionality is built in. visualstudio.com/news/vs2015-vs#ManLang –  RubberDuck May 1 at 15:55
1  
@RubberDuck Yeah, VS ended up implementing an actual "rename" refactoring, too. But VS just isn't the same without R# ;) –  Mat's Mug May 1 at 15:56

C / C++

  • Coverity, a commercial static analyzer, free for open source developers

  • Cppcheck, an open-source static analyzer

  • CppDepend, a commercial static analyzer based on Clang

  • flint, another open-source static analyzer

  • gcc

Website: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html


Simply compiling code with -Wall -Wextra -pedantic options catches quite a number of potential or actual problems.

share

Java

Java lint tools are usually dependent of the IDE you develop in. All the major IDE's (Eclipse, IntelliJ, Netbeans, etc. - alphabetical order) have mechanisms in place for not only checking for lint-like problems, but also for fixing them too.

Features to expect from your IDE - identification of, and correction of:

  1. automatic code formatting (indentation, brace positions, line-wrapping, etc.)
  2. redundant code, or impossible code
  3. incomplete documentation
  4. variable and function name "shadowing"
  5. and much, much more.

Standalone tools:

  1. PMD
  2. FindBugs
share
2  
There is also a bunch of maven plugins that can be used –  Simon Forsberg May 2 at 11:14
    
Funny enough running PMD on PMD reveals the exact thing it's trying to correct ;) –  Bono May 6 at 14:35

SQL

General:

SQL Server / Transact-SQL

Online: SQL-Format.org

Natively: SET SHOWPLAN_XML

MySQL

Online: MySQL Syntax Check

Natively: EXPLAIN

PostgreSQL & PL/pgSQL

Plugin: pg-validator

Natively: EXPLAIN

SQLite

Plugin: sqllogictest

Natively: EXPLAIN

Oracle:

Natively: EXPLAIN

share

PHP

Online:

Plugins:

You can also use the native php_check_syntax from an IDE or command line.

share

C#

  • StyleCop (free)

    It can be run from inside of Visual Studio or integrated into an MSBuild project.

  • ReSharper (commercial)

    A paid Visual Studio extension (possibility for open-source "community" license though) with a free 30-day trial.

  • FxCop (free)

    Can be run standalone, but later versions are bundled into Visual Studio as the "Code Analysis" feature.

share

Delphi

Tool: FixInsight (commercial)

Website: http://sourceoddity.com/fixinsight/

share

JSON

Online validator: JSONLint.com

They also have a free Pro Version

share

Regex:

JS-Flavored

Offline-Tools:

  • RegexBuddy - commercial regex-development helper tool, supporting a multitude of regex-flavors and programming languages
share

Scala

Style checker plug-in: ScalaStyle.org

Online evaluator: SimplyScala.com

share

Objective-C

Plugins:

These should also work for C/C++

share
4  
Can I be on this list? –  nhgrif May 1 at 18:49
1  
The real question is: Do you really want to? ;-) –  Phrancis May 1 at 19:01
    
Note Atom.io is a text-editor. linter is a plug-in for Atom providing the necessary checks for many, many languages. –  Mast May 1 at 21:44
    
Good catch, I corrected it! –  Phrancis May 1 at 21:48

Perl

Plugins:

Or natively using B::Lint module.

share

C

Although not currently actively developed, this free, open-source software provides error checking that can be enhanced with in-code commenting.

share

Bash, Shell

Online:

Plugins:

share

MongoDB

Plugins:

Or natively use validate

share

Lua

Plugins:

share

Ruby

Gems:

  • rubocop is probably the most popular

But there are many more each with emphasis on different things (style, code complexity, etc.).

Online:

  • Don't know if this counts as it's more like CI, but there's always CodeClimate (also works for JavaScript, PHP, and Python)
share

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .