Skip to content

Conversation

never112
Copy link
Contributor

@never112 never112 commented Oct 30, 2024

    • 版本检查
      无配置:>=10.8 版本 comments+discussion,<10.8版本使用comments,
      有配置:>=10.8 版本 使用配置,<10.8版本使用comments.
      全局无配置,repo无配置,->无配置
      全局无配置,repo有配置 ,->repo配置
      全局有配置,repo有配置,->repo配置
    • linter结果汇总 comment输出。
    • 单条linter结果 discussion 输出。
    • linter结果汇总 表格形式
    • 拉取代码使用 accesstoken 方式
      github/gitlab 统一使用 accesstokne的方式拉取代码 需要重新设计?
    • 解决linter检查 错误
    • gitlab 使用 accesstoken 拉取代码,不改动原有逻辑, 在gitlab handler 中实现

report: comment:
Fail:Folding
image
Fail: Unfolding
image
pass:
image

report:discussion
image

comments-table
image

Copy link

netlify bot commented Oct 30, 2024

Deploy Preview for reviewbot-x canceled.

Name Link
🔨 Latest commit 3ff170b
🔍 Latest deploy log https://app.netlify.com/sites/reviewbot-x/deploys/67396b989f643d0008e16e88

@never112 never112 force-pushed the zhou1025 branch 4 times, most recently from f51dbab to 6fedd79 Compare October 30, 2024 09:34
Copy link

codecov bot commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 1.28388% with 692 lines in your changes missing coverage. Please review.

Project coverage is 25.61%. Comparing base (9aab280) to head (3ff170b).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
internal/linters/providergitlab.go 0.00% 436 Missing ⚠️
server.go 0.00% 209 Missing ⚠️
internal/linters/hunk.go 0.00% 25 Missing ⚠️
main.go 0.00% 19 Missing ⚠️
config/config.go 75.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #428      +/-   ##
==========================================
- Coverage   30.13%   25.61%   -4.53%     
==========================================
  Files          30       31       +1     
  Lines        3796     4467     +671     
==========================================
  Hits         1144     1144              
- Misses       2515     3185     +670     
- Partials      137      138       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@never112 never112 force-pushed the zhou1025 branch 3 times, most recently from 49ecb83 to 4ae269d Compare October 30, 2024 10:27
@never112 never112 force-pushed the zhou1025 branch 2 times, most recently from dc22817 to 194c8c3 Compare October 30, 2024 10:58
@never112 never112 force-pushed the zhou1025 branch 12 times, most recently from d313f1c to ebfda9b Compare November 6, 2024 09:02
@never112 never112 force-pushed the zhou1025 branch 9 times, most recently from 26a954c to 70ee7fe Compare November 13, 2024 06:10
Copy link

qiniu-x bot commented Nov 17, 2024

[Git-flow] Hi @never112, There are some suggestions for your information:


Rebase suggestions

  • Following commits seems generated via git merge

    Merge remote-tracking branch 'upstream/master' into zhou1025

    Merge branch 'zhou1025' of github.com:never112/reviewbot into zhou1025

    Merge branch 'zhou1025' of github.com:never112/reviewbot into zhou1025

    Merge branch 'zhou1025' of github.com:never112/reviewbot into zhou1025

  • Following commits have duplicated messages

    fix linter error

    fix linter error

    Merge branch 'zhou1025' of github.com:never112/reviewbot into zhou1025

    Merge branch 'zhou1025' of github.com:never112/reviewbot into zhou1025

    Merge branch 'zhou1025' of github.com:never112/reviewbot into zhou1025

    fix main conflict

    fix main conflict

    fix main conflict

Which seems insignificant, recommend to use git rebase command to reorganize your PR.

For other git-flow instructions, recommend refer to these examples.

If you have any questions about this comment, feel free to raise an issue here:

return fmt.Sprintf("[**%s**]", linterName)
}

func (g *GitlabProvider) Report(ctx context.Context, a Agent, lintResults map[string][]LinterOutput) error {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-lint] reported by reviewbot🐮
cognitive complexity 33 of func (*GitlabProvider).Report is high (> 30) (gocognit)

num := a.Provider.GetCodeReviewInfo().Number
orgRepo := fmt.Sprintf("%s/%s", org, repo)
reportformat := ReportFormMatCheck(g.GitLabClient, a.LinterConfig.ReportType)
switch reportformat {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-lint] reported by reviewbot🐮
missing cases in switch of type config.ReportType: config.GithubCheckRuns, config.GithubPRReview, config.GithubMixType (exhaustive)


func ListMergeRequestsFiles(ctx context.Context, gc *gitlab.Client, owner string, repo string, pid int, number int) ([]*gitlab.MergeRequestDiff, *gitlab.Response, error) {
// For version compatibility,because verion below 10.8 not support ListMergeRequestDiffs
files, response, err := gc.MergeRequests.GetMergeRequestChanges(pid, number, nil)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-lint] reported by reviewbot🐮
SA1019: gc.MergeRequests.GetMergeRequestChanges is deprecated: This endpoint has been replaced by MergeRequestsService.ListMergeRequestDiffs() (staticcheck)

return s.gitlabHandle(ctx, event)
}

func (s *Server) gitlabHandle(ctx context.Context, event *gitlab.MergeEvent) error {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-lint] reported by reviewbot🐮
cognitive complexity 35 of func (*Server).gitlabHandle is high (> 30) (gocognit)

log.Fatalf("Failed to create client: %v", err)
}
return git
}

func (s *Server) handle(ctx context.Context, event *github.PullRequestEvent) error {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-lint] reported by reviewbot🐮
cognitive complexity 31 of func (*Server).handle is high (> 30) (gocognit)

} else {
log.Infof("no .gitmodules file in repo %s", repo)
}
for name, fn := range linters.TotalPullRequestHandlers() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-lint] reported by reviewbot🐮
empty-lines: extra empty line at the start of a block (revive)

@@ -220,6 +231,10 @@ func (s *Server) pullImageWithRetry(ctx context.Context, image string, dockerRun
}

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-lint] reported by reviewbot🐮
Non-inherited new context, use function like context.WithXXX or r.Context instead (contextcheck)

@@ -20,6 +20,7 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-lint] reported by reviewbot🐮
SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck)

eventGUID = eventGUID[len(eventGUID)-12:]
}
ctx := context.WithValue(context.Background(), lintersutil.EventGUIDKey, eventGUID)
log := lintersutil.FromContext(ctx)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-lint] reported by reviewbot🐮
Non-inherited new context, use function like context.WithXXX or r.Context instead (contextcheck)

func (o options) Validate() error {
if o.accessToken == "" && o.appID == 0 {
return errors.New("either access-token or github app information should be provided")
if o.gitHubAccessToken == "" && o.appID == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewbot 应当允许只使用 gitlab ,这里就不合适了

@@ -220,6 +231,10 @@ func (s *Server) pullImageWithRetry(ctx context.Context, image string, dockerRun
}

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("X-Gitlab-Event") != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github 也需要包装下

@@ -63,6 +69,38 @@ func NewFileHunkChecker(commitFiles []*github.CommitFile) (*FileHunkChecker, err
Hunks: hunks,
}, nil
}
func NewGitLabCommitFileHunkChecker(commitFiles []*gitlab.MergeRequestDiff) (*FileHunkChecker, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件应该剥离 对github 和 gitlab的耦合

@@ -6,7 +6,8 @@
# 3. Conducting specific gray testing for a particular feature.

globalDefaultConfig: # global default settings, will be overridden by qbox org and repo specific settings if they exist
githubReportType: "github_check_run" # github_pr_review, github_check_run, github_mix
githubReportType: "github_check_run" # github_pr_review, github_check_run
gitlabReportType: "gitlab_mr_comment_discussion" # gitlab_mr_comment, gitlab_mr_discussion,gitlab_mr_comment_discussion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码里应该要有最佳实践,通常这里不需要配置

@CarlJi CarlJi merged commit 6766b6c into qiniu:master Nov 17, 2024
7 of 8 checks passed
@CarlJi CarlJi mentioned this pull request Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants