Skip to content

Commit f8b0b48

Browse files
authored
Merge pull request #1048 from 11Petrov/master
enable gomnd linter
2 parents 6e51a12 + 281a3f8 commit f8b0b48

File tree

36 files changed

+88
-57
lines changed

36 files changed

+88
-57
lines changed

.golangci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ linters:
234234
- godot
235235
- goerr113
236236
- golint
237-
- gomnd
238237
- ifshort
239238
- interfacebloat
240239
- ireturn
@@ -304,6 +303,9 @@ issues:
304303
- staticcheck
305304
- path: _test\.go
306305
text: "ydb.Connection is deprecated"
306+
- path: examples
307+
linters:
308+
- gomnd
307309

308310
# Allow underscore and capital camel case for readability
309311
# Examples: Type_PRIMITIVE_TYPE_ID_UNSPECIFIED, Ydb_Discovery_V1, _voidValue

internal/allocator/allocator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ type structAllocator struct {
395395
func (a *structAllocator) Struct() (v *Ydb.StructType) {
396396
v = structPool.Get()
397397
if cap(v.GetMembers()) <= 0 {
398-
v.Members = make([]*Ydb.StructMember, 0, 10)
398+
v.Members = make([]*Ydb.StructMember, 0, 10) //nolint:gomnd
399399
}
400400
a.allocations = append(a.allocations, v)
401401

internal/backoff/backoff.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ const (
2222
var (
2323
Fast = New(
2424
WithSlotDuration(fastSlot),
25-
WithCeiling(6),
25+
WithCeiling(6), //nolint:gomnd
2626
)
2727
Slow = New(
2828
WithSlotDuration(slowSlot),
29-
WithCeiling(6),
29+
WithCeiling(6), //nolint:gomnd
3030
)
3131
)
3232

internal/balancer/local_dc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func detectFastestEndpoint(ctx context.Context, endpoints []endpoint.Endpoint) (
6969

7070
var lastErr error
7171
// common is 2 ip address for every fqdn: ipv4 + ipv6
72-
initialAddressToEndpointCapacity := len(endpoints) * 2
72+
initialAddressToEndpointCapacity := len(endpoints) * 2 //nolint:gomnd
7373
addressToEndpoint := make(map[string]endpoint.Endpoint, initialAddressToEndpointCapacity)
7474
for _, ep := range endpoints {
7575
host, port, err := extractHostPort(ep.Address())

internal/cmd/gtrace/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func main() {
6767
f, err = os.OpenFile(
6868
filepath.Join(workDir, filepath.Clean(name)),
6969
os.O_WRONLY|os.O_CREATE|os.O_TRUNC,
70-
0o600,
70+
0o600, //nolint:gomnd
7171
)
7272
if err != nil {
7373
log.Fatal(err)

internal/cmd/gtrace/writer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ func (s *scope) set(v string) bool {
10321032
if _, has := s.vars[v]; has {
10331033
return false
10341034
}
1035-
_, file, line, _ := runtime.Caller(2)
1035+
_, file, line, _ := runtime.Caller(2) //nolint:gomnd
10361036
s.vars[v] = decl{
10371037
where: fmt.Sprintf("%s:%d", file, line),
10381038
}

internal/conn/pool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func NewPool(ctx context.Context, config Config) *Pool {
246246
}
247247

248248
if ttl := config.ConnectionTTL(); ttl > 0 {
249-
go p.connParker(xcontext.ValueOnly(ctx), ttl, ttl/2)
249+
go p.connParker(xcontext.ValueOnly(ctx), ttl, ttl/2) //nolint:gomnd
250250
}
251251

252252
return p

internal/coordination/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,11 @@ func (c *Client) closeSessions(ctx context.Context) {
336336
func defaultCreateSessionConfig() *options.CreateSessionOptions {
337337
return &options.CreateSessionOptions{
338338
Description: "YDB Go SDK",
339-
SessionTimeout: time.Second * 5,
339+
SessionTimeout: time.Second * 5, //nolint:gomnd
340340
SessionStartTimeout: time.Second * 1,
341341
SessionStopTimeout: time.Second * 1,
342-
SessionKeepAliveTimeout: time.Second * 10,
343-
SessionReconnectDelay: time.Millisecond * 500,
342+
SessionKeepAliveTimeout: time.Second * 10, //nolint:gomnd
343+
SessionReconnectDelay: time.Millisecond * 500, //nolint:gomnd
344344
}
345345
}
346346

internal/coordination/session.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func createSession(
7373
}
7474

7575
func newProtectionKey() []byte {
76-
key := make([]byte, 8)
76+
key := make([]byte, 8) //nolint:gomnd
7777
binary.LittleEndian.PutUint64(key, rand.Uint64()) //nolint:gosec
7878

7979
return key
@@ -120,7 +120,7 @@ func (s *session) newStream(
120120
deadline = s.getLastGoodResponseTime().Add(s.options.SessionTimeout)
121121
} else {
122122
// Large enough to make the loop infinite, small enough to allow the maximum duration value (~290 years).
123-
deadline = time.Now().Add(time.Hour * 24 * 365 * 100)
123+
deadline = time.Now().Add(time.Hour * 24 * 365 * 100) //nolint:gomnd
124124
}
125125

126126
lastChance := false
@@ -230,7 +230,7 @@ func (s *session) mainLoop(path string, sessionStartedChan chan struct{}) {
230230

231231
// Start the loops.
232232
wg := sync.WaitGroup{}
233-
wg.Add(2)
233+
wg.Add(2) //nolint:gomnd
234234
sessionStarted := make(chan *Ydb_Coordination.SessionResponse_SessionStarted, 1)
235235
sessionStopped := make(chan *Ydb_Coordination.SessionResponse_SessionStopped, 1)
236236
startSending := make(chan struct{})

internal/credentials/static.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xstring"
2020
)
2121

22+
const TokenRefreshDivisor = 10
23+
2224
var (
2325
_ Credentials = (*Static)(nil)
2426
_ fmt.Stringer = (*Static)(nil)
@@ -133,7 +135,7 @@ func (c *Static) Token(ctx context.Context) (token string, err error) {
133135
return "", xerrors.WithStackTrace(err)
134136
}
135137

136-
c.requestAt = time.Now().Add(time.Until(expiresAt) / 10)
138+
c.requestAt = time.Now().Add(time.Until(expiresAt) / TokenRefreshDivisor)
137139
c.token = result.GetToken()
138140

139141
return c.token, nil

0 commit comments

Comments
 (0)