Skip to content

Commit cf01642

Browse files
authored
Merge pull request #1023 from ShishkovEM/master
enable ifshort linter
2 parents f22a42c + 5f81a80 commit cf01642

File tree

24 files changed

+51
-77
lines changed

24 files changed

+51
-77
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ linters:
232232
- godot
233233
- goerr113
234234
- golint
235-
- ifshort
236235
- interfacebloat
237236
- ireturn
238237
- maintidx

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
## v3.68.0
1+
* Refactored internal packages by `ifshort` linter issues
2+
3+
# v3.68.0
24
* Added experimental `ydb.{Register,Unregister}DsnParser` global funcs for register/unregister external custom DSN parser for `ydb.Open` and `sql.Open` driver constructor
35
* Simple implement option WithReaderWithoutConsumer
46
* Fixed bug: topic didn't send specified partition number to a server

examples/basic/native/table/series.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,7 @@ func describeTable(ctx context.Context, c table.Client, path string) error {
409409

410410
func render(t *template.Template, data interface{}) string {
411411
var buf bytes.Buffer
412-
err := t.Execute(&buf, data)
413-
if err != nil {
412+
if err := t.Execute(&buf, data); err != nil {
414413
panic(err)
415414
}
416415

examples/decimal/decimal.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ SELECT value FROM decimals;
3030

3131
func render(t *template.Template, data interface{}) string {
3232
var buf bytes.Buffer
33-
err := t.Execute(&buf, data)
34-
if err != nil {
33+
if err := t.Execute(&buf, data); err != nil {
3534
panic(err)
3635
}
3736

examples/read_table/orders.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ FROM AS_TABLE($ordersData);
7373

7474
func render(t *template.Template, data interface{}) string {
7575
var buf bytes.Buffer
76-
err := t.Execute(&buf, data)
77-
if err != nil {
76+
if err := t.Execute(&buf, data); err != nil {
7877
panic(err)
7978
}
8079

examples/serverless/url_shortener/service.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ var (
4141

4242
func hash(s string) (string, error) {
4343
hasher := fnv.New32a()
44-
_, err := hasher.Write([]byte(s))
45-
if err != nil {
44+
if _, err := hasher.Write([]byte(s)); err != nil {
4645
return "", err
4746
}
4847

@@ -59,8 +58,7 @@ func isLongCorrect(link string) bool {
5958

6059
func render(t *template.Template, data interface{}) string {
6160
var buf bytes.Buffer
62-
err := t.Execute(&buf, data)
63-
if err != nil {
61+
if err := t.Execute(&buf, data); err != nil {
6462
panic(err)
6563
}
6664

examples/topic/cdc-cache-bus-freeseats/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ var (
2727
func main() {
2828
flag.Parse()
2929

30-
ctx := context.Background()
3130
db := connect()
3231

3332
if !*skipCreateTable {
34-
createTableAndCDC(ctx, db, *backendCount)
33+
createTableAndCDC(context.Background(), db, *backendCount)
3534
}
3635

3736
servers := make([]http.Handler, *backendCount)

internal/conn/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (c *conn) setState(ctx context.Context, s State) State {
161161
func (c *conn) Unban(ctx context.Context) State {
162162
var newState State
163163
c.mtx.RLock()
164-
cc := c.grpcConn
164+
cc := c.grpcConn //nolint:ifshort
165165
c.mtx.RUnlock()
166166
if isAvailable(cc) {
167167
newState = Online

internal/coordination/conversation/conversation.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ func (c *Controller) OnSend(ctx context.Context) (*Ydb_Coordination.SessionReque
315315
// OnRecv consumes a new conversation response and process with the corresponding conversation if any exists for it. The
316316
// returned value indicates if any conversation considers the incoming message part of it or the controller is closed.
317317
// You should call this method in the goroutine that handles gRPC stream Recv method.
318+
//
319+
//nolint:ifshort // false-positive this var is used outside if statement in switch-case up
318320
func (c *Controller) OnRecv(resp *Ydb_Coordination.SessionResponse) bool {
319321
c.mutex.Lock()
320322
defer c.mutex.Unlock()

internal/decimal/decimal.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ func FromBytes(bts []byte, precision, scale uint32) *big.Int {
6161
}
6262

6363
v.SetBytes(bts)
64-
65-
neg := bts[0]&negMask != 0
64+
neg := bts[0]&negMask != 0 //nolint:ifshort
6665
if neg {
6766
// Given bytes contains negative value.
6867
// Interpret is as two's complement.
@@ -99,7 +98,7 @@ func Parse(s string, precision, scale uint32) (*big.Int, error) {
9998
return v, nil
10099
}
101100

102-
neg := s[0] == '-'
101+
neg := s[0] == '-' //nolint:ifshort
103102
if neg || s[0] == '+' {
104103
s = s[1:]
105104
}
@@ -212,7 +211,7 @@ func Format(x *big.Int, precision, scale uint32) string {
212211
}
213212

214213
v := big.NewInt(0).Set(x)
215-
neg := x.Sign() < 0
214+
neg := x.Sign() < 0 //nolint:ifshort
216215
if neg {
217216
// Convert negative to positive.
218217
v.Neg(x)
@@ -288,7 +287,7 @@ func BigIntToByte(x *big.Int, precision, scale uint32) (p [16]byte) {
288287
}
289288

290289
func put(x *big.Int, p []byte) {
291-
neg := x.Sign() < 0
290+
neg := x.Sign() < 0 //nolint:ifshort
292291
if neg {
293292
x = complement(x)
294293
}

0 commit comments

Comments
 (0)