<commit_before>## reviewdog - A code review dog who keeps your codebase healthy

[![Gitter](https://badges.gitter.im/haya14busa/reviewdog.svg)](https://gitter.im/haya14busa/reviewdog?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Go Report Card](https://goreportcard.com/badge/github.com/haya14busa/reviewdog)](https://goreportcard.com/report/github.com/haya14busa/reviewdog)
[![releases](https://img.shields.io/github/release/haya14busa/reviewdog.svg)](https://github.com/haya14busa/reviewdog/releases)

![reviewdog logo](https://raw.githubusercontent.com/haya14busa/i/d598ed7dc49fefb0018e422e4c43e5ab8f207a6b/reviewdog/reviewdog.logo.png)

| CI | Status |
| ---- | ----------- |
| [Travis CI](https://travis-ci.org/haya14busa/reviewdog) | [![Travis Build Status](https://travis-ci.org/haya14busa/reviewdog.svg?branch=master)](https://travis-ci.org/haya14busa/reviewdog) |
| [CircleCI](https://circleci.com/gh/haya14busa/reviewdog) | [![CircleCI](https://circleci.com/gh/haya14busa/reviewdog.svg?style=svg)](https://circleci.com/gh/haya14busa/reviewdog) |
| [drone.io](http://droneio.haya14busa.com/haya14busa/reviewdog) | [![drone.io Build Status](http://droneio.haya14busa.com/api/badges/haya14busa/reviewdog/status.svg)](http://droneio.haya14busa.com/haya14busa/reviewdog) |

"reviewdog" provides a way to post review comments to code hosting service,
such as GitHub, automatically by integrating with any linter tools with ease.
It uses any output of lint tools and post them as a comment if the file and
line are in diff of patches to review.

reviewdog also supports run in local environment to filter output of lint tools
by diff.

[design doc](https://docs.google.com/document/d/1mGOX19SSqRowWGbXieBfGPtLnM0BdTkIc9JelTiu6wA/edit?usp=sharing)


Automatic code review ([sample PR](https://github.com/haya14busa/reviewdog/pull/24#discussion_r84599728))

[![sample-comment.png](https://raw.githubusercontent.com/haya14busa/i/dc0ccb1e110515ea407c146d99b749018db05c45/reviewdog/sample-comment.png)](https://github.com/haya14busa/reviewdog/pull/24#discussion_r84599728)

Local run

![reviewdog-local-demo.gif](https://raw.githubusercontent.com/haya14busa/i/dc0ccb1e110515ea407c146d99b749018db05c45/reviewdog/reviewdog-local-demo.gif)

### Installation

Get [the binary release](https://github.com/haya14busa/reviewdog/releases) (recommended way)

or

```
go get -u github.com/haya14busa/reviewdog/cmd/reviewdog
```

## Usage

### 'errorformat'

reviewdog accepts any compiler or linter result from stdin and parses it with
scan-f like [**'errorformat'**](https://github.com/haya14busa/errorformat),
which is the port of Vim's [errorformat](http://vimdoc.sourceforge.net/htmldoc/quickfix.html#errorformat)
feature.

For example, if the result format is `{file}:{line number}:{column number}: {message}`,
errorformat should be `%f:%l:%c: %m` and you can pass it as `-efm` arguments.

```
$ golint ./...
comment_iowriter.go:11:6: exported type CommentWriter should have comment or be unexported
$ golint ./... | reviewdog -efm="%f:%l:%c: %m" -diff="git diff master"
```

| name | description |
| ---- | ----------- |
| %f | file name |
| %l | line number |
| %c | column number |
| %m | error message |
| %% | the single '%' character |
| ... | ... |

Please see [haya14busa/errorformat](https://github.com/haya14busa/errorformat)
and [:h errorformat](http://vimdoc.sourceforge.net/htmldoc/quickfix.html#errorformat)
if you want to deal with more complex output. 'errorformat' can handle more
complex output like multi-line error message.

By this 'errorformat' feature, reviewdog can support any tools output with ease.

### Available pre-defined 'errorformat'

But, you don't have to write 'errorformat' in many cases. reviewdog supports
pre-defined errorformat for major compiler or linter tools.

You can find available errorformat name by `reviewdog -list` and you can use it
with `-f={name}`.

```
$ reviewdog -list
golint          linter for Go source code                                       - https://github.com/golang/lint
govet           Vet examines Go source code and reports suspicious problems     - https://golang.org/cmd/vet/
sbt             the interactive build tool                                      - http://www.scala-sbt.org/
...
```

```
$ golint ./... | reviewdog -f=golint -diff="git diff master"
```

You can add supported pre-defined 'errorformat' by contributing to [haya14busa/errorformat](https://github.com/haya14busa/errorformat)

#### checkstyle format

reviewdog also accepts [checkstyle XML format](http://checkstyle.sourceforge.net/) as well.
If the linter supports checkstyle format as a report format, you can us
-f=checkstyle instead of using 'errorformat'.

```
# Local
$ eslint -f checkstyle . | reviewdog -f=checkstyle -diff="git diff"

# CI (overwrite tool name which is shown in review comment by -name arg)
$ eslint -f checkstyle . | reviewdog -f=checkstyle -name="eslint" -ci="circle-ci"
```

Also, if you want to pass other Json/XML/etc... format to reviewdog, you can write a converter.

```
$ <linter> | <convert-to-checkstyle> | reviewdog -f=checkstyle -name="<linter>" -ci="circle-ci"
```

### Run locally

reviewdog can find new introduced warnings or error by filtering linter results
using diff. You can pass diff comamnd as `-diff` arg, like `-diff="git diff"`,
`-diff="git diff master"`, etc... when you use reviewdog in local environment.

### Working with GitHub and CI services

reviewdog can intergrate with CI service and post review comments to report
results automatically as well!

#### Supported code hosting (or code review) service
At the time of writing, reviewdog supports [GitHub](https://github.com/) and
[GitHub Enterprise](https://enterprise.github.com/home) as a code hosting service for posting comments.

It may support [Gerrit](https://www.gerritcodereview.com/), [Bitbucket](https://bitbucket.org/product), or other services later.

reviewdog requires GitHub Personal API Access token as an environment variable
(`REVIEWDOG_GITHUB_API_TOKEN`) to post comments to GitHub or GitHub Enterprise.<commit_msg>:memo: add document for Project Configuration Based Run<commit_after>## reviewdog - A code review dog who keeps your codebase healthy

[![Gitter](https://badges.gitter.im/haya14busa/reviewdog.svg)](https://gitter.im/haya14busa/reviewdog?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Go Report Card](https://goreportcard.com/badge/github.com/haya14busa/reviewdog)](https://goreportcard.com/report/github.com/haya14busa/reviewdog)
[![releases](https://img.shields.io/github/release/haya14busa/reviewdog.svg)](https://github.com/haya14busa/reviewdog/releases)

![reviewdog logo](https://raw.githubusercontent.com/haya14busa/i/d598ed7dc49fefb0018e422e4c43e5ab8f207a6b/reviewdog/reviewdog.logo.png)

| CI | Status |
| ---- | ----------- |
| [Travis CI](https://travis-ci.org/haya14busa/reviewdog) | [![Travis Build Status](https://travis-ci.org/haya14busa/reviewdog.svg?branch=master)](https://travis-ci.org/haya14busa/reviewdog) |
| [CircleCI](https://circleci.com/gh/haya14busa/reviewdog) | [![CircleCI](https://circleci.com/gh/haya14busa/reviewdog.svg?style=svg)](https://circleci.com/gh/haya14busa/reviewdog) |
| [drone.io](http://droneio.haya14busa.com/haya14busa/reviewdog) | [![drone.io Build Status](http://droneio.haya14busa.com/api/badges/haya14busa/reviewdog/status.svg)](http://droneio.haya14busa.com/haya14busa/reviewdog) |

"reviewdog" provides a way to post review comments to code hosting service,
such as GitHub, automatically by integrating with any linter tools with ease.
It uses any output of lint tools and post them as a comment if the file and
line are in diff of patches to review.

reviewdog also supports run in local environment to filter output of lint tools
by diff.

[design doc](https://docs.google.com/document/d/1mGOX19SSqRowWGbXieBfGPtLnM0BdTkIc9JelTiu6wA/edit?usp=sharing)


Automatic code review ([sample PR](https://github.com/haya14busa/reviewdog/pull/24#discussion_r84599728))

[![sample-comment.png](https://raw.githubusercontent.com/haya14busa/i/dc0ccb1e110515ea407c146d99b749018db05c45/reviewdog/sample-comment.png)](https://github.com/haya14busa/reviewdog/pull/24#discussion_r84599728)

Local run

![reviewdog-local-demo.gif](https://raw.githubusercontent.com/haya14busa/i/dc0ccb1e110515ea407c146d99b749018db05c45/reviewdog/reviewdog-local-demo.gif)

### Installation

Get [the binary release](https://github.com/haya14busa/reviewdog/releases) (recommended way)

or

```
go get -u github.com/haya14busa/reviewdog/cmd/reviewdog
```

## Usage

### 'errorformat'

reviewdog accepts any compiler or linter result from stdin and parses it with
scan-f like [**'errorformat'**](https://github.com/haya14busa/errorformat),
which is the port of Vim's [errorformat](http://vimdoc.sourceforge.net/htmldoc/quickfix.html#errorformat)
feature.

For example, if the result format is `{file}:{line number}:{column number}: {message}`,
errorformat should be `%f:%l:%c: %m` and you can pass it as `-efm` arguments.

```
$ golint ./...
comment_iowriter.go:11:6: exported type CommentWriter should have comment or be unexported
$ golint ./... | reviewdog -efm="%f:%l:%c: %m" -diff="git diff master"
```

| name | description |
| ---- | ----------- |
| %f | file name |
| %l | line number |
| %c | column number |
| %m | error message |
| %% | the single '%' character |
| ... | ... |

Please see [haya14busa/errorformat](https://github.com/haya14busa/errorformat)
and [:h errorformat](http://vimdoc.sourceforge.net/htmldoc/quickfix.html#errorformat)
if you want to deal with more complex output. 'errorformat' can handle more
complex output like multi-line error message.

By this 'errorformat' feature, reviewdog can support any tools output with ease.

### Available pre-defined 'errorformat'

But, you don't have to write 'errorformat' in many cases. reviewdog supports
pre-defined errorformat for major compiler or linter tools.

You can find available errorformat name by `reviewdog -list` and you can use it
with `-f={name}`.

```
$ reviewdog -list
golint          linter for Go source code                                       - https://github.com/golang/lint
govet           Vet examines Go source code and reports suspicious problems     - https://golang.org/cmd/vet/
sbt             the interactive build tool                                      - http://www.scala-sbt.org/
...
```

```
$ golint ./... | reviewdog -f=golint -diff="git diff master"
```

You can add supported pre-defined 'errorformat' by contributing to [haya14busa/errorformat](https://github.com/haya14busa/errorformat)

#### checkstyle format

reviewdog also accepts [checkstyle XML format](http://checkstyle.sourceforge.net/) as well.
If the linter supports checkstyle format as a report format, you can us
-f=checkstyle instead of using 'errorformat'.

```
# Local
$ eslint -f checkstyle . | reviewdog -f=checkstyle -diff="git diff"

# CI (overwrite tool name which is shown in review comment by -name arg)
$ eslint -f checkstyle . | reviewdog -f=checkstyle -name="eslint" -ci="circle-ci"
```

Also, if you want to pass other Json/XML/etc... format to reviewdog, you can write a converter.

```
$ <linter> | <convert-to-checkstyle> | reviewdog -f=checkstyle -name="<linter>" -ci="circle-ci"
```

### Project Configuration Based Run

[experimental]

reviewdog can also be controlled via the reviewdog.yml configuration file instead of "-f" or "-efm" arguments.

#### reviewdog.yml

```yaml
runner:
  <tool-name>:
    cmd: <command> # (required)
    errorformat: # (optional if there is supporeted format for <tool-name>. see reviewdog -list)
      - <list of errorformat>
    name: <tool-name> # (optional. you can overwrite <tool-name> defined by runner key)

  # examples
  golint:
    cmd: golint ./...
    errorformat:
      - "%f:%l:%c: %m"
  govet:
    cmd: go tool vet -all -shadowstrict .
```

```
$ reviewdog -diff="git diff master"
project/run_test.go:61:28: [golint] error strings should not end with punctuation
project/run.go:57:18: [errcheck]        defer os.Setenv(name, os.Getenv(name))
project/run.go:58:12: [errcheck]        os.Setenv(name, "")
# You can use -conf to specify config file path.
$ reviewdog -ci=droneio -conf=./reviewdog.yml
```

### Run locally

reviewdog can find new introduced warnings or error by filtering linter results
using diff. You can pass diff comamnd as `-diff` arg, like `-diff="git diff"`,
`-diff="git diff master"`, etc... when you use reviewdog in local environment.

### Working with GitHub and CI services

reviewdog can intergrate with CI service and post review comments to report
results automatically as well!

#### Supported code hosting (or code review) service
At the time of writing, reviewdog supports [GitHub](https://github.com/) and
[GitHub Enterprise](https://enterprise.github.com/home) as a code hosting service for posting comments.

It may support [Gerrit](https://www.gerritcodereview.com/), [Bitbucket](https://bitbucket.org/product), or other services later.

reviewdog requires GitHub Personal API Access token as an environment variable
(`REVIEWDOG_GITHUB_API_TOKEN`) to post comments to GitHub or GitHub Enterprise.
{'fraction_non_alphanumeric': 0.13752808988764045, 'fraction_numerical': 0.025318352059925095, 'mean_word_length': 4.331869009584665, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 58, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '271395', 'n_tokens_mistral': 4677, 'n_tokens_neox': 4342, 'n_words': 1137}