Skip to content

Commit

Permalink
Merge pull request #127 from ownmfa/bconway_linter_updates
Browse files Browse the repository at this point in the history
Linter updates and style fixes
  • Loading branch information
bconway authored Oct 21, 2023
2 parents 8ed0347 + bf1884d commit fd458c6
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 24 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ lint:
golangci-lint version
golangci-lint run -E bidichk,durationcheck,errname,exportloopref \
-E forcetypeassert,godot,goerr113,gofumpt,gosec,nlreturn,prealloc \
-E protogetter,unconvert,unparam,usestdlibvars --exclude-use-default=false
-E protogetter,testifylint,unconvert,unparam,usestdlibvars \
--exclude-use-default=false

go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck -test ./...
Expand Down
11 changes: 6 additions & 5 deletions internal/hermes-api/service/identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ func TestCreateIdentity(t *testing.T) {
identityer.EXPECT().Create(gomock.Any(), identity).Return(retIdentity,
otp, true, nil).Times(1)
apper := NewMockApper(ctrl)
apper.EXPECT().Read(gomock.Any(), app.GetId(), app.GetOrgId()).Return(app, nil).
Times(1)
apper.EXPECT().Read(gomock.Any(), app.GetId(), app.GetOrgId()).
Return(app, nil).Times(1)
eventer := NewMockEventer(ctrl)
eventer.EXPECT().Create(gomock.Any(), event).Return(dao.ErrNotFound).
Times(1)
Expand Down Expand Up @@ -494,8 +494,8 @@ func TestCreateIdentity(t *testing.T) {
uuid.NewString())

notifier := notify.NewMockNotifier(gomock.NewController(t))
notifier.EXPECT().ValidateSMS(gomock.Any(),
identity.GetSmsMethod().GetPhone()).Return(notify.ErrInvalidSMS).Times(1)
notifier.EXPECT().ValidateSMS(gomock.Any(), identity.GetSmsMethod().
GetPhone()).Return(notify.ErrInvalidSMS).Times(1)

ctx, cancel := context.WithTimeout(session.NewContext(
context.Background(), &session.Session{
Expand All @@ -521,7 +521,8 @@ func TestCreateIdentity(t *testing.T) {
uuid.NewString())

notifier := notify.NewMockNotifier(gomock.NewController(t))
notifier.EXPECT().ValidatePushover(identity.GetPushoverMethod().GetPushoverKey()).Return(notify.ErrInvalidPushover).Times(1)
notifier.EXPECT().ValidatePushover(identity.GetPushoverMethod().
GetPushoverKey()).Return(notify.ErrInvalidPushover).Times(1)

ctx, cancel := context.WithTimeout(session.NewContext(
context.Background(), &session.Session{
Expand Down
4 changes: 2 additions & 2 deletions internal/hermes-api/test/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ func TestListApps(t *testing.T) {
})
t.Logf("nextApps, err: %+v, %v", nextApps, err)
require.NoError(t, err)
require.GreaterOrEqual(t, len(nextApps.GetApps()), 1)
require.NotEmpty(t, nextApps.GetApps())
require.GreaterOrEqual(t, nextApps.GetTotalSize(), int32(3))
})

Expand All @@ -560,7 +560,7 @@ func TestListApps(t *testing.T) {
listApps, err := secCli.ListApps(ctx, &api.ListAppsRequest{})
t.Logf("listApps, err: %+v, %v", listApps, err)
require.NoError(t, err)
require.Len(t, listApps.GetApps(), 0)
require.Empty(t, listApps.GetApps())
require.Equal(t, int32(0), listApps.GetTotalSize())
})

Expand Down
4 changes: 2 additions & 2 deletions internal/hermes-api/test/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestListEvents(t *testing.T) {
})
t.Logf("listEvents, err: %+v, %v", listEvents, err)
require.NoError(t, err)
require.Len(t, listEvents.GetEvents(), 0)
require.Empty(t, listEvents.GetEvents())
})

t.Run("List events by invalid time range", func(t *testing.T) {
Expand Down Expand Up @@ -283,7 +283,7 @@ func TestLatestEvents(t *testing.T) {
latEvents, err := evCli.LatestEvents(ctx, &api.LatestEventsRequest{})
t.Logf("latEvents, err: %+v, %v", latEvents, err)
require.NoError(t, err)
require.Len(t, latEvents.GetEvents(), 0)
require.Empty(t, latEvents.GetEvents())
})

t.Run("Latest events by invalid identity ID", func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions internal/hermes-api/test/identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ func TestListIdentities(t *testing.T) {
})
t.Logf("nextIdentities, err: %+v, %v", nextIdentities, err)
require.NoError(t, err)
require.GreaterOrEqual(t, len(nextIdentities.GetIdentities()), 1)
require.NotEmpty(t, nextIdentities.GetIdentities())
require.GreaterOrEqual(t, nextIdentities.GetTotalSize(), int32(3))
})

Expand Down Expand Up @@ -1880,7 +1880,7 @@ func TestListIdentities(t *testing.T) {
&api.ListIdentitiesRequest{})
t.Logf("listIdentities, err: %+v, %v", listIdentities, err)
require.NoError(t, err)
require.Len(t, listIdentities.GetIdentities(), 0)
require.Empty(t, listIdentities.GetIdentities())
require.Equal(t, int32(0), listIdentities.GetTotalSize())
})

Expand Down
2 changes: 1 addition & 1 deletion internal/hermes-api/test/org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ func TestListOrgs(t *testing.T) {
})
t.Logf("nextOrgs, err: %+v, %v", nextOrgs, err)
require.NoError(t, err)
require.GreaterOrEqual(t, len(nextOrgs.GetOrgs()), 1)
require.NotEmpty(t, nextOrgs.GetOrgs())
require.GreaterOrEqual(t, nextOrgs.GetTotalSize(), int32(3))
})

Expand Down
2 changes: 1 addition & 1 deletion internal/hermes-api/test/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func TestListKeys(t *testing.T) {
})
t.Logf("nextKeys, err: %+v, %v", nextKeys, err)
require.NoError(t, err)
require.GreaterOrEqual(t, len(nextKeys.GetKeys()), 1)
require.NotEmpty(t, nextKeys.GetKeys())
require.GreaterOrEqual(t, nextKeys.GetTotalSize(), int32(3))
})

Expand Down
4 changes: 2 additions & 2 deletions internal/hermes-api/test/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ func TestListUsers(t *testing.T) {
})
t.Logf("nextUsers, err: %+v, %v", nextUsers, err)
require.NoError(t, err)
require.GreaterOrEqual(t, len(nextUsers.GetUsers()), 1)
require.NotEmpty(t, nextUsers.GetUsers())
require.GreaterOrEqual(t, nextUsers.GetTotalSize(), int32(3))
})

Expand All @@ -804,7 +804,7 @@ func TestListUsers(t *testing.T) {
listUsers, err := secCli.ListUsers(ctx, &api.ListUsersRequest{})
t.Logf("listUsers, err: %+v, %v", listUsers, err)
require.NoError(t, err)
require.Len(t, listUsers.GetUsers(), 0)
require.Empty(t, listUsers.GetUsers())
require.Equal(t, int32(0), listUsers.GetTotalSize())
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/consterr/consterr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestOrg(t *testing.T) {

require.Equal(t, errStr, err.Error())
// Errors should compare exactly without reflection.
require.True(t, err == Error(errStr))
require.True(t, err == Error(errStr)) //nolint:testifylint // above

wrapErr := fmt.Errorf("%w: %s", err, random.String(10))
t.Logf("wrapErr: %v", wrapErr)
Expand Down
2 changes: 1 addition & 1 deletion pkg/dao/app/crudl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func TestList(t *testing.T) {
t.Logf("listApps, listCount, err: %+v, %v, %v", listApps, listCount,
err)
require.NoError(t, err)
require.Len(t, listApps, 0)
require.Empty(t, listApps)
require.Equal(t, int32(0), listCount)
})

Expand Down
4 changes: 2 additions & 2 deletions pkg/dao/event/crudl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestList(t *testing.T) {
event.GetCreatedAt().AsTime().Add(-time.Millisecond))
t.Logf("listEvents, err: %+v, %v", listEvents, err)
require.NoError(t, err)
require.Len(t, listEvents, 0)
require.Empty(t, listEvents)
})

t.Run("List events by invalid org ID", func(t *testing.T) {
Expand Down Expand Up @@ -261,7 +261,7 @@ func TestLatest(t *testing.T) {
event.GetIdentityId())
t.Logf("latEvents, err: %+v, %v", latEvents, err)
require.NoError(t, err)
require.Len(t, latEvents, 0)
require.Empty(t, latEvents)
})

t.Run("Latest events by invalid app ID", func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/dao/identity/crudl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ func TestList(t *testing.T) {
t.Logf("listIdentities, listCount, err: %+v, %v, %v", listIdentities,
listCount, err)
require.NoError(t, err)
require.Len(t, listIdentities, 0)
require.Empty(t, listIdentities)
require.Equal(t, int32(0), listCount)
})

Expand All @@ -856,7 +856,7 @@ func TestList(t *testing.T) {
t.Logf("listIdentities, listCount, err: %+v, %v, %v", listIdentities,
listCount, err)
require.NoError(t, err)
require.Len(t, listIdentities, 0)
require.Empty(t, listIdentities)
require.Equal(t, int32(0), listCount)
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/dao/key/crudl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func TestList(t *testing.T) {
t.Logf("listKeys, listCount, err: %+v, %v, %v", listKeys, listCount,
err)
require.NoError(t, err)
require.Len(t, listKeys, 0)
require.Empty(t, listKeys)
require.Equal(t, int32(0), listCount)
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/dao/user/crudl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ func TestList(t *testing.T) {
t.Logf("listUsers, listCount, err: %+v, %v, %v", listUsers, listCount,
err)
require.NoError(t, err)
require.Len(t, listUsers, 0)
require.Empty(t, listUsers)
require.Equal(t, int32(0), listCount)
})

Expand Down

0 comments on commit fd458c6

Please sign in to comment.