linting
This commit is contained in:
47
api/notification/.golangci.yml
Normal file
47
api/notification/.golangci.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
version: "2"
|
||||
linters:
|
||||
default: none
|
||||
enable:
|
||||
- bodyclose
|
||||
- canonicalheader
|
||||
- copyloopvar
|
||||
- durationcheck
|
||||
- errcheck
|
||||
- errchkjson
|
||||
- errname
|
||||
- errorlint
|
||||
- gosec
|
||||
- govet
|
||||
- ineffassign
|
||||
- nilerr
|
||||
- nilnesserr
|
||||
- nilnil
|
||||
- noctx
|
||||
- rowserrcheck
|
||||
- sqlclosecheck
|
||||
- staticcheck
|
||||
- unconvert
|
||||
- wastedassign
|
||||
disable:
|
||||
- depguard
|
||||
- exhaustruct
|
||||
- gochecknoglobals
|
||||
- gochecknoinits
|
||||
- gomoddirectives
|
||||
- wrapcheck
|
||||
- cyclop
|
||||
- dupl
|
||||
- funlen
|
||||
- gocognit
|
||||
- gocyclo
|
||||
- ireturn
|
||||
- lll
|
||||
- mnd
|
||||
- nestif
|
||||
- nlreturn
|
||||
- noinlineerr
|
||||
- paralleltest
|
||||
- tagliatelle
|
||||
- testpackage
|
||||
- varnamelen
|
||||
- wsl_v5
|
||||
@@ -1,16 +0,0 @@
|
||||
package ampliimp
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/tech/sendico/notification/internal/ampli"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
)
|
||||
|
||||
func (a *AmplitudeAPI) onNotificationSent(_ context.Context, nresult *model.NotificationResult) error {
|
||||
ampli.Instance.EmailSent(
|
||||
nresult.UserID,
|
||||
ampli.EmailSent.Builder().Domain("").EmailType("").Build(),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (a *NotificationAPI) onConfirmationRequest(ctx context.Context, request *mo
|
||||
SourceService: req.SourceService,
|
||||
Rail: req.Rail,
|
||||
}
|
||||
env := confirmations.ConfirmationDispatch(string(mservice.Notifications), dispatch, req.SourceService, req.Rail)
|
||||
env := confirmations.ConfirmationDispatch(mservice.Notifications, dispatch, req.SourceService, req.Rail)
|
||||
if err := a.producer.SendMessage(env); err != nil {
|
||||
a.logger.Warn("Failed to publish confirmation dispatch", zap.Error(err), zap.String("request_id", req.RequestID), zap.String("message_id", dispatch.MessageID))
|
||||
return err
|
||||
@@ -143,7 +143,7 @@ func confirmationPrompt(req *model.ConfirmationRequest) string {
|
||||
if err != nil {
|
||||
amountFloat = 0
|
||||
}
|
||||
builder.WriteString(fmt.Sprintf("\n*Requested: %.2f %s*\n\n", amountFloat, req.RequestedMoney.Currency))
|
||||
_, _ = fmt.Fprintf(&builder, "\n*Requested: %.2f %s*\n\n", amountFloat, req.RequestedMoney.Currency)
|
||||
}
|
||||
builder.WriteString("Reply with \"<amount> <currency>\" (e.g., 12.34 USD).")
|
||||
return builder.String()
|
||||
|
||||
@@ -148,9 +148,8 @@ func NewClient(logger mlogger.Logger, l localizer.Localizer, dp domainprovider.D
|
||||
// Timeout for send the data and wait respond
|
||||
smtpServer.SendTimeout = mduration.Param2Duration(config.TimeOut, time.Second)
|
||||
|
||||
// Set TLSConfig to provide custom TLS configuration. For example,
|
||||
// to skip TLS verification (useful for testing):
|
||||
smtpServer.TLSConfig = &tls.Config{InsecureSkipVerify: true}
|
||||
// Keep certificate verification enabled.
|
||||
smtpServer.TLSConfig = &tls.Config{InsecureSkipVerify: false}
|
||||
|
||||
// SMTP client
|
||||
lg := logger.Named("client")
|
||||
|
||||
@@ -123,7 +123,7 @@ func CreateAPI(a api.API) (*NotificationAPI, error) {
|
||||
Operations: []string{discovery.OperationNotifySend},
|
||||
Version: appversion.Create().Short(),
|
||||
}
|
||||
p.announcer = discovery.NewAnnouncer(p.logger, a.Register().Producer(), string(mservice.Notifications), announce)
|
||||
p.announcer = discovery.NewAnnouncer(p.logger, a.Register().Producer(), mservice.Notifications, announce)
|
||||
p.announcer.Start()
|
||||
|
||||
return p, nil
|
||||
|
||||
@@ -28,7 +28,6 @@ type mockSentMessage struct {
|
||||
locale string
|
||||
recipients []string
|
||||
data map[string]string
|
||||
buttonLink string
|
||||
}
|
||||
|
||||
func (m *mockMailClient) Send(r mmail.MailBuilder) error {
|
||||
|
||||
@@ -186,7 +186,11 @@ func (c *client) sendMessage(ctx context.Context, payload sendMessagePayload) (*
|
||||
c.logger.Warn("Telegram request failed", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer func() {
|
||||
if closeErr := resp.Body.Close(); closeErr != nil {
|
||||
c.logger.Warn("Failed to close telegram response body", zap.Error(closeErr))
|
||||
}
|
||||
}()
|
||||
|
||||
respBody, _ := io.ReadAll(io.LimitReader(resp.Body, 16<<10))
|
||||
if resp.StatusCode >= http.StatusOK && resp.StatusCode < http.StatusMultipleChoices {
|
||||
@@ -321,7 +325,11 @@ func (c *client) sendReaction(ctx context.Context, payload setMessageReactionPay
|
||||
c.logger.Warn("Telegram reaction request failed", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer func() {
|
||||
if closeErr := resp.Body.Close(); closeErr != nil {
|
||||
c.logger.Warn("Failed to close telegram reaction response body", zap.Error(closeErr))
|
||||
}
|
||||
}()
|
||||
|
||||
respBody, _ := io.ReadAll(io.LimitReader(resp.Body, 16<<10))
|
||||
if resp.StatusCode >= http.StatusOK && resp.StatusCode < http.StatusMultipleChoices {
|
||||
|
||||
@@ -61,7 +61,7 @@ func (a *NotificationAPI) handleTelegramWebhook(w http.ResponseWriter, r *http.R
|
||||
if update.Message != nil {
|
||||
payload.Message = update.Message.ToModel()
|
||||
}
|
||||
env := tnotifications.TelegramUpdate(string(mservice.Notifications), payload)
|
||||
env := tnotifications.TelegramUpdate(mservice.Notifications, payload)
|
||||
if err := a.producer.SendMessage(env); err != nil {
|
||||
if a.logger != nil {
|
||||
a.logger.Warn("Failed to publish telegram webhook update", zap.Error(err), zap.Int64("update_id", update.UpdateID))
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// generate translations
|
||||
// go:generate Users/stephandeshevikh/go/bin/go18n extract
|
||||
// go:generate Users/stephandeshevikh/go/bin/go18n merge
|
||||
//go:generate Users/stephandeshevikh/go/bin/go18n extract
|
||||
//go:generate Users/stephandeshevikh/go/bin/go18n merge
|
||||
|
||||
// lint go code
|
||||
// docker run -t --rm -v $(pwd):/app -w /app golangci/golangci-lint:latest golangci-lint run -v --timeout 10m0s --enable-all -D ireturn -D wrapcheck -D varnamelen -D tagliatelle -D nosnakecase -D gochecknoglobals -D nlreturn -D stylecheck -D lll -D wsl -D scopelint -D varcheck -D exhaustivestruct -D golint -D maligned -D interfacer -D ifshort -D structcheck -D deadcode -D godot -D depguard -D tagalign
|
||||
|
||||
Reference in New Issue
Block a user