Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gofmt): it is recommended to display gofmt reports on GitHubPRReviews #167

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/website/docs/components/go/gofmt.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ sidebar_position: 2

**Reviewbot** 会执行**gofmt**检查,确保这个规范在组织内被有效贯彻。

值得注意的是,如果**Reviewbot**检测出格式问题,她会以[suggest changes](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/incorporating-feedback-in-your-pull-request)形式直接comment目标代码行,相对优雅些。
值得注意的是,如果**Reviewbot**检测出格式问题,她会以[suggest changes](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/incorporating-feedback-in-your-pull-request)形式直接comment目标代码行,相对优雅些。

:::info
由于 check run 模式下不支持GitHub Suggestion 功能,因此,gofmt 固定使用 GitHub PR Review 风格来反馈捕获到的问题。
Issue详情参见: https://github.com/qiniu/reviewbot/issues/166
:::
5 changes: 5 additions & 0 deletions internal/linters/go/gofmt/gofmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"strconv"
"strings"

"github.com/qiniu/reviewbot/config"
"github.com/qiniu/reviewbot/internal/linters"
"github.com/qiniu/x/log"
"github.com/qiniu/x/xlog"
Expand All @@ -24,6 +25,10 @@
a.LinterConfig.Args = append([]string{}, "-d", "./")
}

// Since GitHub's check run feature does not have the suggestion functionality, GitHub PR review is fixed used to display gofmt reports.
// Details: https://github.com/qiniu/reviewbot/issues/166
a.LinterConfig.ReportFormat = config.GithubPRReview

Check warning on line 30 in internal/linters/go/gofmt/gofmt.go

View check run for this annotation

Codecov / codecov/patch

internal/linters/go/gofmt/gofmt.go#L30

Added line #L30 was not covered by tests

executor, err := NewgofmtExecutor(a.LinterConfig.WorkDir)
if err != nil {
log.Errorf("init gofmt executor failed: %v", err)
Expand Down
Loading