Skip to content

Commit 27ddd56

Browse files
yasirfolio3Michael Ng
authored andcommitted
fix(linter): Fixed golangci-lint implementations (#117)
1 parent 36323cd commit 27ddd56

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020
include:
2121
- stage: 'Lint'
2222
install:
23-
- go get github.com/golangci/golangci-lint/cmd/golangci-lint
23+
- curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.19.0
2424
script:
25-
- golangci-lint run --out-format=tab --tests=false optimizely/...
25+
- $GOPATH/bin/golangci-lint run --out-format=tab --tests=false optimizely/...
2626
- stage: 'Integration Tests'
2727
merge_mode: replace
2828
env: SDK=go
@@ -34,4 +34,4 @@ jobs:
3434
script:
3535
- "$HOME/travisci-tools/fsc-trigger/trigger_fullstack-sdk-compat.sh"
3636
after_success: travis_terminate 0
37-
37+

optimizely/notification/manager.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
package notification
1919

2020
import (
21+
"fmt"
2122
"sync/atomic"
23+
24+
"github.com/optimizely/go-sdk/optimizely/logging"
2225
)
2326

27+
var managerLogger = logging.GetLogger("NotificationManager")
28+
2429
// Manager is a generic interface for managing notifications of a particular type
2530
type Manager interface {
2631
Add(func(interface{})) (int, error)
@@ -53,7 +58,10 @@ func (am *AtomicManager) Remove(id int) {
5358
handlerID := uint32(id)
5459
if _, ok := am.handlers[handlerID]; ok {
5560
delete(am.handlers, handlerID)
61+
return
5662
}
63+
managerLogger.Debug(fmt.Sprintf("Handler for id:%d not found", id))
64+
5765
}
5866

5967
// Send sends the notification to the registered handlers

optimizely/notification/manager_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ func TestAtomicManager(t *testing.T) {
4646
atomicManager.Remove(result2)
4747
atomicManager.Send(payload)
4848
mockReceiver.AssertNumberOfCalls(t, "handleBetter", 2)
49+
50+
// Sanity check by calling remove with a incorrect handler id
51+
atomicManager.Remove(55)
4952
}

0 commit comments

Comments
 (0)