Skip to content

Commit d99feda

Browse files
authored
Merge pull request #1058 from ydb-platform/enable_protogetter_linter
Enable protogetter linter
2 parents fe6b521 + 5798413 commit d99feda

36 files changed

+348
-347
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ linters:
243243
- maligned
244244
- nonamedreturns
245245
- paralleltest
246-
- protogetter
247246
- scopelint
248247
- structcheck
249248
- testableexamples

internal/allocator/allocator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ type structAllocator struct {
375375

376376
func (a *structAllocator) Struct() (v *Ydb.StructType) {
377377
v = structPool.Get()
378-
if cap(v.Members) <= 0 {
378+
if cap(v.GetMembers()) <= 0 {
379379
v.Members = make([]*Ydb.StructMember, 0, 10)
380380
}
381381
a.allocations = append(a.allocations, v)
@@ -385,7 +385,7 @@ func (a *structAllocator) Struct() (v *Ydb.StructType) {
385385

386386
func (a *structAllocator) free() {
387387
for _, v := range a.allocations {
388-
members := v.Members
388+
members := v.GetMembers()
389389
for i := range members {
390390
members[i] = nil
391391
}
@@ -447,7 +447,7 @@ func (a *tupleAllocator) Tuple() (v *Ydb.TupleType) {
447447

448448
func (a *tupleAllocator) free() {
449449
for _, v := range a.allocations {
450-
elements := v.Elements
450+
elements := v.GetElements()
451451
for i := range elements {
452452
elements[i] = nil
453453
}
@@ -718,8 +718,8 @@ func (a *valueAllocator) Value() (v *Ydb.Value) {
718718

719719
func (a *valueAllocator) free() {
720720
for _, v := range a.allocations {
721-
items := v.Items
722-
pairs := v.Pairs
721+
items := v.GetItems()
722+
pairs := v.GetPairs()
723723
for i := range items {
724724
items[i] = nil
725725
}

internal/discovery/discovery.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ func (c *Client) Discover(ctx context.Context) (endpoints []endpoint.Endpoint, e
8080
}
8181

8282
location = result.GetSelfLocation()
83-
endpoints = make([]endpoint.Endpoint, 0, len(result.Endpoints))
84-
for _, e := range result.Endpoints {
85-
if e.Ssl == c.config.Secure() {
83+
endpoints = make([]endpoint.Endpoint, 0, len(result.GetEndpoints()))
84+
for _, e := range result.GetEndpoints() {
85+
if e.GetSsl() == c.config.Secure() {
8686
endpoints = append(endpoints, endpoint.New(
8787
net.JoinHostPort(e.GetAddress(), strconv.Itoa(int(e.GetPort()))),
8888
endpoint.WithLocation(e.GetLocation()),

internal/grpcwrapper/rawscheme/entry.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@ func (e *Entry) FromProto(proto *Ydb_Scheme.Entry) error {
2626
if proto == nil {
2727
return xerrors.WithStackTrace(errUnexpectedNilForSchemeEntry)
2828
}
29-
e.Name = proto.Name
30-
e.Owner = proto.Owner
31-
e.Type = EntryType(proto.Type)
29+
e.Name = proto.GetName()
30+
e.Owner = proto.GetOwner()
31+
e.Type = EntryType(proto.GetType())
3232

33-
e.EffectivePermissions = make([]Permissions, len(proto.EffectivePermissions))
34-
for i := range proto.EffectivePermissions {
35-
if err := e.EffectivePermissions[i].FromProto(proto.EffectivePermissions[i]); err != nil {
33+
e.EffectivePermissions = make([]Permissions, len(proto.GetEffectivePermissions()))
34+
for i := range proto.GetEffectivePermissions() {
35+
if err := e.EffectivePermissions[i].FromProto(proto.GetEffectivePermissions()[i]); err != nil {
3636
return err
3737
}
3838
}
3939

40-
e.Permissions = make([]Permissions, len(proto.Permissions))
41-
for i := range proto.Permissions {
42-
if err := e.Permissions[i].FromProto(proto.Permissions[i]); err != nil {
40+
e.Permissions = make([]Permissions, len(proto.GetPermissions()))
41+
for i := range proto.GetPermissions() {
42+
if err := e.Permissions[i].FromProto(proto.GetPermissions()[i]); err != nil {
4343
return err
4444
}
4545
}
4646

47-
e.SizeBytes = proto.SizeBytes
47+
e.SizeBytes = proto.GetSizeBytes()
4848

4949
return nil
5050
}
@@ -74,8 +74,8 @@ func (p *Permissions) FromProto(proto *Ydb_Scheme.Permissions) error {
7474
if proto == nil {
7575
return xerrors.WithStackTrace(errUnexpectedNilForSchemePermissions)
7676
}
77-
p.Subject = proto.Subject
78-
p.PermissionNames = proto.PermissionNames
77+
p.Subject = proto.GetSubject()
78+
p.PermissionNames = proto.GetPermissionNames()
7979

8080
return nil
8181
}

internal/grpcwrapper/rawtopic/alter_topic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type AlterTopicResult struct {
6464
}
6565

6666
func (r *AlterTopicResult) FromProto(proto *Ydb_Topic.AlterTopicResponse) error {
67-
return r.Operation.FromProtoWithStatusCheck(proto.Operation)
67+
return r.Operation.FromProtoWithStatusCheck(proto.GetOperation())
6868
}
6969

7070
type AlterConsumer struct {

internal/grpcwrapper/rawtopic/controlplane_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (c *Consumer) MustFromProto(consumer *Ydb_Topic.Consumer) {
2525
c.Important = consumer.GetImportant()
2626
c.Attributes = consumer.GetAttributes()
2727
c.ReadFrom.MustFromProto(consumer.GetReadFrom())
28-
c.SupportedCodecs.MustFromProto(consumer.SupportedCodecs)
28+
c.SupportedCodecs.MustFromProto(consumer.GetSupportedCodecs())
2929
}
3030

3131
func (c *Consumer) ToProto() *Ydb_Topic.Consumer {
@@ -56,8 +56,8 @@ func (s *PartitioningSettings) FromProto(proto *Ydb_Topic.PartitioningSettings)
5656
return xerrors.WithStackTrace(errUnexpectedNilPartitioningSettings)
5757
}
5858

59-
s.MinActivePartitions = proto.MinActivePartitions
60-
s.PartitionCountLimit = proto.PartitionCountLimit
59+
s.MinActivePartitions = proto.GetMinActivePartitions()
60+
s.PartitionCountLimit = proto.GetPartitionCountLimit()
6161

6262
return nil
6363
}

internal/grpcwrapper/rawtopic/create_topic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (req *CreateTopicRequest) ToProto() *Ydb_Topic.CreateTopicRequest {
4141
proto.Attributes = req.Attributes
4242

4343
proto.Consumers = make([]*Ydb_Topic.Consumer, len(req.Consumers))
44-
for i := range proto.Consumers {
44+
for i := range proto.GetConsumers() {
4545
proto.Consumers[i] = req.Consumers[i].ToProto()
4646
}
4747

@@ -55,5 +55,5 @@ type CreateTopicResult struct {
5555
}
5656

5757
func (r *CreateTopicResult) FromProto(proto *Ydb_Topic.CreateTopicResponse) error {
58-
return r.Operation.FromProtoWithStatusCheck(proto.Operation)
58+
return r.Operation.FromProtoWithStatusCheck(proto.GetOperation())
5959
}

internal/grpcwrapper/rawtopic/describe_topic.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type DescribeTopicResult struct {
4242
}
4343

4444
func (res *DescribeTopicResult) FromProto(protoResponse *Ydb_Topic.DescribeTopicResponse) error {
45-
if err := res.Operation.FromProtoWithStatusCheck(protoResponse.Operation); err != nil {
45+
if err := res.Operation.FromProtoWithStatusCheck(protoResponse.GetOperation()); err != nil {
4646
return err
4747
}
4848

@@ -51,11 +51,11 @@ func (res *DescribeTopicResult) FromProto(protoResponse *Ydb_Topic.DescribeTopic
5151
return xerrors.WithStackTrace(fmt.Errorf("ydb: describe topic result failed on unmarshal grpc result: %w", err))
5252
}
5353

54-
if err := res.Self.FromProto(protoResult.Self); err != nil {
54+
if err := res.Self.FromProto(protoResult.GetSelf()); err != nil {
5555
return err
5656
}
5757

58-
if err := res.PartitioningSettings.FromProto(protoResult.PartitioningSettings); err != nil {
58+
if err := res.PartitioningSettings.FromProto(protoResult.GetPartitioningSettings()); err != nil {
5959
return err
6060
}
6161

@@ -72,17 +72,17 @@ func (res *DescribeTopicResult) FromProto(protoResponse *Ydb_Topic.DescribeTopic
7272
res.SupportedCodecs = append(res.SupportedCodecs, rawtopiccommon.Codec(v))
7373
}
7474

75-
res.PartitionWriteSpeedBytesPerSecond = protoResult.PartitionWriteSpeedBytesPerSecond
76-
res.PartitionWriteBurstBytes = protoResult.PartitionWriteBurstBytes
75+
res.PartitionWriteSpeedBytesPerSecond = protoResult.GetPartitionWriteSpeedBytesPerSecond()
76+
res.PartitionWriteBurstBytes = protoResult.GetPartitionWriteBurstBytes()
7777

78-
res.Attributes = protoResult.Attributes
78+
res.Attributes = protoResult.GetAttributes()
7979

80-
res.Consumers = make([]Consumer, len(protoResult.Consumers))
80+
res.Consumers = make([]Consumer, len(protoResult.GetConsumers()))
8181
for i := range res.Consumers {
82-
res.Consumers[i].MustFromProto(protoResult.Consumers[i])
82+
res.Consumers[i].MustFromProto(protoResult.GetConsumers()[i])
8383
}
8484

85-
res.MeteringMode = MeteringMode(protoResult.MeteringMode)
85+
res.MeteringMode = MeteringMode(protoResult.GetMeteringMode())
8686

8787
return nil
8888
}

internal/grpcwrapper/rawtopic/drop_topic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ type DropTopicResult struct {
2323
}
2424

2525
func (r *DropTopicResult) FromProto(proto *Ydb_Topic.DropTopicResponse) error {
26-
return r.Operation.FromProtoWithStatusCheck(proto.Operation)
26+
return r.Operation.FromProtoWithStatusCheck(proto.GetOperation())
2727
}

internal/grpcwrapper/rawtopic/rawtopiccommon/codec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (c *SupportedCodecs) ToProto() *Ydb_Topic.SupportedCodecs {
9898
func (c *SupportedCodecs) MustFromProto(proto *Ydb_Topic.SupportedCodecs) {
9999
res := make([]Codec, len(proto.GetCodecs()))
100100
for i := range proto.GetCodecs() {
101-
res[i].MustFromProto(Ydb_Topic.Codec(proto.Codecs[i]))
101+
res[i].MustFromProto(Ydb_Topic.Codec(proto.GetCodecs()[i]))
102102
}
103103
*c = res
104104
}

0 commit comments

Comments
 (0)