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:
@@ -8,6 +8,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io"
|
||||
@@ -117,7 +118,7 @@ func (b64embedder *mailAttachmentBase64Embedder) AttachmentSrcToBase64DataURI(ct
|
||||
attachmentUUID, ok = strings.CutPrefix(parsedSrc.RepoSubPath, "/attachments/")
|
||||
}
|
||||
if !ok {
|
||||
return "", fmt.Errorf("not an attachment")
|
||||
return "", errors.New("not an attachment")
|
||||
}
|
||||
}
|
||||
attachment, err := repo_model.GetAttachmentByUUID(ctx, attachmentUUID)
|
||||
@@ -126,10 +127,10 @@ func (b64embedder *mailAttachmentBase64Embedder) AttachmentSrcToBase64DataURI(ct
|
||||
}
|
||||
|
||||
if attachment.RepoID != b64embedder.repo.ID {
|
||||
return "", fmt.Errorf("attachment does not belong to the repository")
|
||||
return "", errors.New("attachment does not belong to the repository")
|
||||
}
|
||||
if attachment.Size+b64embedder.estimateSize > b64embedder.maxSize {
|
||||
return "", fmt.Errorf("total embedded images exceed max limit")
|
||||
return "", errors.New("total embedded images exceed max limit")
|
||||
}
|
||||
|
||||
fr, err := storage.Attachments.Open(attachment.RelativePath())
|
||||
@@ -146,7 +147,7 @@ func (b64embedder *mailAttachmentBase64Embedder) AttachmentSrcToBase64DataURI(ct
|
||||
|
||||
mimeType := typesniffer.DetectContentType(content)
|
||||
if !mimeType.IsImage() {
|
||||
return "", fmt.Errorf("not an image")
|
||||
return "", errors.New("not an image")
|
||||
}
|
||||
|
||||
encoded := base64.StdEncoding.EncodeToString(content)
|
||||
|
@@ -6,6 +6,7 @@ package mailer
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
@@ -38,10 +39,10 @@ func MailTeamInvite(ctx context.Context, inviter *user_model.User, team *org_mod
|
||||
if err != nil && !user_model.IsErrUserNotExist(err) {
|
||||
return err
|
||||
} else if user != nil && user.ProhibitLogin {
|
||||
return fmt.Errorf("login is prohibited for the invited user")
|
||||
return errors.New("login is prohibited for the invited user")
|
||||
}
|
||||
|
||||
inviteRedirect := url.QueryEscape(fmt.Sprintf("/org/invite/%s", invite.Token))
|
||||
inviteRedirect := url.QueryEscape("/org/invite/" + invite.Token)
|
||||
inviteURL := fmt.Sprintf("%suser/sign_up?redirect_to=%s", setting.AppURL, inviteRedirect)
|
||||
|
||||
if (err == nil && user != nil) || setting.Service.DisableRegistration || setting.Service.AllowOnlyExternalRegistration {
|
||||
|
@@ -5,6 +5,7 @@ package sender
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
@@ -99,7 +100,7 @@ func (s *SMTPSender) Send(from string, to []string, msg io.WriterTo) error {
|
||||
canAuth, options := client.Extension("AUTH")
|
||||
if len(opts.User) > 0 {
|
||||
if !canAuth {
|
||||
return fmt.Errorf("SMTP server does not support AUTH, but credentials provided")
|
||||
return errors.New("SMTP server does not support AUTH, but credentials provided")
|
||||
}
|
||||
|
||||
var auth smtp.Auth
|
||||
|
@@ -4,6 +4,7 @@
|
||||
package sender
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/Azure/go-ntlmssp"
|
||||
@@ -60,7 +61,7 @@ func (a *ntlmAuth) Start(server *smtp.ServerInfo) (string, []byte, error) {
|
||||
func (a *ntlmAuth) Next(fromServer []byte, more bool) ([]byte, error) {
|
||||
if more {
|
||||
if len(fromServer) == 0 {
|
||||
return nil, fmt.Errorf("ntlm ChallengeMessage is empty")
|
||||
return nil, errors.New("ntlm ChallengeMessage is empty")
|
||||
}
|
||||
authenticateMessage, err := ntlmssp.ProcessChallenge(fromServer, a.username, a.password, a.domainNeeded)
|
||||
return authenticateMessage, err
|
||||
|
Reference in New Issue
Block a user