Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 732dd51

Browse files
fyrchikalexvanin
authored andcommitted
[#388] *: Remove nil check from setters
I knew one day `sed` would save me an hour of manual work: ``` sed -i -n -e ' s/) Set/) Set/ p t setter b end :setter n s/nil/nil/ t hasif p b end :hasif n :loop p n s/}/}/ t end b loop :end ' $@ goimports -w $@ ``` Signed-off-by: Evgenii Stratonikov <[email protected]>
1 parent 5016274 commit 732dd51

File tree

32 files changed

+714
-2104
lines changed

32 files changed

+714
-2104
lines changed

accounting/accounting.go

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ func (b *BalanceRequestBody) GetOwnerID() *refs.OwnerID {
4040
}
4141

4242
func (b *BalanceRequestBody) SetOwnerID(v *refs.OwnerID) {
43-
if b != nil {
44-
b.ownerID = v
45-
}
43+
b.ownerID = v
4644
}
4745

4846
func (b *BalanceRequest) GetBody() *BalanceRequestBody {
@@ -54,9 +52,7 @@ func (b *BalanceRequest) GetBody() *BalanceRequestBody {
5452
}
5553

5654
func (b *BalanceRequest) SetBody(v *BalanceRequestBody) {
57-
if b != nil {
58-
b.body = v
59-
}
55+
b.body = v
6056
}
6157

6258
func (d *Decimal) GetValue() int64 {
@@ -68,9 +64,7 @@ func (d *Decimal) GetValue() int64 {
6864
}
6965

7066
func (d *Decimal) SetValue(v int64) {
71-
if d != nil {
72-
d.val = v
73-
}
67+
d.val = v
7468
}
7569

7670
func (d *Decimal) GetPrecision() uint32 {
@@ -82,9 +76,7 @@ func (d *Decimal) GetPrecision() uint32 {
8276
}
8377

8478
func (d *Decimal) SetPrecision(v uint32) {
85-
if d != nil {
86-
d.prec = v
87-
}
79+
d.prec = v
8880
}
8981

9082
func (br *BalanceResponseBody) GetBalance() *Decimal {
@@ -96,9 +88,7 @@ func (br *BalanceResponseBody) GetBalance() *Decimal {
9688
}
9789

9890
func (br *BalanceResponseBody) SetBalance(v *Decimal) {
99-
if br != nil {
100-
br.bal = v
101-
}
91+
br.bal = v
10292
}
10393

10494
func (br *BalanceResponse) GetBody() *BalanceResponseBody {
@@ -110,7 +100,5 @@ func (br *BalanceResponse) GetBody() *BalanceResponseBody {
110100
}
111101

112102
func (br *BalanceResponse) SetBody(v *BalanceResponseBody) {
113-
if br != nil {
114-
br.body = v
115-
}
103+
br.body = v
116104
}

accounting/grpc/service.go

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,40 @@ import (
77

88
// SetOwnerId sets identifier of the account owner.
99
func (m *BalanceRequest_Body) SetOwnerId(v *refs.OwnerID) {
10-
if m != nil {
11-
m.OwnerId = v
12-
}
10+
m.OwnerId = v
1311
}
1412

1513
// SetBody sets body of the request.
1614
func (m *BalanceRequest) SetBody(v *BalanceRequest_Body) {
17-
if m != nil {
18-
m.Body = v
19-
}
15+
m.Body = v
2016
}
2117

2218
// SetMetaHeader sets meta header of the request.
2319
func (m *BalanceRequest) SetMetaHeader(v *session.RequestMetaHeader) {
24-
if m != nil {
25-
m.MetaHeader = v
26-
}
20+
m.MetaHeader = v
2721
}
2822

2923
// SetVerifyHeader sets verification header of the request.
3024
func (m *BalanceRequest) SetVerifyHeader(v *session.RequestVerificationHeader) {
31-
if m != nil {
32-
m.VerifyHeader = v
33-
}
25+
m.VerifyHeader = v
3426
}
3527

3628
// SetBalance sets balance value of the response.
3729
func (m *BalanceResponse_Body) SetBalance(v *Decimal) {
38-
if m != nil {
39-
m.Balance = v
40-
}
30+
m.Balance = v
4131
}
4232

4333
// SetBody sets body of the response.
4434
func (m *BalanceResponse) SetBody(v *BalanceResponse_Body) {
45-
if m != nil {
46-
m.Body = v
47-
}
35+
m.Body = v
4836
}
4937

5038
// SetMetaHeader sets meta header of the response.
5139
func (m *BalanceResponse) SetMetaHeader(v *session.ResponseMetaHeader) {
52-
if m != nil {
53-
m.MetaHeader = v
54-
}
40+
m.MetaHeader = v
5541
}
5642

5743
// SetVerifyHeader sets verification header of the response.
5844
func (m *BalanceResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) {
59-
if m != nil {
60-
m.VerifyHeader = v
61-
}
45+
m.VerifyHeader = v
6246
}

accounting/grpc/types.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@ package accounting
22

33
// SetValue sets value of the decimal number.
44
func (m *Decimal) SetValue(v int64) {
5-
if m != nil {
6-
m.Value = v
7-
}
5+
m.Value = v
86
}
97

108
// SetPrecision sets precision of the decimal number.
119
func (m *Decimal) SetPrecision(v uint32) {
12-
if m != nil {
13-
m.Precision = v
14-
}
10+
m.Precision = v
1511
}

acl/grpc/types.go

Lines changed: 21 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,149 +6,107 @@ import (
66

77
// SetVersion sets version of EACL rules in table.
88
func (m *EACLTable) SetVersion(v *refs.Version) {
9-
if m != nil {
10-
m.Version = v
11-
}
9+
m.Version = v
1210
}
1311

1412
// SetContainerId sets container identifier of the eACL table.
1513
func (m *EACLTable) SetContainerId(v *refs.ContainerID) {
16-
if m != nil {
17-
m.ContainerId = v
18-
}
14+
m.ContainerId = v
1915
}
2016

2117
// SetRecords sets record list of the eACL table.
2218
func (m *EACLTable) SetRecords(v []*EACLRecord) {
23-
if m != nil {
24-
m.Records = v
25-
}
19+
m.Records = v
2620
}
2721

2822
// SetOperation sets operation of the eACL record.
2923
func (m *EACLRecord) SetOperation(v Operation) {
30-
if m != nil {
31-
m.Operation = v
32-
}
24+
m.Operation = v
3325
}
3426

3527
// SetAction sets action of the eACL record.
3628
func (m *EACLRecord) SetAction(v Action) {
37-
if m != nil {
38-
m.Action = v
39-
}
29+
m.Action = v
4030
}
4131

4232
// SetFilters sets filter list of the eACL record.
4333
func (m *EACLRecord) SetFilters(v []*EACLRecord_Filter) {
44-
if m != nil {
45-
m.Filters = v
46-
}
34+
m.Filters = v
4735
}
4836

4937
// SetTargets sets target list of the eACL record.
5038
func (m *EACLRecord) SetTargets(v []*EACLRecord_Target) {
51-
if m != nil {
52-
m.Targets = v
53-
}
39+
m.Targets = v
5440
}
5541

5642
// SetHeader sets header type of the eACL filter.
5743
func (m *EACLRecord_Filter) SetHeader(v HeaderType) {
58-
if m != nil {
59-
m.HeaderType = v
60-
}
44+
m.HeaderType = v
6145
}
6246

6347
// SetMatchType sets match type of the eACL filter.
6448
func (m *EACLRecord_Filter) SetMatchType(v MatchType) {
65-
if m != nil {
66-
m.MatchType = v
67-
}
49+
m.MatchType = v
6850
}
6951

7052
// SetKey sets key of the eACL filter.
7153
func (m *EACLRecord_Filter) SetKey(v string) {
72-
if m != nil {
73-
m.Key = v
74-
}
54+
m.Key = v
7555
}
7656

7757
// SetValue sets value of the eACL filter.
7858
func (m *EACLRecord_Filter) SetValue(v string) {
79-
if m != nil {
80-
m.Value = v
81-
}
59+
m.Value = v
8260
}
8361

8462
// SetRole sets target group of the eACL target.
8563
func (m *EACLRecord_Target) SetRole(v Role) {
86-
if m != nil {
87-
m.Role = v
88-
}
64+
m.Role = v
8965
}
9066

9167
// SetKeys of the eACL target.
9268
func (m *EACLRecord_Target) SetKeys(v [][]byte) {
93-
if m != nil {
94-
m.Keys = v
95-
}
69+
m.Keys = v
9670
}
9771

9872
// SetEaclTable sets eACL table of the bearer token.
9973
func (m *BearerToken_Body) SetEaclTable(v *EACLTable) {
100-
if m != nil {
101-
m.EaclTable = v
102-
}
74+
m.EaclTable = v
10375
}
10476

10577
// SetOwnerId sets identifier of the bearer token owner.
10678
func (m *BearerToken_Body) SetOwnerId(v *refs.OwnerID) {
107-
if m != nil {
108-
m.OwnerId = v
109-
}
79+
m.OwnerId = v
11080
}
11181

11282
// SetLifetime sets lifetime of the bearer token.
11383
func (m *BearerToken_Body) SetLifetime(v *BearerToken_Body_TokenLifetime) {
114-
if m != nil {
115-
m.Lifetime = v
116-
}
84+
m.Lifetime = v
11785
}
11886

11987
// SetBody sets bearer token body.
12088
func (m *BearerToken) SetBody(v *BearerToken_Body) {
121-
if m != nil {
122-
m.Body = v
123-
}
89+
m.Body = v
12490
}
12591

12692
// SetSignature sets bearer token signature.
12793
func (m *BearerToken) SetSignature(v *refs.Signature) {
128-
if m != nil {
129-
m.Signature = v
130-
}
94+
m.Signature = v
13195
}
13296

13397
// SetExp sets epoch number of the token expiration.
13498
func (m *BearerToken_Body_TokenLifetime) SetExp(v uint64) {
135-
if m != nil {
136-
m.Exp = v
137-
}
99+
m.Exp = v
138100
}
139101

140102
// SetNbf sets starting epoch number of the token.
141103
func (m *BearerToken_Body_TokenLifetime) SetNbf(v uint64) {
142-
if m != nil {
143-
m.Nbf = v
144-
}
104+
m.Nbf = v
145105
}
146106

147107
// SetIat sets the number of the epoch in which the token was issued.
148108
func (m *BearerToken_Body_TokenLifetime) SetIat(v uint64) {
149-
if m != nil {
150-
m.Iat = v
151-
}
109+
m.Iat = v
152110
}
153111

154112
// FromString parses Action from a string representation,

0 commit comments

Comments
 (0)