Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore]: enable int-conversion rule of perfsprint #5964

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ linters:
- govet
- ineffassign
- misspell
- perfsprint
- revive
- staticcheck
- tenv
Expand Down Expand Up @@ -61,10 +62,11 @@ issues:
text: "calls to (.+) only in main[(][)] or init[(][)] functions"
linters:
- revive
# It's okay to not run gosec in a test.
# It's okay to not run gosec and perfsprint in a test.
- path: _test\.go
linters:
- gosec
- perfsprint
# Ignoring gosec G404: Use of weak random number generator (math/rand instead of crypto/rand)
# as we commonly use it in tests and examples.
- text: "G404:"
Expand Down Expand Up @@ -154,6 +156,12 @@ linters-settings:
locale: US
ignore-words:
- cancelled
perfsprint:
mmorel-35 marked this conversation as resolved.
Show resolved Hide resolved
err-error: false
errorf: false
int-conversion: true
sprintf1: false
strconcat: false
dmathieu marked this conversation as resolved.
Show resolved Hide resolved
revive:
# Sets the default failure confidence.
# This means that linting errors with less than 0.8 confidence will be ignored.
Expand Down
5 changes: 3 additions & 2 deletions bridge/opentracing/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package opentracing // import "go.opentelemetry.io/otel/bridge/opentracing"
import (
"context"
"fmt"
"strconv"
"strings"
"sync"

Expand Down Expand Up @@ -532,7 +533,7 @@ func otTagToOTelAttr(k string, v interface{}) attribute.KeyValue {
case int64:
return key.Int64(val)
case uint64:
return key.String(fmt.Sprintf("%d", val))
return key.String(strconv.FormatUint(val, 10))
case float64:
return key.Float64(val)
case int8:
Expand All @@ -552,7 +553,7 @@ func otTagToOTelAttr(k string, v interface{}) attribute.KeyValue {
case int:
return key.Int(val)
case uint:
return key.String(fmt.Sprintf("%d", val))
return key.String(strconv.FormatUint(uint64(val), 10))
case string:
return key.String(val)
default:
Expand Down
3 changes: 2 additions & 1 deletion exporters/zipkin/internal/internaltest/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package internaltest // import "go.opentelemetry.io/otel/exporters/zipkin/intern
import (
"context"
"fmt"
"strconv"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -58,7 +59,7 @@ func (h *Harness) TestTracerProvider(subjectFactory func() trace.TracerProvider)
go func(name, version string) {
_ = tp.Tracer(name, trace.WithInstrumentationVersion(version))
wg.Done()
}(fmt.Sprintf("tracer %d", i%5), fmt.Sprintf("%d", i))
}(fmt.Sprintf("tracer %d", i%5), strconv.Itoa(i))
}
wg.Wait()
done <- struct{}{}
Expand Down
3 changes: 2 additions & 1 deletion internal/internaltest/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package internaltest // import "go.opentelemetry.io/otel/internal/internaltest"
import (
"context"
"fmt"
"strconv"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -58,7 +59,7 @@ func (h *Harness) TestTracerProvider(subjectFactory func() trace.TracerProvider)
go func(name, version string) {
_ = tp.Tracer(name, trace.WithInstrumentationVersion(version))
wg.Done()
}(fmt.Sprintf("tracer %d", i%5), fmt.Sprintf("%d", i))
}(fmt.Sprintf("tracer %d", i%5), strconv.Itoa(i))
}
wg.Wait()
done <- struct{}{}
Expand Down
3 changes: 2 additions & 1 deletion internal/shared/internaltest/harness.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package internaltest
import (
"context"
"fmt"
"strconv"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -58,7 +59,7 @@ func (h *Harness) TestTracerProvider(subjectFactory func() trace.TracerProvider)
go func(name, version string) {
_ = tp.Tracer(name, trace.WithInstrumentationVersion(version))
wg.Done()
}(fmt.Sprintf("tracer %d", i%5), fmt.Sprintf("%d", i))
}(fmt.Sprintf("tracer %d", i%5), strconv.Itoa(i))
}
wg.Wait()
done <- struct{}{}
Expand Down
3 changes: 2 additions & 1 deletion sdk/internal/internaltest/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package internaltest // import "go.opentelemetry.io/otel/sdk/internal/internalte
import (
"context"
"fmt"
"strconv"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -58,7 +59,7 @@ func (h *Harness) TestTracerProvider(subjectFactory func() trace.TracerProvider)
go func(name, version string) {
_ = tp.Tracer(name, trace.WithInstrumentationVersion(version))
wg.Done()
}(fmt.Sprintf("tracer %d", i%5), fmt.Sprintf("%d", i))
}(fmt.Sprintf("tracer %d", i%5), strconv.Itoa(i))
}
wg.Wait()
done <- struct{}{}
Expand Down
Loading