reviewdog

所属分类:collect
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2023-07-20 10:10:09
上 传 者sh-1993
说明:  自动代码审查工具与任何代码分析工具集成,而不管编程语言如何,
(Automated code review tool integrated with any code analysis tools regardless of programming language,)

文件列表:
.circleci/ (0, 2024-01-07)
.circleci/config.yml (635, 2024-01-07)
.codecov.yml (128, 2024-01-07)
.goreleaser-nightly.yml (1109, 2024-01-07)
.goreleaser.yml (1355, 2024-01-07)
.reviewdog.yml (950, 2024-01-07)
.revive.toml (317, 2024-01-07)
.textlintrc (145, 2024-01-07)
.travis.yml (980, 2024-01-07)
CHANGELOG.md (8759, 2024-01-07)
LICENSE (1067, 2024-01-07)
_testdata/ (0, 2024-01-07)
_testdata/custom.txt (130, 2024-01-07)
_testdata/custom_rdjson.json (4023, 2024-01-07)
_testdata/golint.go (28, 2024-01-07)
_testdata/golint2.go (34, 2024-01-07)
_testdata/reviewdog_error.yml (179, 2024-01-07)
_testdata/staticcheck.go (123, 2024-01-07)
_testdata/suggestions.json (2644, 2024-01-07)
_testdata/suggestions.txt (178, 2024-01-07)
cienv/ (0, 2024-01-07)
cienv/_testdata/ (0, 2024-01-07)
cienv/_testdata/github_event_pull_request.json (26360, 2024-01-07)
... ...

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


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. [design doc](https://docs.google.com/document/d/1mGOX19SSqRowWGbXieBfGPtLnM0BdTkIc9JelTiu6wA/edit?usp=sharing) ## Table of Contents - [Installation](#installation) - [Input Format](#input-format) * ['errorformat'](#errorformat) * [Available pre-defined 'errorformat'](#available-pre-defined-errorformat) * [Reviewdog Diagnostic Format (RDFormat)](#reviewdog-diagnostic-format-rdformat) * [Diff](#diff) * [checkstyle format](#checkstyle-format) * [SARIF format](#sarif-format) - [Code Suggestions](#code-suggestions) - [reviewdog config file](#reviewdog-config-file) - [Reporters](#reporters) * [Reporter: Local (-reporter=local) [default]](#reporter-local--reporterlocal-default) * [Reporter: GitHub Checks (-reporter=github-pr-check)](#reporter-github-checks--reportergithub-pr-check) * [Reporter: GitHub Checks (-reporter=github-check)](#reporter-github-checks--reportergithub-check) * [Reporter: GitHub PullRequest review comment (-reporter=github-pr-review)](#reporter-github-pullrequest-review-comment--reportergithub-pr-review) * [Reporter: GitLab MergeRequest discussions (-reporter=gitlab-mr-discussion)](#reporter-gitlab-mergerequest-discussions--reportergitlab-mr-discussion) * [Reporter: GitLab MergeRequest commit (-reporter=gitlab-mr-commit)](#reporter-gitlab-mergerequest-commit--reportergitlab-mr-commit) * [Reporter: Bitbucket Code Insights Reports (-reporter=bitbucket-code-report)](#reporter-bitbucket-code-insights-reports--reporterbitbucket-code-report) - [Supported CI services](#supported-ci-services) * [GitHub Actions](#github-actions) * [Travis CI](#travis-ci) * [Circle CI](#circle-ci) * [GitLab CI](#gitlab-ci) * [Bitbucket Pipelines](#bitbucket-pipelines) * [Common (Jenkins, local, etc...)](#common-jenkins-local-etc) + [Jenkins with GitHub pull request builder plugin](#jenkins-with-github-pull-request-builder-plugin) - [Exit codes](#exit-codes) - [Filter mode](#filter-mode) - [Articles](#articles) [![github-pr-check sample](https://user-images.githubusercontent.com/3797062/40884858-6efd82a0-6756-11e8-9f1a-c6af4f920fb0.png)](https://github.com/reviewdog/reviewdog/pull/131/checks) ![comment in pull-request](https://user-images.githubusercontent.com/3797062/40941822-1d775064-6887-11e8-98e9-4775d37d47f8.png) ![commit status](https://user-images.githubusercontent.com/3797062/40941738-d62acb0a-6886-11e8-858d-7b97aded2a42.png) [![sample-comment.png](https://raw.githubusercontent.com/haya14busa/i/dc0ccb1e110515ea407c146d99b749018db05c45/reviewdog/sample-comment.png)](https://github.com/reviewdog/reviewdog/pull/24#discussion_r84599728) ![reviewdog-local-demo.gif](https://raw.githubusercontent.com/haya14busa/i/dc0ccb1e110515ea407c146d99b749018db05c45/reviewdog/reviewdog-local-demo.gif) ## Installation ```shell # 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](https://github.com/reviewdog/nightly) to try the latest reviewdog improvements every day! ```shell $ curl -sfL https://raw.githubusercontent.com/reviewdog/nightly/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ``` ### GitHub Action: [reviewdog/action-setup](https://github.com/reviewdog/action-setup) ```yaml 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: ```shell $ brew install reviewdog/tap/reviewdog $ brew upgrade reviewdog/tap/reviewdog ``` ### [Scoop](https://scoop.sh/) on Windows ``` > scoop install reviewdog ``` ### Build with go install ```shell $ 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'**](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. ```shell $ 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. ### 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}`. ```shell $ 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/ ... ``` ```shell $ 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 Diagnostic Format (RDFormat) reviewdog supports [Reviewdog Diagnostic Format (RDFormat)](./proto/rdf/) as a generic diagnostic format and it supports both [rdjson](./proto/rdf/#rdjson) and [rdjsonl](./proto/rdf/#rdjsonl) formats. This rdformat supports rich features like multiline ranged comments, severity, rule code with URL, and [code suggestions](#code-suggestions). ```shell $ | | reviewdog -f=rdjson -reporter=github-pr-review # or $ | | reviewdog -f=rdjsonl -reporter=github-pr-review ``` #### Example: ESLint with RDFormat ![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. ```shell $ 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. ### Diff ![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) ```shell $ # 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. ```shell $ 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](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'. ```shell # 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. ```shell $ | | reviewdog -f=checkstyle -name="" -reporter=github-pr-check ``` ### SARIF format reviewdog supports [SARIF 2.1.0 JSON format](https://sarifweb.azurewebsites.net/). You can use reviewdog with -f=sarif option. ```shell # Local $ eslint -f @microsoft/eslint-formatter-sarif . | reviewdog -f=sarif -diff="git diff" ```` ## Code Suggestions ![eslint reviewdog suggestion demo](https://user-images.githubusercontent.com/3797062/97085944-87233a80-165b-11eb-94a8-0a47d5e24905.png) ![reviewdog with gofmt example](https://user-images.githubusercontent.com/3797062/89168305-a3ad5a80-d5b7-11ea-8939-be7ac1976d30.png) 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. ### Code Suggestions Support Table 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-pr-review`** | OK | | **`gitlab-mr-discussion`** | NO [1] | | **`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 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 for both CI service and local environment including editor integration with ease. #### .reviewdog.yml ```yaml 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 ``` ```shell $ 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. - `: [] ` - `:: [] ` - `::: [] ` ## Reporters reviewdog can report results both in the 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 the diff command as `-diff` arg. ```shell $ golint ./... | reviewdog -f=golint -diff="git diff FETCH_HEAD" ``` ### Reporter: GitHub Checks (-reporter=github-pr-check) [![github-pr-check sample annotation with option 1](https://user-images.githubusercontent.com/3797062/64875597-65016f80-d688-11e9-843f-4679fb666f0d.png)](https://github.com/reviewdog/reviewdog/pull/275/files#annotation_6177941961779419) [![github-pr-check sample](https://user-images.githubusercontent.com/3797062/40884858-6efd82a0-6756-11e8-9f1a-c6af4f920fb0.png)](https://github.com/reviewdog/reviewdog/pull/131/checks) 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. #### Option 1) Run reviewdog from GitHub Actions w/ secrets.GITHUB_TOKEN Example: [.github/workflows/reviewdog.yml](.github/workflows/reviewdog.yml) ```yaml - name: Run reviewdog env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | golint ./... | reviewdog -f=golint -reporter=github-pr-check ``` See [GitHub Actions](#github-actions) section too. You can also use public reviewdog GitHub Actions. #### Option 2) Install reviewdog GitHub Apps 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 2. Set `REVIEWDOG_TOKEN` or run reviewdog CLI in trusted CI providers. - Get token from `https://reviewdog.app/gh/{owner}/{repo-name}`. ```shell $ export REVIEWDOG_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](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. ### Reporter ... ...

近期下载者

相关文件


收藏者