VOL-3344 - Enabled default linters and fixed found issues.
Also disabled govet's variable shadowing check, since this is very useful for isolating multiple "err"ors in a row.
Change-Id: Icd70c723c406c5986b8cfe4535ad7daa0752e48c
diff --git a/internal/pkg/resourcemanager/resourcemanager.go b/internal/pkg/resourcemanager/resourcemanager.go
index 58414f0..0504eaf 100755
--- a/internal/pkg/resourcemanager/resourcemanager.go
+++ b/internal/pkg/resourcemanager/resourcemanager.go
@@ -22,11 +22,12 @@
"encoding/json"
"errors"
"fmt"
- "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
"strconv"
"sync"
"time"
+ "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
+
"github.com/opencord/voltha-lib-go/v3/pkg/db"
"github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
@@ -1162,7 +1163,6 @@
logger.Errorw(ctx, "Failed to add uin port in onugem to kv store", log.Fields{"uni": portNo})
return
}
- return
}
//UpdateGemPortForPktIn updates gemport for pkt in path to kvstore, path being intfid, onuid, portno, vlan id, priority bit
@@ -1179,8 +1179,6 @@
return
}
logger.Debugw(ctx, "added gem packet in successfully", log.Fields{"path": path, "gem": gemPort})
-
- return
}
// GetGemPortFromOnuPktIn gets the gem port from onu pkt in path, path being intfid, onuid, portno, vlan id, priority bit
@@ -1252,7 +1250,7 @@
var nni []uint32
var Val []byte
- path := fmt.Sprintf(NnniIntfID)
+ path := NnniIntfID
value, err := RsrcMgr.KVStore.Get(ctx, path)
if err != nil {
logger.Error(ctx, "failed to get data from kv store")
@@ -1281,7 +1279,7 @@
return err
}
- path := fmt.Sprintf(NnniIntfID)
+ path := NnniIntfID
nni = append(nni, nniIntf)
Value, err = json.Marshal(nni)
if err != nil {
@@ -1298,7 +1296,7 @@
// DelNNiFromKVStore deletes nni interface list from kv store.
func (RsrcMgr *OpenOltResourceMgr) DelNNiFromKVStore(ctx context.Context) error {
- path := fmt.Sprintf(NnniIntfID)
+ path := NnniIntfID
if err := RsrcMgr.KVStore.Delete(ctx, path); err != nil {
logger.Errorw(ctx, "Failed to delete nni interfaces from kv store", log.Fields{"path": path})
@@ -1364,9 +1362,7 @@
defer RsrcMgr.flowIDToGemInfoLock.Unlock()
if err = RsrcMgr.KVStore.Put(ctx, path, val); err != nil {
logger.Errorw(ctx, "Failed to put to kvstore", log.Fields{"error": err, "path": path, "value": val})
- return
}
- return
}
//GetFlowIDsGemMapForInterface gets flowids per gemport and interface
@@ -1401,9 +1397,7 @@
defer RsrcMgr.flowIDToGemInfoLock.Unlock()
if err := RsrcMgr.KVStore.Delete(ctx, path); err != nil {
logger.Errorw(ctx, "Failed to delete nni interfaces from kv store", log.Fields{"path": path})
- return
}
- return
}
// RemoveResourceMap Clear resource map associated with (intfid, onuid, uniid) tuple.
@@ -1414,7 +1408,7 @@
//GetMcastQueuePerInterfaceMap gets multicast queue info per pon interface
func (RsrcMgr *OpenOltResourceMgr) GetMcastQueuePerInterfaceMap(ctx context.Context) (map[uint32][]uint32, error) {
- path := fmt.Sprintf(McastQueuesForIntf)
+ path := McastQueuesForIntf
var mcastQueueToIntfMap map[uint32][]uint32
var val []byte
@@ -1439,7 +1433,7 @@
//AddMcastQueueForIntf adds multicast queue for pon interface
func (RsrcMgr *OpenOltResourceMgr) AddMcastQueueForIntf(ctx context.Context, intf uint32, gem uint32, servicePriority uint32) error {
var val []byte
- path := fmt.Sprintf(McastQueuesForIntf)
+ path := McastQueuesForIntf
mcastQueues, err := RsrcMgr.GetMcastQueuePerInterfaceMap(ctx)
if err != nil {
diff --git a/internal/pkg/resourcemanager/resourcemanager_test.go b/internal/pkg/resourcemanager/resourcemanager_test.go
index 73b74df..562bc08 100644
--- a/internal/pkg/resourcemanager/resourcemanager_test.go
+++ b/internal/pkg/resourcemanager/resourcemanager_test.go
@@ -43,14 +43,14 @@
)
func init() {
- log.SetDefaultLogger(log.JSON, log.DebugLevel, nil)
+ _, _ = log.SetDefaultLogger(log.JSON, log.DebugLevel, nil)
}
const (
// MeterConfig meter to extract meter
MeterConfig = "meter_id"
// TpIDSuffixPath to extract Techprofile
- TpIDSuffixPath = "tp_id"
+ // TpIDSuffixPath = "tp_id"
// FlowIDInfo to extract flows
FlowIDInfo = "flow_id_info"
// FlowIds to extract flows