mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Enable addtional linters (#34085)
enable mirror, usestdlibbars and perfsprint part of: https://github.com/go-gitea/gitea/issues/34083 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -552,10 +552,10 @@ func CommonRoutes() *web.Router {
|
||||
|
||||
r.Methods("HEAD,GET,PUT,DELETE", "*", func(ctx *context.Context) {
|
||||
path := ctx.PathParam("*")
|
||||
isHead := ctx.Req.Method == "HEAD"
|
||||
isGetHead := ctx.Req.Method == "HEAD" || ctx.Req.Method == "GET"
|
||||
isPut := ctx.Req.Method == "PUT"
|
||||
isDelete := ctx.Req.Method == "DELETE"
|
||||
isHead := ctx.Req.Method == http.MethodHead
|
||||
isGetHead := ctx.Req.Method == http.MethodHead || ctx.Req.Method == http.MethodGet
|
||||
isPut := ctx.Req.Method == http.MethodPut
|
||||
isDelete := ctx.Req.Method == http.MethodDelete
|
||||
|
||||
m := repoPattern.FindStringSubmatch(path)
|
||||
if len(m) == 2 && isGetHead {
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"hash"
|
||||
"math/big"
|
||||
@@ -121,7 +122,7 @@ func verifyTimestamp(req *http.Request) error {
|
||||
}
|
||||
|
||||
if diff > maxTimeDifference {
|
||||
return fmt.Errorf("time difference")
|
||||
return errors.New("time difference")
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -190,7 +191,7 @@ func getAuthorizationData(req *http.Request) ([]byte, error) {
|
||||
tmp := make([]string, len(valueList))
|
||||
for k, v := range valueList {
|
||||
if k > len(tmp) {
|
||||
return nil, fmt.Errorf("invalid X-Ops-Authorization headers")
|
||||
return nil, errors.New("invalid X-Ops-Authorization headers")
|
||||
}
|
||||
tmp[k-1] = v
|
||||
}
|
||||
@@ -267,7 +268,7 @@ func verifyDataOld(signature, data []byte, pub *rsa.PublicKey) error {
|
||||
}
|
||||
|
||||
if !slices.Equal(out[skip:], data) {
|
||||
return fmt.Errorf("could not verify signature")
|
||||
return errors.New("could not verify signature")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@@ -149,7 +149,7 @@ func getOrCreateUploadVersion(ctx context.Context, pi *packages_service.PackageI
|
||||
}
|
||||
|
||||
func createFileForBlob(ctx context.Context, pv *packages_model.PackageVersion, pb *packages_model.PackageBlob) error {
|
||||
filename := strings.ToLower(fmt.Sprintf("sha256_%s", pb.HashSHA256))
|
||||
filename := strings.ToLower("sha256_" + pb.HashSHA256)
|
||||
|
||||
pf := &packages_model.PackageFile{
|
||||
VersionID: pv.ID,
|
||||
|
@@ -406,7 +406,7 @@ func createFileFromBlobReference(ctx context.Context, pv, uploadVersion *package
|
||||
}
|
||||
|
||||
if ref.Name == "" {
|
||||
ref.Name = strings.ToLower(fmt.Sprintf("sha256_%s", ref.File.Blob.HashSHA256))
|
||||
ref.Name = strings.ToLower("sha256_" + ref.File.Blob.HashSHA256)
|
||||
}
|
||||
|
||||
pf := &packages_model.PackageFile{
|
||||
|
@@ -488,7 +488,7 @@ func UploadPackage(ctx *context.Context) {
|
||||
pv,
|
||||
&packages_service.PackageFileCreationInfo{
|
||||
PackageFileInfo: packages_service.PackageFileInfo{
|
||||
Filename: strings.ToLower(fmt.Sprintf("%s.nuspec", np.ID)),
|
||||
Filename: strings.ToLower(np.ID + ".nuspec"),
|
||||
},
|
||||
Data: nuspecBuf,
|
||||
},
|
||||
|
Reference in New Issue
Block a user