diff --git a/.golangci.yml b/.golangci.yml index f0965a4cb10dc8c28837e08c05e4a2038dbded19..d1d3611545b5a13d4b5fcef20db255eca1643d81 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -32,6 +32,8 @@ issues: linters: # enable the specific needed linters + # see here for full list: https://golangci-lint.run/usage/linters/ + # linters to consider: gosimple, disable-all: true enable: - gofmt @@ -56,4 +58,4 @@ linters-settings: # Report about not checking of errors in type assertions: `a := b.(MyStruct)`. # Such cases aren't reported by default. # Default: false - check-type-assertions: false + check-type-assertions: true diff --git a/controller/nucleus/deviceWatcher.go b/controller/nucleus/deviceWatcher.go index de7f135afb62ca2fab0f69d823985acd3e246b38..1f02d5c21847cd26d04298c0962e5c8361831e07 100644 --- a/controller/nucleus/deviceWatcher.go +++ b/controller/nucleus/deviceWatcher.go @@ -124,7 +124,7 @@ func (d *DeviceWatcher) handleSubscribeResponse(resp *gpb.SubscribeResponse, sub PndID: subscriptionInfo.PndID, DeviceID: subscriptionInfo.DeviceID, DeviceName: subscriptionInfo.DeviceName, - Err: fmt.Sprintf("SubscribeResponse_Error"), + Err: fmt.Sprint("SubscribeResponse_Error"), }) case *gpb.SubscribeResponse_SyncResponse: if !resp.SyncResponse { diff --git a/controller/nucleus/errors/errors.go b/controller/nucleus/errors/errors.go index 254cb165389ff596a289d04981c8fefc799aa2f9..19f2b70553497a73ec5cc052571ab2cfd2a603b1 100644 --- a/controller/nucleus/errors/errors.go +++ b/controller/nucleus/errors/errors.go @@ -12,7 +12,7 @@ type ErrNilClient struct { } func (e *ErrNilClient) Error() string { - return fmt.Sprintf("client cannot be nil") + return fmt.Sprint("client cannot be nil") } // ErrNil implements the Error interface and is called if a struct is nil. @@ -20,7 +20,7 @@ type ErrNil struct { } func (e *ErrNil) Error() string { - return fmt.Sprintf("struct cannot be nil") + return fmt.Sprint("struct cannot be nil") } // ErrAlreadyExists implements the Error interface and is called if a specific ID @@ -39,7 +39,7 @@ type ErrInvalidUUID struct { } func (e *ErrInvalidUUID) Error() string { - return fmt.Sprintf("UUID not valid") + return fmt.Sprint("UUID not valid") } // ErrInvalidTypeAssertion implements the Error interface and is called if the @@ -79,7 +79,7 @@ func (e ErrPathNotFound) Error() string { type ErrNotYetImplemented struct{} func (e ErrNotYetImplemented) Error() string { - return fmt.Sprintf("function not yet implemented") + return fmt.Sprint("function not yet implemented") } // ErrInvalidParameters implements the Error interface and is called if the wrong diff --git a/controller/nucleus/gnmi_transport_test.go b/controller/nucleus/gnmi_transport_test.go index deb6742db9cf6255483cbf4fd0b2a627d8910c65..87a1909ae78206df753443be515d32d266885c76 100644 --- a/controller/nucleus/gnmi_transport_test.go +++ b/controller/nucleus/gnmi_transport_test.go @@ -439,6 +439,7 @@ func TestGnmi_Type(t *testing.T) { } } +//nolint:errcheck func TestGnmi_getWithRequest(t *testing.T) { transport := mockTransport() reqFullNode := gnmiMessages["../test/proto/req-full-node"].(*gpb.GetRequest) diff --git a/controller/topology/nodes/nodeStore.go b/controller/topology/nodes/nodeStore.go index 0c0093b20ce84474025a7c1174809b9f8ec72e0c..90891452eeb966bb3faf55de8c9bf8425c9cf3be 100644 --- a/controller/topology/nodes/nodeStore.go +++ b/controller/topology/nodes/nodeStore.go @@ -30,7 +30,7 @@ type DatabaseNodeStore struct { // NewDatabaseNodeStore returns a NodeStore func NewDatabaseNodeStore() Store { return &DatabaseNodeStore{ - storeName: fmt.Sprintf("node-store.json"), + storeName: fmt.Sprint("node-store.json"), } } diff --git a/controller/topology/ports/portStore.go b/controller/topology/ports/portStore.go index e09bbd8fb57423fbe653b8d24611a42175a7085f..45907c054869f345700bf00605578ed7f4ff3bf5 100644 --- a/controller/topology/ports/portStore.go +++ b/controller/topology/ports/portStore.go @@ -31,7 +31,7 @@ type DatabasePortStore struct { // NewDatabasePortStore returns a PortStore func NewDatabasePortStore() Store { return &DatabasePortStore{ - storeName: fmt.Sprintf("port-store.json"), + storeName: fmt.Sprint("port-store.json"), } } diff --git a/controller/topology/routing-tables/routingTableStore.go b/controller/topology/routing-tables/routingTableStore.go index a0afbf140af05fb2cc0799286f9fd1280c4bb349..72aa625c61be6c15d175948827f74e63957f20aa 100644 --- a/controller/topology/routing-tables/routingTableStore.go +++ b/controller/topology/routing-tables/routingTableStore.go @@ -30,7 +30,7 @@ type DatabaseRoutingTableStore struct { // NewDatabaseRoutingTableStore returns a RoutingTableStore func NewDatabaseRoutingTableStore() Store { return &DatabaseRoutingTableStore{ - storeName: fmt.Sprintf("routing-table-store.json"), + storeName: fmt.Sprint("routing-table-store.json"), } } diff --git a/controller/topology/topologyStore.go b/controller/topology/topologyStore.go index 9b50376c17dc981d2f40d674a37f776f73d6153a..ed9318e03e839f4de198ed4f0b332195793c9ffa 100644 --- a/controller/topology/topologyStore.go +++ b/controller/topology/topologyStore.go @@ -31,7 +31,7 @@ type DatabaseTopologyStore struct { // NewDatabaseTopologyStore returns a TopologyStore func NewDatabaseTopologyStore() Store { return &DatabaseTopologyStore{ - storeName: fmt.Sprintf("topology-store.json"), + storeName: fmt.Sprint("topology-store.json"), } } diff --git a/csbi/repository.go b/csbi/repository.go index 3a96d5c6d3250fa5add9f45a5b8477ef6bbdd1b7..92a4ce9c1700371ec0c6058a0c9e841563b222ac 100644 --- a/csbi/repository.go +++ b/csbi/repository.go @@ -114,7 +114,7 @@ func (osfs *filesystem) Stat(name string) (fs.FileInfo, error) { func (osfs *filesystem) Glob(pattern string) (paths []string, err error) { defer func() { if e := recover(); e != nil { - err = e.(error) + err = e.(error) //nolint:errcheck paths = nil } }()