🐶 Automated code review tool integrated with any code analysis tools regardless of programming language

reviewdog - A code review dog who keeps your codebase healthy.


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 an output of lint tools and posts them as a comment if findings are in diff of patches to review.

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

design doc

Table of Contents

github-pr-check sample comment in pull-request commit status sample-comment.png reviewdog-local-demo.gif

Installation

# Install the latest version. (Install it into ./bin/ by default).
$ curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s

# Specify installation directory ($(go env GOPATH)/bin/) and version.
$ curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/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/master/install.sh | sh -s [vX.Y.Z]

Nightly releases

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

$ curl -sfL https://raw.githubusercontent.com/reviewdog/nightly/master/install.sh | sh -s -- -b $(go env GOPATH)/bin

GitHub Action: reviewdog/action-setup

steps:
- uses: reviewdog/action-setup@v1
  with:
    reviewdog_version: latest # Optional. [latest,nightly,v.X.Y.Z]

homebrew / linuxbrew

You can also install reviewdog using brew:

$ brew install reviewdog/tap/reviewdog
$ brew upgrade reviewdog/tap/reviewdog

Build with go install

$ go install github.com/reviewdog/reviewdog/cmd/reviewdog@latest

Input Format

'errorformat'

reviewdog accepts any compiler or linter result from stdin and parses it with scan-f like 'errorformat', which is the port of Vim's 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 FETCH_HEAD"
name description
%f file name
%l line number
%c column number
%m error message
%% the single '%' character
... ...

Please see reviewdog/errorformat and :h errorformat 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!

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 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

Reviewdog Diagnostic Format (RDFormat)

reviewdog supports Reviewdog Diagnostic Format (RDFormat) as a generic diagnostic format and it supports both rdjson and rdjsonl formats.

This rdformat supports rich feature like multiline ranged comments, severity, rule code with URL, and code suggestions.

$ <linter> | <convert-to-rdjson> | reviewdog -f=rdjson -reporter=github-pr-review
# or
$ <linter> | <convert-to-rdjsonl> | reviewdog -f=rdjsonl -reporter=github-pr-review

Example: ESLint with RDFormat

eslint reviewdog rdjson demo

You can use 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 for GitHub Actions.

Diff

reviewdog with gofmt example

reviewdog supports diff (unified format) as an input format especially useful for 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)

$ <any-code-fixer/formatter> # 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 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

checkstyle format

reviewdog also accepts checkstyle XML format 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

Code Suggestions

eslint reviewdog suggestion demo reviewdog with gofmt example

reviewdog supports code suggestions feature with rdformat or diff input. You can also use reviewdog/action-suggester for GitHub Actions.

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

Code Suggestions Support Table

Note that not all reporters provide support of code suggestion.

-reporter Suggestion support
local NO [1]
github-check NO [2]
github-pr-check NO [2]
github-pr-review OK
gitlab-mr-discussion NO [1]
gitlab-mr-commit NO [2]
gerrit-change-review NO [1]
bitbucket-code-report NO [2]
  • [1] The reporter service support code suggestion feature, but reviewdog does not support it yet. See #678 for the status.
  • [2] The reporter service itself doesn't support code suggestion feature.

reviewdog config file

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 both CI service and local environment including editor integration with ease.

.reviewdog.yml

runner:
  <tool-name>:
    cmd: <command> # (required)
    errorformat: # (optional if you use `format`)
      - <list of errorformat>
    format: <format-name> # (optional if you use `errorformat`. e.g. golint,rdjson,rdjsonl)
    name: <tool-name> # (optional. you can overwrite <tool-name> defined by runner key)
    level: <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>

Reporters

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

Reporter: Local (-reporter=local) [default]

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

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

Reporter: GitHub Checks (-reporter=github-pr-check)

github-pr-check sample annotation with option 1 github-pr-check sample

github-pr-check reporter reports results to GitHub Checks.

You can change report level for this reporter by level field in config file or -level flag. You can control GitHub status check result with this feature. (default: error)

Level GitHub Status
info neutral
warning neutral
error failure

There are two options to use this reporter.

Option 1) Run reviewdog from GitHub Actions w/ secrets.GITHUB_TOKEN

Example: .github/workflows/reviewdog.yml

- name: Run reviewdog
  env:
    REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  run: |
    golint ./... | reviewdog -f=golint -reporter=github-pr-check

See GitHub Actions section too. You can also use public reviewdog GitHub Actions.

Option 2) Install reviewdog GitHub Apps

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

  1. Install reviewdog Apps. https://github.com/apps/reviewdog
  2. Set REVIEWDOG_TOKEN or run reviewdog CLI in trusted CI providers.
  • Get token from https://reviewdog.app/gh/{owner}/{repo-name}.
$ export REVIEWDOG_TOKEN="<token>"
$ reviewdog -reporter=github-pr-check

Note: Token is not required if you run reviewdog in Travis or AppVeyor.

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 and GitHub sponsor. See 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.

Reporter: GitHub Checks (-reporter=github-check)

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

sample comment outside diff

You can create reviewdog badge for this reporter.

Reporter: GitHub PullRequest review comment (-reporter=github-pr-review)

sample-comment.png

github-pr-review reporter reports results to GitHub PullRequest review comments using GitHub Personal API Access Token. GitHub Enterprise is supported too.

$ export REVIEWDOG_GITHUB_API_TOKEN="<token>"
$ reviewdog -reporter=github-pr-review

For GitHub Enterprise, set API endpoint by 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 section too if you can use GitHub Actions. You can also use public reviewdog GitHub Actions.

Reporter: GitLab MergeRequest discussions (-reporter=gitlab-mr-discussion)

gitlab-mr-discussion sample

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.

$ export REVIEWDOG_GITLAB_API_TOKEN="<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

Reporter: GitLab MergeRequest commit (-reporter=gitlab-mr-commit)

gitlab-mr-commit is similar to gitlab-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="<token>"
$ reviewdog -reporter=gitlab-mr-commit

Reporter: Gerrit Change review (-reporter=gerrit-change-review)

gerrit-change-review reporter reports result 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://<gerrit-host>:<gerrit-port>
$ reviewdog -reporter=gerrit-change-review

Reporter: Bitbucket Code Insights Reports (-reporter=bitbucket-code-report)

bitbucket-code-report bitbucket-code-annotations

bitbucket-code-report generates the annotated Bitbucket Code Insights report.

For now, only the no-filter mode 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, 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 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 report to 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

Supported CI services

GitHub Actions

Example: .github/workflows/reviewdog.yml

name: reviewdog
on: [pull_request]
jobs:
  reviewdog:
    name: reviewdog
    runs-on: ubuntu-latest
    steps:
      # ...
      - uses: reviewdog/action-setup@v1
        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
Example (github-check reporter):

.github/workflows/reviewdog

Only github-check reporter can run on 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

Public Reviewdog GitHub Actions

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

... and more on GitHub Marketplace.

Missing actions? Check out 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.

Graceful Degradation for Pull Requests from forked repositories

Graceful Degradation example

GITHUB_TOKEN for Pull Requests from forked repository doesn't have write access to Check API nor Review API due to GitHub Actions restriction.

Instead, reviewdog uses Logging commands of GitHub Actions to post results as annotations 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. You can check GitHub Actions log to see full results in such cases.

reviewdog badge reviewdog

As github-check reporter support running on commit, we can create reviewdog GitHub Action badge to check the result against master commit for example. 🎉

Example:

<!-- Replace <OWNER> and <REPOSITORY>. It assumes workflow name is "reviewdog" -->
[![reviewdog](https://github.com/<OWNER>/<REPOSITORY>/workflows/reviewdog/badge.svg?branch=master&event=push)](https://github.com/<OWNER>/<REPOSITORY>/actions?query=workflow%3Areviewdog+event%3Apush+branch%3Amaster)

Travis CI

Travis CI (-reporter=github-pr-check)

If you use -reporter=github-pr-check in Travis CI, you don't need to set REVIEWDOG_TOKEN.

Example:

install:
  - mkdir -p ~/bin/ && export PATH="~/bin/:$PATH"
  - curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b ~/bin

script:
  - reviewdog -conf=.reviewdog.yml -reporter=github-pr-check

Travis CI (-reporter=github-pr-review)

Store GitHub API token by travis encryption keys.

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

Example:

env:
  global:
    - secure: <token>

install:
  - mkdir -p ~/bin/ && export PATH="~/bin/:$PATH"
  - curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b ~/bin

script:
  - >-
    golint ./... | reviewdog -f=golint -reporter=github-pr-review

Examples

Circle CI

Store REVIEWDOG_GITHUB_API_TOKEN (or REVIEWDOG_TOKEN for github-pr-check) in Environment variables - CircleCI

.circleci/config.yml sample

version: 2
jobs:
  build:
    docker:
      - image: golang:latest
    steps:
      - checkout
      - run: curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/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

GitLab CI

Store REVIEWDOG_GITLAB_API_TOKEN in GitLab CI variable.

.gitlab-ci.yml sample

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

Bitbucket Pipelines

No additional configuration is needed.

bitbucket-pipelines.yml sample

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

Common (Jenkins, local, etc...)

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. "haya14busa" for https://github.com/haya14busa/reviewdog)
CI_REPO_NAME repository name (e.g. "reviewdog" for https://github.com/haya14busa/reviewdog)
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="<token>"
$ REVIEWDOG_GITHUB_API_TOKEN="<token>"
$ REVIEWDOG_GITLAB_API_TOKEN="<token>"

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

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

Jenkins with Github pull request builder plugin

$ 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="<token>" reviewdog -reporter=github-pr-check
# Or, to submit directly via API using github-pr-review reporter
$ REVIEWDOG_GITHUB_API_TOKEN="<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="<token>" reviewdog -reporter=github-pr-check

Exit codes

By default reviewdog will return 0 as exit code even if it finds errors. If -fail-on-error flag is passed, reviewdog exits with 1 when at least one error was found/reported. 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.

See also -level flag for github-pr-check/github-check reporters. reviewdog will exit with 1 if reported check status is failure as well if -fail-on-error=true.

Filter mode

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

added (default)

Filter results by added/modified lines.

diff_context

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

file

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.

nofilter

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.

Example:

$ reviewdog -reporter=github-pr-review -filter-mode=nofilter -fail-on-error

Filter Mode Support Table

Note that not all reporters provide full support of filter mode due to API limitation. e.g. github-pr-review reporter uses GitHub Review API but it doesn't support posting comment outside diff (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]
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
  • [1] Report results which is outside diff context with Check annotation as fallback if it's running in GitHub actions instead of Review API (comments). All results will be reported to console as well.
  • [2] Report results which is outside diff file to console.
  • [3] It should work, but not verified yet.
  • [4] Not implemented at the moment

Debugging

Use the -tee flag to show debug info.

reviewdog -filter-mode=nofilter -tee

Articles

🐦 Author

haya14busa GitHub followers

Contributors

Contributors

Supporting reviewdog

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

Become a backer

Comments
  • [bitbucket-code-report] Integration with Bitbucket Code Insights

    [bitbucket-code-report] Integration with Bitbucket Code Insights

  • Use Gitlab suggestions in merge request comments

    Use Gitlab suggestions in merge request comments

    I noticed that the issue found by diff parser is triggering a comment in Gitlab on the correct line but without any explanation, So I decided to append comment with suggested changes in markdown diff format.

    • [x] Updated Unreleased section in CHANGELOG or it's not notable changes.
  • reviewdog: this is not PullRequest build

    reviewdog: this is not PullRequest build

    Details are in this Stack Overflow (https://stackoverflow.com/questions/66309574/reviewdog-this-is-not-pullrequest-build)

    I would like to be able run reviewdog on CircleCI, and when I did git push, it will check the documentation for text errors, and reviewdog will send out a pull-request if there is an error.

    - run: # (d1)
              name: "Execute textlint for README.md"
              command: npx textlint --rule common-misspellings README.md >> .textlint.log
          - run: # (d2)
              name: "Execute reviewdog"
              when: on_fail
              command: |
                cat .textlint.log | ./bin/reviewdog -f=checkstyle -name="textlint" -reporter="github-pr-review"
    

    Before I git push, I set Environment Variables, REVIEWDOG_GITHUB_API_TOKEN and turned on the checkbox, Only build pull requests

    After that, I git push and job, Execute reviewdog said

    #!/bin/bash -eo pipefail
    cat .textlint.log | ./bin/reviewdog -f=checkstyle -name="textlint" -reporter="github-pr-review"
    reviewdog: this is not PullRequest build.
    CircleCI received exit code 0
    

    I would appreciate any help

  • Thoughts on generalized action

    Thoughts on generalized action

    A lot of linters (at least in our neck of the woods) are meant to be installed into the project rather than globally. For one thing, it ensures that CI and the local dev environment are using the same versions.

    So a general reviewdog action would be handy, and one wouldn't have to create a new action for each new linter.

    So I'm attempting to create a generalized action that can take the output of any command and pass it to reviewdog: https://github.com/reload/action-reviewdog (still much a work in progress).

    I had to use a composite action in order to be able to run whatever command was configured (in most interpreted languages the linters also require the interpreter). But that messes with the nice depup action unfortunately.

    What's your thought about this?

  • Check filtered finding when error is on another line than `git diff`

    Check filtered finding when error is on another line than `git diff`

    I'm trying out to create a PHP Linter.

    I have a file like this:

    public function create()
    {
        // i make a mistake below by forgetting the trailing ;  line 33
        blaat()  // <-- line 34
    }
    

    My php linter gives the following error:

    src/AdminBundle/Job/PostAdminMessageToSlackJob.php:35: PHP Parse error: syntax error, unexpected '$job' (T_VARIABLE)
    

    And Reviewdog marks this finding as filtered:

    Findings (0)
    Filtered Findings (1)
    src/AdminBundle/Job/PostAdminMessageToSlackJob.php:35: PHP Parse error: syntax error, unexpected '$job' (T_VARIABLE)
    

    That's because Reviewdog does a strict lookup for the given row number in the git diff. But in PHP the error will sometimes be on the next line.

    Any idea how to solve this?

    Doesn't Github allow for adding checks to lines that didn't change? It always shows ±5 lines before and after right? Maybe we can take that margin into account here?

  • Fails to run on GitHub Actions

    Fails to run on GitHub Actions

    I get the following error in repositories that use Dockerfile with GitHub Actions.

    reviewdog: PullRequest needs 'git' command: failed to run 'git rev-parse --show-prefix': exit status 128
    
    • https://github.com/reviewdog/action-misspell
    • https://github.com/reviewdog/action-stylelint
    • https://github.com/reviewdog/action-coffeelint etc.

    I have investigated and it seems to be related here.

    • https://github.blog/2022-04-12-git-security-vulnerability-announced/
    • https://stackoverflow.com/questions/71849415/cannot-add-parent-directory-to-safe-directory-on-git
    fatal: unsafe repository ('/github/workspace' is owned by someone else)
    To add an exception for this directory, call:
    
    	git config --global --add safe.directory /github/workspace
    

    How do we fix it?

  • Doghouse server is broken after Github API changes

    Doghouse server is broken after Github API changes

    I am trying to run golint on a subdirectory in my repo using this command:

    golint -set_exit_status ./pkg/... | reviewdog -f=golint -diff="git diff origin/master" -reporter=github-pr-check

    But it is giving me a 422 Invalid request error - along with the message: "annotation_level", "path" weren't supplied. []

    I can get this to run successfully by changing my command to this:

    cd pkg && golint -set_exit_status ./... | reviewdog -f=golint -diff="git diff origin/master" -reporter=github-pr-check

    But then the links referenced in the errors don't include the pkg folder, so they don't work.

    I there a reviewdog flag I need to include to be able to make one of the above run commands work properly?

  • Return error exit code when one of the checks fails

    Return error exit code when one of the checks fails

    I'm running Reviewdog in Github Actions. Reviewdog checks php-cs-fixer and phpstan. When it finds errors, they are reported as separate checker results: Screenshot 2020-01-16 at 11 57 18

    But, as you can see, the reviewdog step is ✅.

    This makes it hard to work with, because for the deploy step (not in screenshot) I want to depend on the success of reviewdog + phpunit step. But the reviewdog step is always green. Even tho it found errors.

    Would be great if reviewdog has an option to return an error exit code when one of the runners find an error.

  • go get failed unless GO111MODULE=on

    go get failed unless GO111MODULE=on

    This is expected behavior?

    % go version
    go version go1.12.4 darwin/amd64
    
    % go get -u github.com/reviewdog/reviewdog/cmd/reviewdog
    package github.com/google/go-github/v24/github: cannot find package "github.com/google/go-github/v24/github" in any of:
            /usr/local/Cellar/go/1.12.4/libexec/src/github.com/google/go-github/v24/github (from $GOROOT)
            /Users/hamakn/dev/src/github.com/google/go-github/v24/github (from $GOPATH)
    
    % GO111MODULE=on go get -u github.com/reviewdog/reviewdog/cmd/reviewdog
    // OK if there is no Gopkg.lock
    
  • Error retrieving token for reviewdog.app

    Error retrieving token for reviewdog.app

    I went to https://reviewdog.app/gh/{owner}/{repo} to get my token after setting up the GitHub integration and got this error. When I login at reviewdog.app, it shows that my account is successfully connected. Anything else I can try?

    failed to get repo: &github.ErrorResponse{Response:(*http.Response)(0xc008515170), Message:"Resource not accessible by integration", Errors:[]github.Error(nil), Block:(*struct { Reason string "json:\"reason,omitempty\""; CreatedAt *github.Timestamp "json:\"created_at,omitempty\"" })(nil), DocumentationURL:"https://developer.github.com/v3/repos/#get"}
    
  • Allow GitHub PR reporting for a forked repository iff it's triggered by pull_request_target

    Allow GitHub PR reporting for a forked repository iff it's triggered by pull_request_target

    • [x] Updated Unreleased section in CHANGELOG or it's not notable changes.

    Related to #706, #759

    This PR just allows the pull_request_target trigger even if it's from a forked repo. GITHUB_TOKEN via the trigger has enough read/write permission to call review APIs.

  • fix deprecated configure of goreleaser

    fix deprecated configure of goreleaser

    fix DEPRECATED warnings of goreleaser.

    Run goreleaser/goreleaser-action@v4
    Downloading https://github.com/goreleaser/goreleaser/releases/download/v1.14.0/goreleaser_Linux_x86_64.tar.gz
    Extracting GoReleaser
    /usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/9b1579dd-7d1f-4706-b6b1-b183dc0e8cb3 -f /home/runner/work/_temp/7d60f6ed-4281-4a1c-a0c6-03cd59e6d085
    GoReleaser latest installed successfully
    /opt/hostedtoolcache/goreleaser-action/1.14.0/x64/goreleaser check
      • loading config file                              file=.goreleaser.yml
      • checking config...
        • DEPRECATED: `archives.rlcp` will be the default soon, check https://goreleaser.com/deprecations#archivesrlcp for more info
        • DEPRECATED: `archives.replacements` should not be used anymore, check https://goreleaser.com/deprecations#archivesreplacements for more info
      ⨯ command failed                                   error=config is valid, but uses deprecated properties, check logs above for details
    Error: The process '/opt/hostedtoolcache/goreleaser-action/1.14.0/x64/goreleaser' failed with exit code 2
    

    The log of goreleaser release --snapshot --rm-dist is here:

    % goreleaser release --snapshot --rm-dist
      • starting release...
      • loading config file                              file=.goreleaser.yml
      • loading environment variables
      • getting and validating git state
        • building...                                    commit=2c9939c287e19d12fbb6195d286ea654f3479fc8 latest tag=v0.14.1
        • pipe skipped                                   reason=disabled during snapshot mode
      • parsing tag
      • setting defaults
      • running before hooks
        • running                                        hook=go mod download
      • snapshotting
        • building snapshot...                           version=v0.14.1-next
      • checking distribution directory
        • --rm-dist is set, cleaning it up
      • loading go mod information
      • build prerequisites
      • writing effective config file
        • writing                                        config=dist/config.yaml
      • building binaries
        • building                                       binary=dist/reviewdog_windows_arm64/reviewdog.exe
        • building                                       binary=dist/reviewdog_windows_386/reviewdog.exe
        • building                                       binary=dist/reviewdog_darwin_amd64_v1/reviewdog
        • building                                       binary=dist/reviewdog_linux_386/reviewdog
        • building                                       binary=dist/reviewdog_linux_amd64_v1/reviewdog
        • building                                       binary=dist/reviewdog_windows_arm_6/reviewdog.exe
        • building                                       binary=dist/reviewdog_windows_amd64_v1/reviewdog.exe
        • building                                       binary=dist/reviewdog_darwin_arm64/reviewdog
        • building                                       binary=dist/reviewdog_linux_arm_6/reviewdog
        • building                                       binary=dist/reviewdog_linux_arm64/reviewdog
        • took: 1s
      • archives
        • creating                                       archive=dist/reviewdog_v0.14.1-next_Windows_x86_64.tar.gz
        • creating                                       archive=dist/reviewdog_v0.14.1-next_Linux_x86_64.tar.gz
        • creating                                       archive=dist/reviewdog_v0.14.1-next_Darwin_arm64.tar.gz
        • creating                                       archive=dist/reviewdog_v0.14.1-next_Linux_arm64.tar.gz
        • creating                                       archive=dist/reviewdog_v0.14.1-next_Linux_armv6.tar.gz
        • creating                                       archive=dist/reviewdog_v0.14.1-next_Windows_arm64.tar.gz
        • creating                                       archive=dist/reviewdog_v0.14.1-next_Darwin_x86_64.tar.gz
        • creating                                       archive=dist/reviewdog_v0.14.1-next_Windows_i386.tar.gz
        • creating                                       archive=dist/reviewdog_v0.14.1-next_Windows_armv6.tar.gz
        • creating                                       archive=dist/reviewdog_v0.14.1-next_Linux_i386.tar.gz
        • took: 2s
      • calculating checksums
      • homebrew tap formula
        • guessing install to be "bin.install \"reviewdog\""
        • guessing install to be "bin.install \"reviewdog\""
        • guessing install to be "bin.install \"reviewdog\""
        • guessing install to be "bin.install \"reviewdog\""
        • guessing install to be "bin.install \"reviewdog\""
        • writing                                        formula=dist/reviewdog.rb
      • storing release metadata
        • writing                                        file=dist/artifacts.json
        • writing                                        file=dist/metadata.json
      • release succeeded after 3s
    
    • [x] Updated Unreleased section in CHANGELOG or it's not notable changes.
  • Is there any plan to allow for config via environment variables?

    Is there any plan to allow for config via environment variables?

    Is there any plan to allow for config via environment variables?

    Specifically I'm looking for REVIEWDOG_DIFF and REVIEWDOG_REPORTER.

    The reason for these options is I'm looking to run reviewdog as both a pre-commit hook and a CI job. Setting via environment would be easier.

    Thanks for this awesome tool.

  • fix(deps): update module gopkg.in/yaml.v2 to v3

    fix(deps): update module gopkg.in/yaml.v2 to v3

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | gopkg.in/yaml.v2 | require | major | v2.4.0 -> v3.0.1 |


    Release Notes

    go-yaml/yaml

    v3.0.1

    Compare Source

    v3.0.0

    Compare Source


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Bitbucket Cloud fixes

    Bitbucket Cloud fixes

    • Addresses some of the bugs in https://github.com/reviewdog/reviewdog/issues/1285
      • Limit length of Annotation Summaries to 450 characters. The annotation model for Bitbucket server appears to be different.
      • Delete report before recreating to purge old annotations (to avoid the 1000 annotation limit). This is in line with the Bitbucket Server implementation.
      • Does NOT show bitbucket error strings to user.
      • Does NOT limit the number of annotations to 1000 or warn.
    • [x] Updated Unreleased section in CHANGELOG or it's not notable changes.
  • chore(deps): update google-github-actions/setup-gcloud action to v1

    chore(deps): update google-github-actions/setup-gcloud action to v1

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | google-github-actions/setup-gcloud | action | major | v0.6.2 -> v1.0.1 |


    Release Notes

    google-github-actions/setup-gcloud

    v1.0.1

    Compare Source

    What's Changed

    Full Changelog: https://github.com/google-github-actions/setup-gcloud/compare/v1.0.0...v1.0.1

    v1.0.0

    Compare Source

    What's Changed
    New Contributors

    Full Changelog: https://github.com/google-github-actions/setup-gcloud/compare/v0.6.2...v1.0.0


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • chore(deps): update dependency textlint-rule-no-dead-link to v5

    chore(deps): update dependency textlint-rule-no-dead-link to v5

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | textlint-rule-no-dead-link | ^4.7.0 -> ^5.0.0 | age | adoption | passing | confidence |


    Release Notes

    textlint-rule/textlint-rule-no-dead-link

    v5.1.2

    Compare Source

    Bug Fixes
    • delete keepAlive options (0930067)

    v5.1.1

    Compare Source

    v5.1.0

    Compare Source

    Bug Fixes
    • use import type for typing (8446573)
    Features
    • add maxRetryAfterTime option (dbeed6b)

    v5.0.0

    Compare Source

    Features
    BREAKING CHANGES
    • It depended on textlint 12.2.0>=
    • delete experimental keepAlive optoin

    v4.8.0

    Compare Source

    Bug Fixes
    • fix handling of redirects (e834ab0)
    • fix redirect condition (9350dbe)
    Features
    • rule: add maxRetryTime option (#​136) (9f9c636)
      • Add handling of Retry-After resposne header

    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

A Golang tool that does static analysis, unit testing, code review and generate code quality report.
A Golang tool that does static analysis, unit testing, code review and generate code quality report.

goreporter A Golang tool that does static analysis, unit testing, code review and generate code quality report. This is a tool that concurrently runs

Jan 8, 2023
a simple golang SSA viewer tool use for code analysis or make a linter
a simple golang SSA viewer tool use for code analysis or make a linter

ssaviewer A simple golang SSA viewer tool use for code analysis or make a linter ssa.html generate code modify from src/cmd/compile/internal/ssa/html.

May 17, 2022
This static analysis tool works to ensure your program's data flow does not spill beyond its banks.

Go Flow Levee This static analysis tool works to ensure your program's data flow does not spill beyond its banks. An input program's data flow is expl

Dec 1, 2022
Analyzer: zapvet is static analysis tool for zap

zapvet zapvet is static analysis tool for zap. fieldtype: fieldtype finds confliction type of field Install You can get zapvet by go install command (

Sep 18, 2022
Retnilnil is a static analysis tool to detect `return nil, nil`

retnilnil retnilnil is a static analysis tool for Golang that detects return nil, nil in functions with (*T, error) as the return type. func f() (*T,

Jun 9, 2022
Tool: ptrls prints result of pointer analysis

ptrls Install $ go install github.com/gostaticanalysis/ptrls/cmd/ptrls@latest Usage $ cd testdata/a $ cat a.go package main func main() { f(map[str

Feb 1, 2022
octocov is a tool for collecting code metrics (code coverage, code to test ratio and test execution time).

octocov is a tool for collecting code metrics (code coverage, code to test ratio and test execution time).

Jan 9, 2023
[mirror] Performance measurement, storage, and analysis.

Go performance measurement, storage, and analysis tools This subrepository holds the source for various packages and tools related to performance meas

Dec 24, 2022
GoKart - Go Security Static Analysis
 GoKart - Go Security Static Analysis

GoKart is a static analysis tool for Go that finds vulnerabilities using the SSA (single static assignment) form of Go source code.

Jan 1, 2023
Detect non-inclusive language in your source code.
Detect non-inclusive language in your source code.

Detect non-inclusive language in your source code. I stay woke - Erykah Badu Creating an inclusive work environment is imperative to a healthy, suppor

Dec 25, 2022
The most opinionated Go source code linter for code audit.
The most opinionated Go source code linter for code audit.

go-critic Highly extensible Go source code linter providing checks currently missing from other linters. There is never too much static code analysis.

Jan 6, 2023
Sloc, Cloc and Code: scc is a very fast accurate code counter with complexity calculations and COCOMO estimates written in pure Go
Sloc, Cloc and Code: scc is a very fast accurate code counter with complexity calculations and COCOMO estimates written in pure Go

Sloc Cloc and Code (scc) A tool similar to cloc, sloccount and tokei. For counting physical the lines of code, blank lines, comment lines, and physica

Jan 4, 2023
a tool for code clone detection

dupl dupl is a tool written in Go for finding code clones. So far it can find clones only in the Go source files. The method uses suffix tree for seri

Dec 12, 2022
depth is tool to retrieve and visualize Go source code dependency trees.

depth is tool to retrieve and visualize Go source code dependency trees. Install Download the appropriate binary for your platform from the Rele

Dec 30, 2022
Tool to populate your code with traceable and secure error codes

Essential part of any project, especially customer facing is proper and secure error handling. When error happens and customer reports it, it would be nice to know the context of the error and where it exactly occured.

Sep 28, 2022
Refactoring and code transformation tool for Go.

gopatch is a tool to match and transform Go code. It is meant to aid in refactoring and restyling.

Dec 30, 2022
[mirror] This is a linter for Go source code.

Golint is a linter for Go source code. Installation Golint requires a supported release of Go. go get -u golang.org/x/lint/golint To find out where g

Dec 23, 2022
Run linters from Go code -

Lint - run linters from Go Lint makes it easy to run linters from Go code. This allows lint checks to be part of a regular go build + go test workflow

Sep 27, 2022