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
This commit is part of merge request !363. Comments created here will be created in the context of that merge request.
......@@ -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
......@@ -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 {
......
......@@ -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
......
......@@ -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)
......
......@@ -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"),
}
}
......
......@@ -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"),
}
}
......
......@@ -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"),
}
}
......
......@@ -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"),
}
}
......
......@@ -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
}
}()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment