Skip to content

Commit

Permalink
Fix static code analysis issues (#121)
Browse files Browse the repository at this point in the history
* client: checked returned error in test

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>

* client: skip assignment

Returned value is not used or checked.

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>

* client: drop deprecated io/ioutil

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>

---------

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
  • Loading branch information
florianl authored Aug 7, 2024
1 parent 165e47a commit f66604c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions pkg/client/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"crypto/x509"
"errors"
"io"
"io/ioutil"

protobuf "github.com/golang/protobuf/proto"
"google.golang.org/grpc"
Expand Down Expand Up @@ -40,7 +39,7 @@ const (
// NewFromReader creates a new client reading the connection information from the io.Reader.
func NewFromReader(reader io.Reader, impl StateInterface, actions ...Action) (Client, error) {
connInfo := &proto.StartUpInfo{}
data, err := ioutil.ReadAll(reader)
data, err := io.ReadAll(reader)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func TestStore(t *testing.T) {
newTx, err := storeClient.BeginTx(ctx, false)
require.NoError(t, err)
defer newTx.Discard(ctx)
res, ok, err = newTx.GetKey(ctx, "test")
_, ok, err = newTx.GetKey(ctx, "test")
require.NoError(t, err)
require.False(t, ok)

Expand All @@ -142,7 +142,7 @@ func TestStore(t *testing.T) {
require.NoError(t, err)

// get value in one opened before commit (should still fail)
res, ok, err = newTx.GetKey(ctx, "test")
_, ok, err = newTx.GetKey(ctx, "test")
require.NoError(t, err)
require.False(t, ok)
newTx.Commit(ctx)
Expand Down
1 change: 1 addition & 0 deletions pkg/client/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestUnitUpdateWithSameMap(t *testing.T) {
defaultTest.config.Source = pbStruct

pbStructNew, err := structpb.NewStruct(sameMap)
require.NoError(t, err)
newUnit := &proto.UnitExpectedConfig{
Source: pbStructNew,
}
Expand Down

0 comments on commit f66604c

Please sign in to comment.