]> source.dussan.org Git - gitea.git/commitdiff
Upgrade golangci-lint to 1.24.0 (#10894)
authorzeripath <art27@cantab.net>
Mon, 30 Mar 2020 18:52:45 +0000 (19:52 +0100)
committerGitHub <noreply@github.com>
Mon, 30 Mar 2020 18:52:45 +0000 (21:52 +0300)
* upgrade golangci-lint to 1.24.0 to allow go 1.14 compatibility
* fix golangci-lint errors
* make make golangci-lint work when out of go-path

Signed-off-by: Andrew Thornton <art27@cantab.net>
Makefile
models/error.go
models/notification.go
modules/private/key.go
modules/private/manager.go
routers/repo/compare.go
routers/repo/pull_review.go

index 745cdb260137a9d38c31cf655e1618debcd1fb1b..f34658d5708c93320fb8d3367893ba267d649277 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -621,6 +621,6 @@ pr\#%: clean-all
 golangci-lint:
        @hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
                export BINARY="golangci-lint"; \
-               curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.20.0; \
+               curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.24.0; \
        fi
-       golangci-lint run --timeout 5m
+       env GO111MODULE=on golangci-lint run --timeout 5m
index a5b62b85ec84bdf920a449acfc34758180438916..f53479fac82cbc5eed92bd31778f975932fe6a35 100644 (file)
@@ -227,7 +227,7 @@ func IsErrUserNotAllowedCreateOrg(err error) bool {
 }
 
 func (err ErrUserNotAllowedCreateOrg) Error() string {
-       return fmt.Sprintf("user is not allowed to create organizations")
+       return "user is not allowed to create organizations"
 }
 
 // ErrReachLimitOfRepo represents a "ReachLimitOfRepo" kind of error.
@@ -561,7 +561,7 @@ func IsErrAccessTokenEmpty(err error) bool {
 }
 
 func (err ErrAccessTokenEmpty) Error() string {
-       return fmt.Sprintf("access token is empty")
+       return "access token is empty"
 }
 
 // ________                            .__                __  .__
@@ -1107,7 +1107,7 @@ func IsErrSHAOrCommitIDNotProvided(err error) bool {
 }
 
 func (err ErrSHAOrCommitIDNotProvided) Error() string {
-       return fmt.Sprintf("a SHA or commmit ID must be proved when updating a file")
+       return "a SHA or commmit ID must be proved when updating a file"
 }
 
 //  __      __      ___.   .__                   __
index daf13faf87b33071b456b5450c40f68457cceac7..0cee8616cadf50b675982090eafa268927b10d49 100644 (file)
@@ -611,7 +611,7 @@ func (nl NotificationList) LoadIssues() ([]int, error) {
 
 // Without returns the notification list without the failures
 func (nl NotificationList) Without(failures []int) NotificationList {
-       if failures == nil || len(failures) == 0 {
+       if len(failures) == 0 {
                return nl
        }
        remaining := make([]*Notification, 0, len(nl))
index 40e1c492f8ef53a917bfd70065d212fb71e7cadd..bea7837906a0c949ee5daa8af96eacaa0898a364 100644 (file)
@@ -34,7 +34,7 @@ func UpdatePublicKeyInRepo(keyID, repoID int64) error {
 // and returns public key found.
 func AuthorizedPublicKeyByContent(content string) (string, error) {
        // Ask for running deliver hook and test pull request tasks.
-       reqURL := setting.LocalURL + fmt.Sprintf("api/internal/ssh/authorized_keys")
+       reqURL := setting.LocalURL + "api/internal/ssh/authorized_keys"
        req := newInternalRequest(reqURL, "POST")
        req.Param("content", content)
        resp, err := req.Response()
index de46c7ab2cae8ff733c27b6aba82093949a1ea17..503acf17d64e9baf2b59fd50284819c79ac7fb87 100644 (file)
@@ -15,7 +15,7 @@ import (
 
 // Shutdown calls the internal shutdown function
 func Shutdown() (int, string) {
-       reqURL := setting.LocalURL + fmt.Sprintf("api/internal/manager/shutdown")
+       reqURL := setting.LocalURL + "api/internal/manager/shutdown"
 
        req := newInternalRequest(reqURL, "POST")
        resp, err := req.Response()
@@ -33,7 +33,7 @@ func Shutdown() (int, string) {
 
 // Restart calls the internal restart function
 func Restart() (int, string) {
-       reqURL := setting.LocalURL + fmt.Sprintf("api/internal/manager/restart")
+       reqURL := setting.LocalURL + "api/internal/manager/restart"
 
        req := newInternalRequest(reqURL, "POST")
        resp, err := req.Response()
@@ -57,7 +57,7 @@ type FlushOptions struct {
 
 // FlushQueues calls the internal flush-queues function
 func FlushQueues(timeout time.Duration, nonBlocking bool) (int, string) {
-       reqURL := setting.LocalURL + fmt.Sprintf("api/internal/manager/flush-queues")
+       reqURL := setting.LocalURL + "api/internal/manager/flush-queues"
 
        req := newInternalRequest(reqURL, "POST")
        if timeout > 0 {
index 4769a4da1aa7807d3c39bbf42d9f7a11735c55d4..815ec3565033bd1167307a3789ea057020a2e120 100644 (file)
@@ -422,7 +422,6 @@ func CompareDiff(ctx *context.Context) {
        beforeCommitID := ctx.Data["BeforeCommitID"].(string)
        afterCommitID := ctx.Data["AfterCommitID"].(string)
 
-
        ctx.Data["Title"] = "Comparing " + base.ShortSha(beforeCommitID) + "..." + base.ShortSha(afterCommitID)
 
        ctx.Data["IsRepoToolbarCommits"] = true
index 9fcb02cd4ab630fbd3c5d5537e7b1b7abdd9aa75..0f5375dc166fd5beaa1d1a25dc2566e03b8b6adc 100644 (file)
@@ -51,13 +51,14 @@ func CreateCodeComment(ctx *context.Context, form auth.CodeCommentForm) {
                return
        }
 
-       log.Trace("Comment created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID)
-
-       if comment != nil {
-               ctx.Redirect(comment.HTMLURL())
-       } else {
+       if comment == nil {
+               log.Trace("Comment not created: %-v #%d[%d]", ctx.Repo.Repository, issue.Index, issue.ID)
                ctx.Redirect(fmt.Sprintf("%s/pulls/%d/files", ctx.Repo.RepoLink, issue.Index))
+               return
        }
+
+       log.Trace("Comment created: %-v #%d[%d] Comment[%d]", ctx.Repo.Repository, issue.Index, issue.ID, comment.ID)
+       ctx.Redirect(comment.HTMLURL())
 }
 
 // SubmitReview creates a review out of the existing pending review or creates a new one if no pending review exist