fix(lint): update some warning from golangci-lint

https://github.com/appleboy/gorush/issues/704

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi.Wu 2022-12-18 10:06:43 +08:00
parent 577083639c
commit 83a6e63af9
10 changed files with 35 additions and 22 deletions

View File

@ -10,6 +10,7 @@ import (
"github.com/spf13/viper"
)
//nolint
var defaultConf = []byte(`
core:
enabled: true # enable httpd server

View File

@ -153,8 +153,8 @@ func hideToken(token string, markLen int) string {
start := token[len(token)-markLen:]
end := token[0:markLen]
result := strings.Replace(token, start, strings.Repeat("*", markLen), -1)
result = strings.Replace(result, end, strings.Repeat("*", markLen), -1)
result := strings.ReplaceAll(token, start, strings.Repeat("*", markLen))
result = strings.ReplaceAll(result, end, strings.Repeat("*", markLen))
return result
}

View File

@ -2,6 +2,7 @@ package notify
import (
"bytes"
"context"
"errors"
"net"
"net/http"
@ -21,7 +22,7 @@ func DispatchFeedback(log logx.LogPushEntry, url string, timeout int64) error {
return err
}
req, err := http.NewRequest("POST", url, bytes.NewBuffer(payload))
req, err := http.NewRequestWithContext(context.Background(), "POST", url, bytes.NewBuffer(payload))
if err != nil {
return err
}

View File

@ -216,17 +216,17 @@ func CheckPushConf(cfg *config.ConfYaml) error {
if cfg.Android.Enabled {
if cfg.Android.APIKey == "" {
return errors.New("Missing Android API Key")
return errors.New("missing android api key")
}
}
if cfg.Huawei.Enabled {
if cfg.Huawei.AppSecret == "" {
return errors.New("Missing Huawei App Secret")
return errors.New("missing huawei app secret")
}
if cfg.Huawei.AppID == "" {
return errors.New("Missing Huawei App ID")
return errors.New("missing huawei app id")
}
}

View File

@ -106,7 +106,7 @@ func InitAPNSClient(cfg *config.ConfYaml) error {
if ext == ".p8" {
if cfg.Ios.KeyID == "" || cfg.Ios.TeamID == "" {
msg := "You should provide ios.KeyID and ios.TeamID for P8 token"
msg := "you should provide ios.KeyID and ios.TeamID for p8 token"
logx.LogError.Error(msg)
return errors.New(msg)
}

View File

@ -1,6 +1,7 @@
package notify
import (
"context"
"log"
"net/http"
"net/url"
@ -16,13 +17,13 @@ import (
)
const (
// nolint
//nolint
certificateValidP12 = `MIIKlgIBAzCCClwGCSqGSIb3DQEHAaCCCk0EggpJMIIKRTCCBMcGCSqGSIb3DQEHBqCCBLgwggS0AgEAMIIErQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQID/GJtcRhjvwCAggAgIIEgE5ralQoQBDgHgdp5+EwBaMjcZEJUXmYRdVCttIwfN2OxlIs54tob3/wpUyWGqJ+UXy9X+4EsWpDPUfTN/w88GMgj0kftpTqG0+3Hu/9pkZO4pdLCiyMGOJnXCOdhHFirtTXAR3QvnKKIpXIKrmZ4rcr/24Uvd/u669Tz8VDgcGOQazKeyvtdW7TJBxMFRv+IsQi/qCj5PkQ0jBbZ1LAc4C8mCMwOcH+gi/e471mzPWihQmynH2yJlZ4jb+taxQ/b8Dhlni2vcIMn+HknRk3Cyo8jfFvvO0BjvVvEAPxPJt7X96VFFS2KlyXjY3zt0siGrzQpczgPB/1vTqhQUvoOBw6kcXWgOjwt+gR8Mmo2DELnQqGhbYuWu52doLgVvD+zGr5vLYXHz6gAXnI6FVyHb+oABeBet3cer3EzGR7r+VoLmWSBm8SyRHwi0mxE63S7oD1j22jaTo7jnQBFZaY+cPaATcFjqW67x4j8kXh9NRPoINSgodLJrgmet2D1iOKuLTkCWf0UTi2HUkn9Zf0y+IIViZaVE4mWaGb9xTBClfa4KwM5gSz3jybksFKbtnzzPFuzClu+2mdthJs/58Ao40eyaykNmzSPhDv1F8Mai8bfaAqSdcBl5ZB2PF33xhuNSS4j2uIh1ICGv9DueyN507iEMQO2yCcaQTMKejV7/52h9LReS5/QPXDJhWMVpTb5FGCP7EmO0lZTeBNO5MlDzDQfz5xcFqHqfoby2sfAMU8HNB8wzdcwHtacgKGLBjLkapxyTsqYE5Kry6UxclvF4soR8TZoQ69E7WsKZLmTaw2+msmnDJubpY0NqkRqkVk7umtVC0D+w6AIKDrY58HM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4VmltNllRZCtLVlQ0OWlSRERBaUlGb01HQTRpCnZ2Y0lsbmVxT1paUERJb0tKNjBJak8vRFpIV2t3NW1MamFJclQrcVEzWEFHZEpBMTNoY20KLS0tLS1FTkQgUlNBIFBSSVZBVEUgS0VZLS0tLS0K`
// nolint
//nolint
authkeyInvalidP8 = `TUlHSEFnRUFNQk1HQnlxR1NNNDlBZ0VHQ0NxR1NNNDlBd0VIQkcwd2F3SUJBUVFnRWJWemZQblpQeGZBeXhxRQpaVjA1bGFBb0pBbCsvNlh0Mk80bU9CNjExc09oUkFOQ0FBU2dGVEtqd0pBQVU5NWcrKy92ektXSGt6QVZtTk1JCnRCNXZUalpPT0l3bkViNzBNc1daRkl5VUZEMVA5R3dzdHo0K2FrSFg3dkk4Qkg2aEhtQm1mWlpaCg==`
// nolint
//nolint
authkeyValidP8 = `LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JR0hBZ0VBTUJNR0J5cUdTTTQ5QWdFR0NDcUdTTTQ5QXdFSEJHMHdhd0lCQVFRZ0ViVnpmUG5aUHhmQXl4cUUKWlYwNWxhQW9KQWwrLzZYdDJPNG1PQjYxMXNPaFJBTkNBQVNnRlRLandKQUFVOTVnKysvdnpLV0hrekFWbU5NSQp0QjV2VGpaT09Jd25FYjcwTXNXWkZJeVVGRDFQOUd3c3R6NCtha0hYN3ZJOEJINmhIbUJtZmVRbAotLS0tLUVORCBQUklWQVRFIEtFWS0tLS0tCg==`
)
@ -698,7 +699,7 @@ func TestAPNSClientUseProxy(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, apns2.HostDevelopment, ApnsClient.Host)
req, _ := http.NewRequest("GET", apns2.HostDevelopment, nil)
req, _ := http.NewRequestWithContext(context.Background(), "GET", apns2.HostDevelopment, nil)
actualProxyURL, err := ApnsClient.HTTPClient.Transport.(*http.Transport).Proxy(req)
assert.Nil(t, err)
@ -713,7 +714,7 @@ func TestAPNSClientUseProxy(t *testing.T) {
assert.Equal(t, apns2.HostDevelopment, ApnsClient.Host)
assert.NotNil(t, ApnsClient.Token)
req, _ = http.NewRequest("GET", apns2.HostDevelopment, nil)
req, _ = http.NewRequestWithContext(context.Background(), "GET", apns2.HostDevelopment, nil)
actualProxyURL, err = ApnsClient.HTTPClient.Transport.(*http.Transport).Proxy(req)
assert.Nil(t, err)
@ -735,7 +736,7 @@ func TestPushToIOS(t *testing.T) {
assert.Nil(t, err)
req := &PushNotification{
// nolint
//nolint
Tokens: []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7", "11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef1"},
Platform: 1,
Message: "Welcome",

View File

@ -17,7 +17,7 @@ func InitFCMClient(cfg *config.ConfYaml, key string) (*fcm.Client, error) {
var err error
if key == "" && cfg.Android.APIKey == "" {
return nil, errors.New("Missing Android API Key")
return nil, errors.New("missing android api key")
}
if key != "" && key != cfg.Android.APIKey {
@ -216,7 +216,7 @@ Retry:
if len(res.FailedRegistrationIDs) > 0 {
newTokens = append(newTokens, res.FailedRegistrationIDs...)
// nolint
//nolint
errLog := logPush(cfg, core.FailedPush, notification.To, req, errors.New("device group: partial success or all fails"))
resp.Logs = append(resp.Logs, errLog)
}

View File

@ -38,11 +38,11 @@ func GetPushClient(conf *c.Config) (*client.HMSClient, error) {
// InitHMSClient use for initialize HMS Client.
func InitHMSClient(cfg *config.ConfYaml, appSecret, appID string) (*client.HMSClient, error) {
if appSecret == "" {
return nil, errors.New("Missing Huawei App Secret")
return nil, errors.New("missing huawei app secret")
}
if appID == "" {
return nil, errors.New("Missing Huawei App ID")
return nil, errors.New("missing huawei app id")
}
conf := &c.Config{

View File

@ -222,7 +222,11 @@ func routerEngine(cfg *config.ConfYaml, q *queue.Queue) *gin.Engine {
}
// markFailedNotification adds failure logs for all tokens in push notification
func markFailedNotification(cfg *config.ConfYaml, notification *notify.PushNotification, reason string) []logx.LogPushEntry {
func markFailedNotification(
cfg *config.ConfYaml,
notification *notify.PushNotification,
reason string,
) []logx.LogPushEntry {
logx.LogError.Error(reason)
logs := make([]logx.LogPushEntry, 0)
for _, token := range notification.Tokens {
@ -242,7 +246,12 @@ func markFailedNotification(cfg *config.ConfYaml, notification *notify.PushNotif
}
// HandleNotification add notification to queue list.
func handleNotification(ctx context.Context, cfg *config.ConfYaml, req notify.RequestPush, q *queue.Queue) (int, []logx.LogPushEntry) {
func handleNotification(
ctx context.Context,
cfg *config.ConfYaml,
req notify.RequestPush,
q *queue.Queue,
) (int, []logx.LogPushEntry) {
var count int
wg := sync.WaitGroup{}
newNotification := []*notify.PushNotification{}

View File

@ -68,6 +68,7 @@ func initTest() *config.ConfYaml {
// testRequest is testing url string if server is running
func testRequest(t *testing.T, url string) {
tr := &http.Transport{
//nolint:gosec
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{
@ -143,9 +144,9 @@ func TestRunTLSServer(t *testing.T) {
}
func TestRunTLSBase64Server(t *testing.T) {
// nolint
//nolint
cert := `LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMrekNDQWVPZ0F3SUJBZ0lKQUxiWkVEdlVRckZLTUEwR0NTcUdTSWIzRFFFQkJRVUFNQlF4RWpBUUJnTlYKQkFNTUNXeHZZMkZzYUc5emREQWVGdzB4TmpBek1qZ3dNek13TkRGYUZ3MHlOakF6TWpZd016TXdOREZhTUJReApFakFRQmdOVkJBTU1DV3h2WTJGc2FHOXpkRENDQVNJd0RRWUpLb1pJaHZjTkFRRUJCUUFEZ2dFUEFEQ0NBUW9DCmdnRUJBTWoxK3hnNGpWTHpWbkI1ajduMXVsMzBXRUU0QkN6Y05GeGc1QU9CNUg1cSt3amUwWVlpVkZnNlBReXYKR0NpcHFJUlhWUmRWUTFoSFNldW5ZR0tlOGxxM1NiMVg4UFVKMTJ2OXVSYnBTOURLMU93cWs4cnNQRHU2c1ZUTApxS0tnSDFaOHlhenphUzBBYlh1QTVlOWdPL1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