Skip to content
Snippets Groups Projects
Commit 27f2b62b authored by Fabian Seidl's avatar Fabian Seidl
Browse files

some code simplification, enabled type assertion in errcheck again

parent 57d017b5
No related branches found
No related tags found
1 merge request!363Resolve "Improve security by enabling and enforcing more linting rules"
Pipeline #110709 passed
...@@ -32,6 +32,8 @@ issues: ...@@ -32,6 +32,8 @@ issues:
linters: linters:
# enable the specific needed linters # enable the specific needed linters
# see here for full list: https://golangci-lint.run/usage/linters/
# linters to consider: gosimple,
disable-all: true disable-all: true
enable: enable:
- gofmt - gofmt
...@@ -56,4 +58,4 @@ linters-settings: ...@@ -56,4 +58,4 @@ linters-settings:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`. # Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default. # Such cases aren't reported by default.
# Default: false # Default: false
check-type-assertions: false check-type-assertions: true
...@@ -124,7 +124,7 @@ func (d *DeviceWatcher) handleSubscribeResponse(resp *gpb.SubscribeResponse, sub ...@@ -124,7 +124,7 @@ func (d *DeviceWatcher) handleSubscribeResponse(resp *gpb.SubscribeResponse, sub
PndID: subscriptionInfo.PndID, PndID: subscriptionInfo.PndID,
DeviceID: subscriptionInfo.DeviceID, DeviceID: subscriptionInfo.DeviceID,
DeviceName: subscriptionInfo.DeviceName, DeviceName: subscriptionInfo.DeviceName,
Err: fmt.Sprintf("SubscribeResponse_Error"), Err: fmt.Sprint("SubscribeResponse_Error"),
}) })
case *gpb.SubscribeResponse_SyncResponse: case *gpb.SubscribeResponse_SyncResponse:
if !resp.SyncResponse { if !resp.SyncResponse {
......
...@@ -12,7 +12,7 @@ type ErrNilClient struct { ...@@ -12,7 +12,7 @@ type ErrNilClient struct {
} }
func (e *ErrNilClient) Error() string { 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. // ErrNil implements the Error interface and is called if a struct is nil.
...@@ -20,7 +20,7 @@ type ErrNil struct { ...@@ -20,7 +20,7 @@ type ErrNil struct {
} }
func (e *ErrNil) Error() string { 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 // ErrAlreadyExists implements the Error interface and is called if a specific ID
...@@ -39,7 +39,7 @@ type ErrInvalidUUID struct { ...@@ -39,7 +39,7 @@ type ErrInvalidUUID struct {
} }
func (e *ErrInvalidUUID) Error() string { 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 // ErrInvalidTypeAssertion implements the Error interface and is called if the
...@@ -79,7 +79,7 @@ func (e ErrPathNotFound) Error() string { ...@@ -79,7 +79,7 @@ func (e ErrPathNotFound) Error() string {
type ErrNotYetImplemented struct{} type ErrNotYetImplemented struct{}
func (e ErrNotYetImplemented) Error() string { 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 // ErrInvalidParameters implements the Error interface and is called if the wrong
......
...@@ -439,6 +439,7 @@ func TestGnmi_Type(t *testing.T) { ...@@ -439,6 +439,7 @@ func TestGnmi_Type(t *testing.T) {
} }
} }
//nolint:errcheck
func TestGnmi_getWithRequest(t *testing.T) { func TestGnmi_getWithRequest(t *testing.T) {
transport := mockTransport() transport := mockTransport()
reqFullNode := gnmiMessages["../test/proto/req-full-node"].(*gpb.GetRequest) reqFullNode := gnmiMessages["../test/proto/req-full-node"].(*gpb.GetRequest)
......
...@@ -30,7 +30,7 @@ type DatabaseNodeStore struct { ...@@ -30,7 +30,7 @@ type DatabaseNodeStore struct {
// NewDatabaseNodeStore returns a NodeStore // NewDatabaseNodeStore returns a NodeStore
func NewDatabaseNodeStore() Store { func NewDatabaseNodeStore() Store {
return &DatabaseNodeStore{ return &DatabaseNodeStore{
storeName: fmt.Sprintf("node-store.json"), storeName: fmt.Sprint("node-store.json"),
} }
} }
......
...@@ -31,7 +31,7 @@ type DatabasePortStore struct { ...@@ -31,7 +31,7 @@ type DatabasePortStore struct {
// NewDatabasePortStore returns a PortStore // NewDatabasePortStore returns a PortStore
func NewDatabasePortStore() Store { func NewDatabasePortStore() Store {
return &DatabasePortStore{ return &DatabasePortStore{
storeName: fmt.Sprintf("port-store.json"), storeName: fmt.Sprint("port-store.json"),
} }
} }
......
...@@ -30,7 +30,7 @@ type DatabaseRoutingTableStore struct { ...@@ -30,7 +30,7 @@ type DatabaseRoutingTableStore struct {
// NewDatabaseRoutingTableStore returns a RoutingTableStore // NewDatabaseRoutingTableStore returns a RoutingTableStore
func NewDatabaseRoutingTableStore() Store { func NewDatabaseRoutingTableStore() Store {
return &DatabaseRoutingTableStore{ return &DatabaseRoutingTableStore{
storeName: fmt.Sprintf("routing-table-store.json"), storeName: fmt.Sprint("routing-table-store.json"),
} }
} }
......
...@@ -31,7 +31,7 @@ type DatabaseTopologyStore struct { ...@@ -31,7 +31,7 @@ type DatabaseTopologyStore struct {
// NewDatabaseTopologyStore returns a TopologyStore // NewDatabaseTopologyStore returns a TopologyStore
func NewDatabaseTopologyStore() Store { func NewDatabaseTopologyStore() Store {
return &DatabaseTopologyStore{ return &DatabaseTopologyStore{
storeName: fmt.Sprintf("topology-store.json"), storeName: fmt.Sprint("topology-store.json"),
} }
} }
......
...@@ -114,7 +114,7 @@ func (osfs *filesystem) Stat(name string) (fs.FileInfo, error) { ...@@ -114,7 +114,7 @@ func (osfs *filesystem) Stat(name string) (fs.FileInfo, error) {
func (osfs *filesystem) Glob(pattern string) (paths []string, err error) { func (osfs *filesystem) Glob(pattern string) (paths []string, err error) {
defer func() { defer func() {
if e := recover(); e != nil { if e := recover(); e != nil {
err = e.(error) err = e.(error) //nolint:errcheck
paths = nil paths = nil
} }
}() }()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment