The most opinionated Go source code linter for code audit.
Clone or download

README.md

go-critic

Build Status Awesome Go Report Card GoDoc coverage PRs Welcome

Go source code linter providing checks currently missing from other linters.

Logo

Project goals:

  • Provide as many useful checks as possible; We're prototyping and experimenting here.

  • When a specific check implementation is mature and proven useful, propose its integration into other linters.

  • If a good checker can't find a better home, it stays here.

We say yes! to most checks that feel right and can help someone.

You can use this tool to make whole codebase checks periodically.

There is never too much static code analysis. Try it out.

Documentation

The latest documentation is available at go-critic.github.io.

Installation

go get -u github.com/go-critic/go-critic/...

Usage

Be sure gocritic executable is under your $PATH.

Usage of gocritic: gocritic [sub-command] [sub-command args...] Run gocritic without arguments to get help output.

Examples:

Command Description
gocritic check-package fmt Runs all stable checkers on fmt package
gocritic check-package pkg1 pkg2 Run all stable checkers on pkg1 and pkg2
gocritic check-package -enable elseif,paramName fmt Runs specified checkers on fmt package
gocritic check-project $GOROOT/src Run all stable checkers on entire GOROOT
gocritic check-project $GOPATH/src Run all stable checkers on entire GOPATH
gocritic check-project $GOPATH/src/foo Run all stable checkers on all packages under GOPATH/src/foo

Note: check-project $GOPATH/xyz won't work it you're using multiple paths under GOPATH.

Contributing

This project aims to be contribution-friendly.

Our chats: English or Russian (Telegram website)

We're using an optimistic merging strategy most of the time. In short, this means that if your contribution has some flaws, we can still merge it and then fix them by ourselves. Experimental and work-in-progress checkers are isolated, so nothing bad will happen.

Code style is the same as in Go project, see CodeReviewComments.

See CONTRIBUTING.md for more details. It also describes how to develop a new checker for the linter.