Skip to content

Commit

Permalink
fix: golang lint
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Aug 23, 2024
1 parent b1bdbb4 commit fdde415
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ linters:
- staticcheck
- revive
- gosec
- exportloopref
- copyloopvar
- prealloc
linters-settings:
gocritic:
Expand Down
6 changes: 3 additions & 3 deletions go/grpc/gogoreflection/serverreflection.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func fqn(prefix, name string) string {
// fileDescForType gets the file descriptor for the given type.
// The given type should be a proto message.
func (s *serverReflectionServer) fileDescForType(st reflect.Type) (*dpb.FileDescriptorProto, error) {
m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(protoMessage)
m, ok := reflect.Zero(reflect.PointerTo(st)).Interface().(protoMessage)
if !ok {
return nil, fmt.Errorf("failed to create message from type: %v", st)
}
Expand Down Expand Up @@ -232,7 +232,7 @@ func typeForName(name string) (reflect.Type, error) {
}

func fileDescContainingExtension(st reflect.Type, ext int32) (*dpb.FileDescriptorProto, error) {
m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(proto.Message)
m, ok := reflect.Zero(reflect.PointerTo(st)).Interface().(proto.Message)
if !ok {
return nil, fmt.Errorf("failed to create message from type: %v", st)
}
Expand All @@ -247,7 +247,7 @@ func fileDescContainingExtension(st reflect.Type, ext int32) (*dpb.FileDescripto
}

func (s *serverReflectionServer) allExtensionNumbersForType(st reflect.Type) ([]int32, error) {
m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(proto.Message)
m, ok := reflect.Zero(reflect.PointerTo(st)).Interface().(proto.Message)
if !ok {
return nil, fmt.Errorf("failed to create message from type: %v", st)
}
Expand Down
4 changes: 2 additions & 2 deletions go/inventory/v1/resourcepair.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (m *ResourcePair) SubMilliNLZ(val types.ResourceValue) bool {
}

allocated := m.Allocated.DeepCopy()
allocated.Add(*resource.NewMilliQuantity(int64(val.Value()), resource.DecimalSI))
allocated.Add(*resource.NewMilliQuantity(int64(val.Value()), resource.DecimalSI)) // nolint: gosec

allocatable := m.Allocatable.DeepCopy()

Expand All @@ -91,7 +91,7 @@ func (m *ResourcePair) SubNLZ(val types.ResourceValue) bool {
}

allocated := m.Allocated.DeepCopy()
allocated.Add(*resource.NewQuantity(int64(val.Value()), resource.DecimalSI))
allocated.Add(*resource.NewQuantity(int64(val.Value()), resource.DecimalSI)) // nolint: gosec

allocatable := m.Allocatable.DeepCopy()

Expand Down
2 changes: 1 addition & 1 deletion go/manifest/v2beta3/manifest_cross_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestManifestWithDeployment(t *testing.T) {
}

func TestManifestWithDeploymentMultipleCount(t *testing.T) {
addl := uint32(tutil.RandRangeInt(1, 20))
addl := uint32(tutil.RandRangeInt(1, 20)) // nolint: gosec
m := simpleManifest(addl)

deployment := simpleDeployment(t, m[0].Services[0].Expose, addl)
Expand Down
8 changes: 4 additions & 4 deletions go/manifest/v2beta3/serviceexpose.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ func (s *ServiceExpose) checkAgainstResources(res *dtypes.ResourceUnit, eps vali
}

func (s *ServiceExpose) IsIngress() bool {
return s.Proto == TCP && s.Global && 80 == s.GetExternalPort()
return s.Proto == TCP && s.Global && uint32(80) == s.GetExternalPort()
}

func (s *ServiceExpose) GetExternalPort() int32 {
func (s *ServiceExpose) GetExternalPort() uint32 {
if s.ExternalPort == 0 {
return int32(s.Port)
return s.Port
}

return int32(s.ExternalPort)
return s.ExternalPort
}
2 changes: 1 addition & 1 deletion go/node/client/v1beta3/testutil/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func Resources(t testing.TB) dtypes.ResourceUnits {
coin := sdk.NewDecCoin(CoinDenom, sdk.NewInt(rand.Int63n(9999)+1))
res := dtypes.ResourceUnit{
Resources: types.Resources{
ID: uint32(i) + 1,
ID: uint32(i) + 1, // nolint: gosec
CPU: &types.CPU{
Units: types.NewResourceValue(uint64(dtypes.GetValidationConfig().Unit.Min.CPU)),
},
Expand Down
2 changes: 1 addition & 1 deletion go/node/market/v1beta5/escrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ func LeaseIDFromEscrowAccount(id etypes.AccountID, pid string) (v1.LeaseID, bool
v1.MakeBidID(
v1.MakeOrderID(
dtypesv1.MakeGroupID(
did, uint32(gseq)), uint32(oseq)), owner)), true
did, uint32(gseq)), uint32(oseq)), owner)), true // nolint: gosec
}
2 changes: 1 addition & 1 deletion go/testutil/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func Resources(t testing.TB) []dtypes.ResourceUnit {
coin := sdk.NewDecCoin(CoinDenom, sdk.NewInt(rand.Int63n(9999)+1))
res := dtypes.ResourceUnit{
Resources: types.Resources{
ID: uint32(i) + 1,
ID: uint32(i) + 1, // nolint: gosec
CPU: &types.CPU{
Units: types.NewResourceValue(uint64(dtypes.GetValidationConfig().Unit.Min.CPU)),
},
Expand Down
2 changes: 1 addition & 1 deletion go/testutil/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func DeploymentGroups(t testing.TB, did dtypes.DeploymentID, gseq uint32) dtypes
count := rand.Intn(5) + 5 // nolint:gosec
vals := make(dtypesv1beta4.Groups, 0, count)
for i := 0; i < count; i++ {
vals = append(vals, DeploymentGroup(t, did, gseq+uint32(i)))
vals = append(vals, DeploymentGroup(t, did, gseq+uint32(i))) // nolint: gosec
}
return vals
}
2 changes: 1 addition & 1 deletion go/testutil/v1beta3/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func RandStorageQuantity() uint64 {
func ResourcesList(t testing.TB, startID uint32) dtypes.ResourceUnits {
require.GreaterOrEqual(t, startID, uint32(1))

count := uint32(rand.Intn(10)) + 1
count := uint32(rand.Intn(10)) + 1 // nolint: gosec

vals := make(dtypes.ResourceUnits, 0, count)
for i := uint32(0); i < count; i++ {
Expand Down
2 changes: 1 addition & 1 deletion go/testutil/v1beta3/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func DeploymentGroups(t testing.TB, did dtypes.DeploymentID, gseq uint32) dtypes
count := rand.Intn(5) + 5 // nolint:gosec
vals := make(dtypesv1beta4.Groups, 0, count)
for i := 0; i < count; i++ {
vals = append(vals, DeploymentGroup(t, did, gseq+uint32(i)))
vals = append(vals, DeploymentGroup(t, did, gseq+uint32(i))) // nolint: gosec
}
return vals
}

0 comments on commit fdde415

Please sign in to comment.