Fix golangci-lint warnings (#17598 et al) (#17668)

Backport #17598 
Backport #17606 
Backport #17608 
Backport #17609

- Since https://gitea.com/gitea/test-env/pulls/10 the golangci-lint has been upgraded and is erroring about new warnings in the code, this PR fixes those warnings.
This commit is contained in:
Gusted
2021-11-16 20:38:49 +00:00
committed by GitHub
parent 1cec7f5ab5
commit ea0fe83888
96 changed files with 139 additions and 64 deletions

View File

@ -9,7 +9,6 @@ linters:
- unused - unused
- structcheck - structcheck
- varcheck - varcheck
- golint
- dupl - dupl
#- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time. #- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
- gofmt - gofmt

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//+build vendor //go:build vendor
// +build vendor
package main package main

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -1,3 +1,4 @@
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -1,3 +1,4 @@
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -6,6 +6,7 @@
// gocovmerge takes the results from multiple `go test -coverprofile` runs and // gocovmerge takes the results from multiple `go test -coverprofile` runs and
// merges them into one profile // merges them into one profile
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -43,7 +43,11 @@ func runDocs(ctx *cli.Context) error {
// Clean up markdown. The following bug was fixed in v2, but is present in v1. // Clean up markdown. The following bug was fixed in v2, but is present in v1.
// It affects markdown output (even though the issue is referring to man pages) // It affects markdown output (even though the issue is referring to man pages)
// https://github.com/urfave/cli/issues/1040 // https://github.com/urfave/cli/issues/1040
docs = docs[strings.Index(docs, "#"):] firstHashtagIndex := strings.Index(docs, "#")
if firstHashtagIndex > 0 {
docs = docs[firstHashtagIndex:]
}
} }
out := os.Stdout out := os.Stdout

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build bindata
// +build bindata // +build bindata
package cmd package cmd

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !bindata
// +build !bindata // +build !bindata
package cmd package cmd

View File

@ -7,6 +7,7 @@ package migrations
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"os" "os"
"reflect" "reflect"
@ -762,8 +763,14 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin
} }
tableSQL := string(res[0]["sql"]) tableSQL := string(res[0]["sql"])
// Get the string offset for column definitions: `CREATE TABLE ( column-definitions... )`
columnDefinitionsIndex := strings.Index(tableSQL, "(")
if columnDefinitionsIndex < 0 {
return errors.New("couldn't find column definitions")
}
// Separate out the column definitions // Separate out the column definitions
tableSQL = tableSQL[strings.Index(tableSQL, "("):] tableSQL = tableSQL[columnDefinitionsIndex:]
// Remove the required columnNames // Remove the required columnNames
for _, name := range columnNames { for _, name := range columnNames {

View File

@ -1,3 +1,4 @@
//go:build pam
// +build pam // +build pam
// Copyright 2014 The Gogs Authors. All rights reserved. // Copyright 2014 The Gogs Authors. All rights reserved.

View File

@ -1,9 +1,10 @@
// +build !pam
// Copyright 2014 The Gogs Authors. All rights reserved. // Copyright 2014 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !pam
// +build !pam
package pam package pam
import ( import (

View File

@ -1,3 +1,4 @@
//go:build pam
// +build pam // +build pam
// Copyright 2021 The Gitea Authors. All rights reserved. // Copyright 2021 The Gitea Authors. All rights reserved.

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build race
// +build race // +build race
package git package git

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package git package git

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package git package git

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gogit
// +build gogit // +build gogit
package pipeline package pipeline

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gogit
// +build !gogit // +build !gogit
package pipeline package pipeline

Some files were not shown because too many files have changed in this diff Show More