← 返回列表

reviewdog: Automated code review tool integrated with any code analysis tools

聚合站 SecWiki技术 入库 2026-11-18T18:13:07

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

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

github-pr-check sample

comment in pull-request

commit status

sample-comment.png

reviewdog-local-demo.gif

reviewdog-local-demo.gif

# Install the latest version. (Install it into ./bin/ by default).
$ curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/fd59714416d6d9a1c0692d872e38e7f8448df4fc/install.sh | sh -s
# Specify installation directory ($(go env GOPATH)/bin/) and version.
$ curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/fd59714416d6d9a1c0692d872e38e7f8448df4fc/install.sh | sh -s -- -b $(go env GOPATH)/bin [vX.Y.Z]
# In alpine linux (as it does not come with curl by default)
$ wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/fd59714416d6d9a1c0692d872e38e7f8448df4fc/install.sh | sh -s [vX.Y.Z]

You can also use nightly reviewdog release
to try the latest reviewdog improvements every day!

`$ curl -sfL https://raw.githubusercontent.com/reviewdog/nightly/30fccfe9f47f7e6fd8b3c38aa0da11a6c9f04de7/install.sh | sh -s -- -b $(go env GOPATH)/bin````
steps:
- uses: reviewdog/action-setup@d8edfce3dd5e1ec6978745e801f9c50b5ef80252 # v1.4.0
with:
reviewdog_version: latest # Optional. [latest,nightly,v.X.Y.Z]

You can also install reviewdog using brew:

$ brew install --cask reviewdog/tap/reviewdog
$ brew upgrade --cask reviewdog/tap/reviewdog

scoop install reviewdog

`$ go install github.com/reviewdog/reviewdog/cmd/reviewdog@latest`
reviewdog accepts any compiler or linter result from stdin and parses it with
scan-f like [**'errorformat'**](https://github.com/reviewdog/errorformat),
which is the port of Vim's [errorformat](https://vim-jp.org/vimdoc-en/quickfix.html#error-file-format)
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 FETCH_HEAD"

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

Please see [reviewdog/errorformat](https://github.com/reviewdog/errorformat)
and [:h errorformat](https://vim-jp.org/vimdoc-en/quickfix.html#error-file-format)
if you want to deal with a more complex output. 'errorformat' can handle more
complex output like a multi-line error message.

You can also try errorformat on [the Playground](https://reviewdog.github.io/errorformat-playground/)!

With this 'errorformat' feature, reviewdog can support any tool output with ease.

But, you don't have to write 'errorformat' in many cases. reviewdog supports pre-defined errorformat for major 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 FETCH_HEAD"`
You can add supported pre-defined 'errorformat' by contributing to [reviewdog/errorformat](https://github.com/reviewdog/errorformat)

reviewdog supports [Reviewdog Diagnostic Format (RDFormat)](https://github.com/reviewdog/reviewdog/blob/master/proto/rdf) as a
generic diagnostic format and it supports both [rdjson](https://github.com/reviewdog/reviewdog/blob/master/proto/rdf/#rdjson) and
[rdjsonl](https://github.com/reviewdog/reviewdog/blob/master/proto/rdf/#rdjsonl) formats.

This rdformat supports rich features like multiline ranged comments, severity,
rule code with URL, and [code suggestions](#code-suggestions).

$ | | reviewdog -f=rdjson -reporter=github-pr-review

or

$ | | reviewdog -f=rdjsonl -reporter=github-pr-review

![eslint reviewdog rdjson demo](https://user-images.githubusercontent.com/3797062/97085944-87233a80-165b-11eb-94a8-0a47d5e24905.png)


You can use [eslint-formatter-rdjson](https://www.npmjs.com/package/eslint-formatter-rdjson)
to output `rdjson` as eslint output format.

$ npm install --save-dev eslint-formatter-rdjson
$ eslint -f rdjson . | reviewdog -f=rdjson -reporter=github-pr-review

Or you can also use [reviewdog/action-eslint](https://github.com/reviewdog/action-eslint) for GitHub Actions.

![reviewdog with gofmt example](https://user-images.githubusercontent.com/3797062/89168305-a3ad5a80-d5b7-11ea-8939-be7ac1976d30.png)


reviewdog supports diff (unified format) as an input format especially useful
for [code suggestions](#code-suggestions).
reviewdog can integrate with any code suggestions tools or formatters to report suggestions.

`-f.diff.strip`: option for `-f=diff`: strip NUM leading components from diff file names (equivalent to 'patch -p') (default is 1 for git diff) (default 1)

$ # e.g. eslint --fix, gofmt
$ TMPFILE=$(mktemp)
$ git diff >"${TMPFILE}"
$ git stash -u && git stash drop
$ reviewdog -f=diff -f.diff.strip=1 -reporter=github-pr-review < "${TMPFILE}"

Or you can also use [reviewdog/action-suggester](https://github.com/reviewdog/action-suggester) for GitHub Actions.

If diagnostic tools support diff output format, you can pipe the diff directly.

$ gofmt -s -d . | reviewdog -name="gofmt" -f=diff -f.diff.strip=0 -reporter=github-pr-review
$ shellcheck -f diff $(shfmt -f .) | reviewdog -f=diff

reviewdog also accepts [checkstyle XML format](http://checkstyle.sourceforge.net/) as well.
If the linter supports checkstyle format as a report format, you can use
-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" -reporter=github-check

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>" -reporter=github-pr-check`
reviewdog supports [SARIF 2.1.0 JSON format](https://sarifweb.azurewebsites.net/).
You can use reviewdog with -f=sarif option.

Local

$ eslint -f @microsoft/eslint-formatter-sarif . | reviewdog -f=sarif -diff="git diff"

To check the parsed diagnostics before configuring a remote reporter, print them locally:

`$ reviewdog -f=sarif -reporter=rdjson -filter-mode=nofilter < report.sarif`
- `physicalLocation.artifactLocation.uri` must point at a file in your workspace. A URL there
becomes a `../../…` path instead of an error; keep analysis or report links in the message (or in
the rule's `helpUri`) instead of using them as source locations.
- A finding inside a changed file whose `region.startLine` is on an unchanged line needs `-filter-mode=file` (see [Filter Mode Support Table](#filter-mode-support-table) for reporter
support); the default `added` filter drops it. `-filter-mode=nofilter` disables diff-based filtering,
but it does not repair a path that resolves to nothing.

reviewdog supports *code suggestions* feature with [rdformat](#reviewdog-diagnostic-format-rdformat) or [diff](#diff) input.
You can also use [reviewdog/action-suggester](https://github.com/reviewdog/action-suggester) for GitHub Actions.

reviewdog can suggest code changes along with diagnostic results if a diagnostic tool supports code suggestions data.
You can integrate reviewdog with any code fixing tools and any code formatter with [diff](#diff) input as well.

Note that not all reporters provide support for code suggestions.

| `-reporter` | Suggestion support | 
|---|---|
| **`local`** | NO \[1\] | 
| **`github-check`** | NO \[2\] | 
| **`github-pr-check`** | NO \[2\] | 
| **`github-annotations`** | NO \[2\] | 
| **`github-pr-annotations`** | NO \[2\] | 
| **`github-pr-review`** | OK | 
| **`gitlab-mr-discussion`** | OK | 
| **`gitlab-mr-commit`** | NO \[2\] | 
| **`gerrit-change-review`** | NO \[1\] | 
| **`bitbucket-code-report`** | NO \[2\] | 
| **`gitea-pr-review`** | NO \[2\] | 

- \[1\] The reporter service supports the code suggestion feature, but reviewdog does not support it yet. See [#678](https://github.com/reviewdog/reviewdog/issues/678) for the status.
- \[2\] The reporter service itself doesn't support the code suggestion feature.

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

With .reviewdog.yml, you can run the same commands for both CI service and local environment including editor integration with ease.

runner:
:
cmd: # (required)
errorformat: # (optional if you use format)
-
format: # (optional if you use errorformat. e.g. golint,rdjson,rdjsonl)
name: # (optional. you can overwrite defined by runner key)
level: # (optional. same as -level flag. [info,warning,error])
# examples
golint:
cmd: golint ./...
errorformat:
- "%f:%l:%c: %m"
level: warning
govet:
cmd: go vet -all .
format: govet
your-awesome-linter:
cmd: awesome-linter run
format: rdjson
name: AwesomeLinter

$ reviewdog -diff="git diff FETCH_HEAD"
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 -runners to run only specified runners.

$ reviewdog -diff="git diff FETCH_HEAD" -runners=golint,govet
project/run_test.go:61:28: [golint] error strings should not end with punctuation

You can use -conf to specify config file path.

$ reviewdog -conf=./.reviewdog.yml -reporter=github-pr-check

Output format for project config based run is one of the following formats.

- `<file>: [<tool name>] <message>`
- `<file>:<lnum>: [<tool name>] <message>`
- `<file>:<lnum>:<col>: [<tool name>] <message>`

reviewdog can report results both in the local environment and review services as continuous integration.

reviewdog can find newly introduced findings by filtering linter results
using diff. You can pass the diff command as `-diff` arg.

![github-pr-check sample annotation with option 1](https://user-images.githubusercontent.com/3797062/64875597-65016f80-d688-11e9-843f-4679fb666f0d.png)

![github-pr-check sample](https://user-images.githubusercontent.com/3797062/40884858-6efd82a0-6756-11e8-9f1a-c6af4f920fb0.png)


github-pr-check reporter reports results to [GitHub Checks](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks).

You can change the report level for this reporter by `level` field in [config
file](#reviewdog-config-file) or `-level` flag. You can control GitHub status
check results with this feature. (default: error)

| Level | GitHub Status | 
|---|---|
| `info` | neutral | 
| `warning` | neutral | 
| `error` | failure | 

There are two options to use this reporter.

Example: [.github/workflows/reviewdog.yml](https://github.com/reviewdog/reviewdog/blob/master/.github/workflows/reviewdog.yml)

See [GitHub Actions](#github-actions) section too. You can also use public
reviewdog GitHub Actions.

reviewdog CLI sends a request to reviewdog GitHub App server and the server post results as GitHub Checks, because Check API is only supported for GitHub App and GitHub Actions.

1. Install reviewdog Apps. [https://github.com/apps/reviewdog](https://github.com/apps/reviewdog)
2. Set `REVIEWDOG_TOKEN`.

- Get token from `https://reviewdog.app/gh/{owner}/{repo-name}`.

$ export REVIEWDOG_TOKEN=""
$ reviewdog -reporter=github-pr-check

*Caution*

As described above, github-pr-check reporter with Option 2 depends on reviewdog GitHub App server. The server is running with haya14busa's pocket money for now and I may break things, so I cannot ensure that the server is running 24h and 365 days.

**UPDATE:** Started getting support by [opencollective](https://opencollective.com/reviewdog)
and GitHub sponsor.
See [Supporting reviewdog](#supporting-reviewdog)

You can use github-pr-review reporter or use run reviewdog under GitHub Actions if you don't want to depend on reviewdog server.

It's basically the same as `-reporter=github-pr-check` except it works not only for
Pull Request but also for commit.

![sample comment outside diff](https://user-images.githubusercontent.com/3797062/69917921-e0680580-14ae-11ea-9a56-de9e3cbac005.png)


You can create [reviewdog badge](#reviewdog-badge-) for this reporter.

github-pr-review reporter reports results to GitHub PullRequest review comments
using GitHub Personal API Access Token.
[GitHub Enterprise](https://github.com/enterprise) is supported too.

- Go to [https://github.com/settings/tokens](https://github.com/settings/tokens) and generate a new API token.
- Check `repo` for private repositories or `public_repo` for public repositories.

$ export REVIEWDOG_GITHUB_API_TOKEN=""
$ reviewdog -reporter=github-pr-review

For GitHub Enterprise, set the API endpoint by an environment variable.

$ export GITHUB_API="https://example.githubenterprise.com/api/v3/"
$ export REVIEWDOG_INSECURE_SKIP_VERIFY=true # set this as you need to skip verifying SSL

See [GitHub Actions](#github-actions) section too if you can use GitHub
Actions. You can also use public reviewdog GitHub Actions.

`github-annotations` uses the GitHub Actions annotation format to output errors
and warnings to `stdout` e.g.

::error line=11,col=41,file=app/index.md::[vale] reported by reviewdog 🐶%0A[demo.Spelling] Did you really mean 'boobarbaz'?%0A%0ARaw Output:%0A{"message": "[demo.Spelling] Did you really mean 'boobarbaz'?", "location": {"path": "app/index.md", "range": {"start": {"line": 11, "column": 41}}}, "severity": "ERROR"}

This reporter requires a valid GitHub API token to generate a diff, but will not
use the token to report errors. With `-filter-mode=nofilter`, no diff is fetched,
so token and CI metadata checks are skipped and `-guess` has no effect.

Same as `github-annotations`.

![gitlab-mr-discussion sample](https://user-images.githubusercontent.com/3797062/41810718-f91bc540-773d-11e8-8598-fbc09ce9b1c7.png)


Required GitLab version: >= v10.8.0

gitlab-mr-discussion reporter reports results to GitLab MergeRequest discussions using
GitLab Personal API Access token.
Get the token with `api` scope from [https://gitlab.com/profile/personal\_access\_tokens](https://gitlab.com/profile/personal_access_tokens).

$ export REVIEWDOG_GITLAB_API_TOKEN=""
$ reviewdog -reporter=gitlab-mr-discussion

The `CI_API_V4_URL` environment variable, defined automatically by Gitlab CI (v11.7 onwards), will be used to find out the Gitlab API URL.

Alternatively, `GITLAB_API` can also be defined, in which case it will take precedence over `CI_API_V4_URL`.

$ export GITLAB_API="https://example.gitlab.com/api/v4"
$ export REVIEWDOG_INSECURE_SKIP_VERIFY=true # set this as you need to skip verifying SSL

gitlab-mr-commit is similar to [gitlab-mr-discussion](#reporter-gitlab-mergerequest-discussions--reportergitlab-mr-discussion) reporter but reports results to each commit in GitLab MergeRequest.

gitlab-mr-discussion is recommended, but you can use gitlab-mr-commit reporter if your GitLab version is under v10.8.0.

$ export REVIEWDOG_GITLAB_API_TOKEN=""
$ reviewdog -reporter=gitlab-mr-commit

gerrit-change-review reporter reports results to Gerrit Change using Gerrit Rest APIs.

The reporter supports Basic Authentication and Git-cookie based authentication for reporting results.

Set `GERRIT_USERNAME` and `GERRIT_PASSWORD` environment variables for basic authentication, and put `GIT_GITCOOKIE_PATH` for git cookie-based authentication.

$ export GERRIT_CHANGE_ID=changeID
$ export GERRIT_REVISION_ID=revisionID
$ export GERRIT_BRANCH=master
$ export GERRIT_ADDRESS=http://:
$ reviewdog -reporter=gerrit-change-review

![bitbucket-code-report](https://user-images.githubusercontent.com/9948629/96770123-c138d600-13e8-11eb-8e46-250b4bb393bd.png)

![bitbucket-code-annotations](https://user-images.githubusercontent.com/9948629/97054896-5e813f00-158e-11eb-9ad7-f8d75489b8ba.png)


bitbucket-code-report generates the annotated
[Bitbucket Code Insights](https://support.atlassian.com/bitbucket-cloud/docs/code-insights/) report.

For now, only the `no-filter` mode is supported, so the whole project is scanned on every run.
Reports are stored per commit and can be viewed per commit from Bitbucket Pipelines UI or
in Pull Request. In the Pull Request UI affected code lines will be annotated in the diff,
as well as you will be able to filter the annotations by **This pull request** or **All**.

If running from [Bitbucket Pipelines](#bitbucket-pipelines), no additional configuration is needed (even credentials).
If running locally or from some other CI system you would need to provide Bitbucket API credentials:

- For Basic Auth you need to set the following env variables:
`BITBUCKET_USER` and `BITBUCKET_PASSWORD`
- For AccessToken Auth you need to set `BITBUCKET_ACCESS_TOKEN`

$ export BITBUCKET_USER="my_user"
$ export BITBUCKET_PASSWORD="my_password"
$ reviewdog -reporter=bitbucket-code-report

To post a report to the Bitbucket Server use `BITBUCKET_SERVER_URL` variable:

$ export BITBUCKET_USER="my_user"
$ export BITBUCKET_PASSWORD="my_password"
$ export BITBUCKET_SERVER_URL="https://bitbucket.my-company.com"
$ reviewdog -reporter=bitbucket-code-report

name: reviewdog
on: [pull_request]
jobs:
reviewdog:
name: reviewdog
runs-on: ubuntu-latest
steps:
# ...
- uses: reviewdog/action-setup@d8edfce3dd5e1ec6978745e801f9c50b5ef80252 # v1.4.0
with:
reviewdog_version: latest # Optional. [latest,nightly,v.X.Y.Z]
- name: Run reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
reviewdog -reporter=github-pr-check -runners=golint,govet
# or
reviewdog -reporter=github-pr-review -runners=golint,govet

Only `github-check` reporter can run on the push event too.

name: reviewdog (github-check)
on:
push:
branches:
- master
pull_request:
jobs:
reviewdog:
name: reviewdog
runs-on: ubuntu-latest
steps:
# ...
- name: Run reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
reviewdog -reporter=github-check -runners=golint,govet

You can use public GitHub Actions to start using reviewdog with ease! 🎉 ▶️ 🎉

- Common
- Text
  - [reviewdog/action-alex](https://github.com/reviewdog/action-alex) - Run [alex](https://github.com/get-alex/alex) which catches insensitive, inconsiderate writing. (e.g. master/slave)
  - [reviewdog/action-languagetool](https://github.com/reviewdog/action-languagetool) - Run [languagetool](https://github.com/languagetool-org/languagetool).
  - [tsuyoshicho/action-textlint](https://github.com/tsuyoshicho/action-textlint) - Run [textlint](https://github.com/textlint/textlint)
  - [tsuyoshicho/action-redpen](https://github.com/tsuyoshicho/action-redpen) - Run [redpen](https://github.com/redpen-cc/redpen)
- Markdown
- Docker
  - [reviewdog/action-hadolint](https://github.com/reviewdog/action-hadolint) - Run [hadolint](https://github.com/hadolint/hadolint) to lint `Dockerfile`.
- Env
  - [dotenv-linter/action-dotenv-linter](https://github.com/dotenv-linter/action-dotenv-linter) - Run [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) to lint `.env` files.
- Shell script
  - [reviewdog/action-shellcheck](https://github.com/reviewdog/action-shellcheck) - Run [shellcheck](https://github.com/koalaman/shellcheck).
  - [reviewdog/action-shfmt](https://github.com/reviewdog/action-shfmt) - Run [shfmt](https://github.com/mvdan/sh).
- Go
  - [reviewdog/action-staticcheck](https://github.com/reviewdog/action-staticcheck) - Run [staticcheck](https://staticcheck.io/).
  - [reviewdog/action-golangci-lint](https://github.com/reviewdog/action-golangci-lint) - Run [golangci-lint](https://github.com/golangci/golangci-lint) and supported linters individually by golangci-lint.
- JavaScript
  - [reviewdog/action-eslint](https://github.com/reviewdog/action-eslint) - Run [eslint](https://github.com/eslint/eslint).
  - [mongolyy/reviewdog-action-biome](https://github.com/mongolyy/reviewdog-action-biome) - Run [Biome](https://biomejs.dev/).
- TypeScript
  - [EPMatt/reviewdog-action-tsc](https://github.com/EPMatt/reviewdog-action-tsc) - Run [tsc](https://www.typescriptlang.org/docs/handbook/compiler-options.html).
- CSS
- Vim script
  - [reviewdog/action-vint](https://github.com/reviewdog/action-vint) - Run [vint](https://github.com/Vimjas/vint).
  - [tsuyoshicho/action-vimlint](https://github.com/tsuyoshicho/action-vimlint) - Run [vim-vimlint](https://github.com/syngan/vim-vimlint)
- Terraform
- YAML
- Ruby
  - [reviewdog/action-brakeman](https://github.com/reviewdog/action-brakeman) - Run [brakeman](https://github.com/presidentbeef/brakeman).
  - [reviewdog/action-reek](https://github.com/reviewdog/action-reek) - Run [reek](https://github.com/troessner/reek).
  - [reviewdog/action-rubocop](https://github.com/reviewdog/action-rubocop) - Run [rubocop](https://github.com/rubocop/rubocop).
  - [vk26/action-fasterer](https://github.com/vk26/action-fasterer) - Run [fasterer](https://github.com/DamirSvrtan/fasterer).
  - [PrintReleaf/action-standardrb](https://github.com/PrintReleaf/action-standardrb) - Run [standardrb](https://github.com/standardrb/standard).
  - [tk0miya/action-erblint](https://github.com/tk0miya/action-erblint) - Run [erb-lint](https://github.com/Shopify/erb-lint)
  - [tk0miya/action-steep](https://github.com/tk0miya/action-steep) - Run [steep](https://github.com/soutaro/steep)
  - [blooper05/action-rails\_best\_practices](https://github.com/blooper05/action-rails_best_practices) - Run [rails\_best\_practices](https://github.com/flyerhzm/rails_best_practices)
  - [tomferreira/action-bundler-audit](https://github.com/tomferreira/action-bundler-audit) - Run [bundler-audit](https://github.com/rubysec/bundler-audit)
- Python
  - [wemake-python-styleguide](https://github.com/wemake-services/wemake-python-styleguide) - Run wemake-python-styleguide
  - [tsuyoshicho/action-mypy](https://github.com/tsuyoshicho/action-mypy) - Run [mypy](https://pypi.org/project/mypy/)
  - [jordemort/action-pyright](https://github.com/jordemort/action-pyright) - Run [pyright](https://github.com/Microsoft/pyright)
  - [dciborow/action-pylint](https://github.com/dciborow/action-pylint) - Run [pylint](https://github.com/pylint-dev/pylint)
  - [reviewdog/action-black](https://github.com/reviewdog/action-black) - Run [black](https://github.com/psf/black)
  - [brunohaf/action-bandit](https://github.com/brunohaf/action-bandit) - Run [bandit](https://github.com/PyCQA/bandit)
- Kotlin
  - [ScaCap/action-ktlint](https://github.com/ScaCap/action-ktlint) - Run [ktlint](https://ktlint.github.io/).
- Android Lint
- Ansible
- GitHub Actions
- Protocol Buffers
- Rego
  - [reviewdog/action-regal](https://github.com/reviewdog/action-regal) - Run [Regal](https://github.com/StyraInc/regal)

... and more on [GitHub Marketplace](https://github.com/marketplace?utf8=%E2%9C%93&type=actions&query=reviewdog).

Missing actions? Check out [reviewdog/action-template](https://github.com/reviewdog/action-template) and create a new reviewdog action!

Please open a Pull Request to add your created reviewdog actions here ✨.
I can also put your repositories under reviewdog org and co-maintain the actions.
Example: [action-tflint](https://github.com/reviewdog/reviewdog/issues/322).

![Graceful Degradation example](https://user-images.githubusercontent.com/3797062/71781334-e2266b00-3010-11ea-8a38-dee6e30c8162.png)


`GITHUB_TOKEN` for Pull Requests from a forked repository doesn't have write
access to Check API nor Review API due to [GitHub Actions
restriction](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token).

Instead, reviewdog uses [Logging commands of GitHub
Actions](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#set-an-error-message-error)
to post results as
[annotations](https://docs.github.com/en/rest/checks/runs#annotations-object)
similar to `github-pr-check` reporter.

Note that there is a limitation for annotations created by logging commands,
such as [max # of annotations per run](https://github.com/reviewdog/reviewdog/issues/411#issuecomment-570893427).
You can check GitHub Actions log to see full results in such cases.

As [`github-check` reporter](#reporter-github-checks--reportergithub-pr-check) support running on commit, we can create reviewdog
[GitHub Action badge](https://docs.github.com/en/actions/using-workflows#adding-a-workflow-status-badge-to-your-repository)
to check the result against master commit for example. 🎉

Example:

reviewdog

Store GitHub API token by [travis encryption keys](https://docs.travis-ci.com/user/encryption-keys/).

$ gem install travis
$ travis encrypt REVIEWDOG_GITHUB_API_TOKEN= --add env.global

env:
global:
- secure:
install:
- mkdir -p ~/bin/ && export PATH="~/bin/:$PATH"
- curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/fd59714416d6d9a1c0692d872e38e7f8448df4fc/install.sh| sh -s -- -b ~/bin
script:
- >-
golint ./... | reviewdog -f=golint -reporter=github-pr-review

Examples

Store `REVIEWDOG_GITHUB_API_TOKEN` (or `REVIEWDOG_TOKEN` for github-pr-check) in
[Environment variables - CircleCI](https://circleci.com/docs/environment-variables/#setting-environment-variables-for-all-commands-without-adding-them-to-git)

version: 2
jobs:
build:
docker:
- image: golang:latest
steps:
- checkout
- run: curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/fd59714416d6d9a1c0692d872e38e7f8448df4fc/install.sh| sh -s -- -b ./bin
- run: go vet ./... 2>&1 | ./bin/reviewdog -f=govet -reporter=github-pr-review
# Deprecated: prefer GitHub Actions to use github-pr-check reporter.
- run: go vet ./... 2>&1 | ./bin/reviewdog -f=govet -reporter=github-pr-check

Store `REVIEWDOG_GITLAB_API_TOKEN` in [GitLab CI variable](https://docs.gitlab.com/ee/ci/variables/#variables).

reviewdog:
script:
- reviewdog -reporter=gitlab-mr-discussion
# Or
- reviewdog -reporter=gitlab-mr-commit

No additional configuration is needed.

pipelines:
default:
- step:
name: Reviewdog
image: golangci/golangci-lint:v1.31-alpine
script:
- wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/fd59714416d6d9a1c0692d872e38e7f8448df4fc/install.sh |
sh -s -- -b $(go env GOPATH)/bin
- golangci-lint run --out-format=line-number ./... | reviewdog -f=golangci-lint -reporter=bitbucket-code-report

You can use reviewdog to post review comments from anywhere with following environment variables.

| name | description | 
|---|---|
| `CI_PULL_REQUEST` | Pull Request number (e.g. 14) | 
| `CI_COMMIT` | SHA1 for the current build | 
| `CI_REPO_OWNER` | repository owner (e.g. "reviewdog" for [https://github.com/reviewdog/errorformat](https://github.com/reviewdog/errorformat)) | 
| `CI_REPO_NAME` | repository name (e.g. "errorformat" for [https://github.com/reviewdog/errorformat](https://github.com/reviewdog/errorformat)) | 
| `CI_BRANCH` | \[optional\] branch of the commit | 

$ export CI_PULL_REQUEST=14
$ export CI_REPO_OWNER=haya14busa
$ export CI_REPO_NAME=reviewdog
$ export CI_COMMIT=$(git rev-parse HEAD)

and set a token if required.

$ REVIEWDOG_TOKEN=""
$ REVIEWDOG_GITHUB_API_TOKEN=""
$ REVIEWDOG_GITLAB_API_TOKEN=""

If a CI service doesn't provide information such as Pull Request ID - reviewdog can guess it by a branch name and commit SHA.
Just pass the flag `guess`:

`$ reviewdog -conf=.reviewdog.yml -reporter=github-pr-check -guess`
- [GitHub pull request builder plugin - Jenkins - Jenkins Wiki](https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin)
- [Configuring a GitHub app account - Jenkins - CloudBees](https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-admin-guide/github-app-auth) - required to use github-pr-check formatter without reviewdog server or GitHub actions.

$ export CI_PULL_REQUEST=${ghprbPullId}
$ export CI_REPO_OWNER=haya14busa
$ export CI_REPO_NAME=reviewdog
$ export CI_COMMIT=${ghprbActualCommit}
$ export REVIEWDOG_INSECURE_SKIP_VERIFY=true # set this as you need

To submit via reviewdog server using github-pr-check reporter

$ REVIEWDOG_TOKEN="" reviewdog -reporter=github-pr-check

Or, to submit directly via API using github-pr-review reporter

$ REVIEWDOG_GITHUB_API_TOKEN="" reviewdog -reporter=github-pr-review

Or, to submit directly via API using github-pr-check reporter (requires GitHub App Account configured)

$ REVIEWDOG_SKIP_DOGHOUSE=true REVIEWDOG_GITHUB_API_TOKEN="" reviewdog -reporter=github-pr-check
`` By default (-fail-level=none) reviewdog will return0as exit code even if it finds errors. reviewdog will exit with code 1 with-fail-level=[any,info,warning,error]` flag if it finds at least 1 issue with severity greater than or equal to the given level.
This can be helpful when you are using it as a step in your CI pipeline and want to mark the step failed if any error found by linter.

You can also use -level flag to configure default report revel.

reviewdog filter results by diff and you can control how reviewdog filter results by -filter-mode flag.
Available filter modes are as below.

Filter results by added/modified lines.

Filter results by diff context. i.e. changed lines +-N lines (N=3 for example).

Filter results by added/modified file. i.e. reviewdog will report results as long as they are in added/modified file even if the results are not in actual diff.

Do not filter any results. Useful for posting results as comments as much as possible and check other results in console at the same time.

-fail-on-error also works with any filter-mode and can catch all results from any linters with nofilter mode.

$ reviewdog -reporter=github-pr-review -filter-mode=nofilter -fail-on-error
Note that not all reporters provide full support for filter mode due to API limitation.
e.g. github-pr-review reporter uses GitHub Review
API
but this API don't support posting comments outside diff context,
so reviewdog will use Check annotation as fallback to post those comments [1].

-reporter \ -filter-mode added diff_context file nofilter
local OK OK OK OK
github-check OK OK OK OK
github-pr-check OK OK OK OK
github-pr-review OK OK Partially Supported [1] Partially Supported [1]
github-pr-annotations OK OK OK OK
gitlab-mr-discussion OK OK OK Partially Supported [2]
gitlab-mr-commit OK Partially Supported [2] Partially Supported [2] Partially Supported [2]
gerrit-change-review OK OK? [3] OK? [3] Partially Supported? [2][3]
bitbucket-code-report NO [4] NO [4] NO [4] OK
gitea-pr-review OK OK Partially Supported [5] Partially Supported [5]

Use the -tee flag to show debug info.

reviewdog -filter-mode=nofilter -tee
- reviewdog — A code review dog who keeps your codebase healthy
- reviewdog ♡ GitHub Check — improved automated review experience
- Automated Code Review on GitHub Actions with reviewdog for any languages/tools
- GitHub Actions to guard your workflow

haya14busa

Become GitHub Sponsor for each contributor
or become a backer or sponsor from opencollective.

原文链接:https://github.com/reviewdog/reviewdog