Skip to content

Commit

Permalink
feat(linter): add linters and upgrade versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kissken committed Nov 10, 2023
1 parent 075b6a4 commit ebcb620
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/controller/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func UpdateContact(dataBase moira.Database, contactDTO dto.Contact, contactData

// RemoveContact deletes notification contact for current user and remove contactID from all subscriptions
func RemoveContact(database moira.Database, contactID string, userLogin string, teamID string) *api.ErrorResponse { //nolint:gocyclo
var subscriptionIDs []string
subscriptionIDs := make([]string, 0)
if userLogin != "" {
userSubscriptionIDs, err := database.GetUserSubscriptionIDs(userLogin)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion filter/connection/listening.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (listener *MetricsListener) Listen() chan []byte {
conn, err := listener.listener.Accept()
if nil != err {
var opErr *net.OpError
if ok := errors.Is(err, opErr); ok && opErr.Timeout() {
if ok := errors.As(err, &opErr); ok && opErr.Timeout() {
continue
}
listener.logger.Info().
Expand Down
2 changes: 1 addition & 1 deletion index/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestGetTriggerChecksWithRetries(t *testing.T) {
dataBase.EXPECT().GetTriggerChecks(randomBatch).Return(nil, expectedError).Times(3)
actualData, actualError := index.getTriggerChecksWithRetries(randomBatch)
So(actualData, ShouldBeEmpty)
So(actualError, ShouldResemble, fmt.Errorf("cannot get trigger checks from DB after 3 tries, last error: %w", expectedError))
So(actualError.Error(), ShouldResemble, fmt.Sprintf("cannot get trigger checks from DB after 3 tries, last error: %v", expectedError))
})
}

Expand Down
2 changes: 1 addition & 1 deletion notifier/plotting.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func fetchAvailableSeries(metricsSource metricSource.MetricSource, target string
return realtimeFetchResult.GetMetricsData(), nil
}
var errFailedWithPanic local.ErrEvaluateTargetFailedWithPanic
if ok := errors.Is(realtimeErr, errFailedWithPanic); ok {
if ok := errors.As(realtimeErr, &errFailedWithPanic); ok {
fetchResult, err := metricsSource.Fetch(target, from, to, false)
if err != nil {
return nil, errFetchAvailableSeriesFailed{realtimeErr: errFailedWithPanic.Error(), storedErr: err.Error()}
Expand Down
4 changes: 2 additions & 2 deletions notifier/plotting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func TestFetchAvailableSeries(t *testing.T) {

Convey("with error ErrEvaluateTargetFailedWithPanic and error again", func() {
var err error = local.ErrEvaluateTargetFailedWithPanic{}
var secondErr = errors.New("Test error")
var secondErr = errors.New("test error")
gomock.InOrder(
source.EXPECT().Fetch("testTarget", int64(17), int64(67), true).Return(nil, err).Times(1),
source.EXPECT().Fetch("testTarget", int64(17), int64(67), false).Return(nil, secondErr).Times(1),
Expand All @@ -234,7 +234,7 @@ func TestFetchAvailableSeries(t *testing.T) {
})

Convey("with unknown error", func() {
var err error = errors.New("Test error")
var err = errors.New("test error")
gomock.InOrder(
source.EXPECT().Fetch("testTarget", int64(17), int64(67), true).Return(nil, err).Times(1),
)
Expand Down
6 changes: 4 additions & 2 deletions senders/telegram/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package telegram

import (
"bytes"
"errors"
"fmt"
"strings"

"errors"

"gopkg.in/tucnak/telebot.v2"

"github.com/moira-alert/moira"
Expand Down Expand Up @@ -147,8 +148,9 @@ func checkBrokenContactError(logger moira.Logger, err error) error {
if err == nil {
return nil
}

var e *telebot.APIError
if ok := errors.Is(err, e); ok {
if ok := errors.As(err, &e); ok {
logger.Debug().
Int("code", e.Code).
String("msg", e.Message).
Expand Down

0 comments on commit ebcb620

Please sign in to comment.