1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-26 21:05:00 +02:00

Add unconvert linter (#5529)

This adds the unconvert linter, and fixes every new issue related to it.

Co-authored-by: Sam Xie <sam@samxie.me>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
Damien Mathieu 2024-06-22 00:00:26 +02:00 committed by GitHub
parent 4a509d24e2
commit 3e91436a3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 19 additions and 18 deletions

View File

@ -23,6 +23,7 @@ linters:
- staticcheck
- tenv
- typecheck
- unconvert
- unused
issues:

View File

@ -233,7 +233,7 @@ func convertKV(key string, value any) attribute.KeyValue {
case uintptr:
return uint64KV(key, uint64(typedVal))
case uint64:
return uint64KV(key, uint64(typedVal))
return uint64KV(key, typedVal)
case float32:
return attribute.Float64(key, float64(typedVal))
case float64:

View File

@ -376,7 +376,7 @@ func TestConfigs(t *testing.T) {
{
name: "Test With Timeout",
opts: []GenericOption{
WithTimeout(time.Duration(5 * time.Second)),
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)

View File

@ -79,7 +79,7 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
out := &mpb.Metric{
Name: m.Name,
Description: m.Description,
Unit: string(m.Unit),
Unit: m.Unit,
}
switch a := m.Data.(type) {
case metricdata.Gauge[int64]:

View File

@ -376,7 +376,7 @@ func TestConfigs(t *testing.T) {
{
name: "Test With Timeout",
opts: []GenericOption{
WithTimeout(time.Duration(5 * time.Second)),
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)

View File

@ -79,7 +79,7 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
out := &mpb.Metric{
Name: m.Name,
Description: m.Description,
Unit: string(m.Unit),
Unit: m.Unit,
}
switch a := m.Data.(type) {
case metricdata.Gauge[int64]:

View File

@ -372,7 +372,7 @@ func TestConfigs(t *testing.T) {
{
name: "Test With Timeout",
opts: []GenericOption{
WithTimeout(time.Duration(5 * time.Second)),
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, 5*time.Second, c.Traces.Timeout)

View File

@ -372,7 +372,7 @@ func TestConfigs(t *testing.T) {
{
name: "Test With Timeout",
opts: []GenericOption{
WithTimeout(time.Duration(5 * time.Second)),
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, 5*time.Second, c.Traces.Timeout)

View File

@ -376,7 +376,7 @@ func TestConfigs(t *testing.T) {
{
name: "Test With Timeout",
opts: []GenericOption{
WithTimeout(time.Duration(5 * time.Second)),
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)

View File

@ -79,7 +79,7 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
out := &mpb.Metric{
Name: m.Name,
Description: m.Description,
Unit: string(m.Unit),
Unit: m.Unit,
}
switch a := m.Data.(type) {
case metricdata.Gauge[int64]:

View File

@ -372,7 +372,7 @@ func TestConfigs(t *testing.T) {
{
name: "Test With Timeout",
opts: []GenericOption{
WithTimeout(time.Duration(5 * time.Second)),
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, 5*time.Second, c.Traces.Timeout)

View File

@ -50,8 +50,8 @@ func ReservoirTest[N int64 | float64](f factory) func(*testing.T) {
want := Exemplar{
Time: staticTime,
Value: NewValue(N(10)),
SpanID: []byte(sID[:]),
TraceID: []byte(tID[:]),
SpanID: sID[:],
TraceID: tID[:],
}
require.Len(t, dest, 1, "number of collected exemplars")
assert.Equal(t, want, dest[0])

View File

@ -61,7 +61,7 @@ func (c *NetConv) Host(address string) []attribute.KeyValue {
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.HostName(h))
if p > 0 {
attrs = append(attrs, c.HostPort(int(p)))
attrs = append(attrs, c.HostPort(p))
}
return attrs
}
@ -252,7 +252,7 @@ func (c *NetConv) Peer(address string) []attribute.KeyValue {
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.PeerName(h))
if p > 0 {
attrs = append(attrs, c.PeerPort(int(p)))
attrs = append(attrs, c.PeerPort(p))
}
return attrs
}

View File

@ -61,7 +61,7 @@ func (c *NetConv) Host(address string) []attribute.KeyValue {
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.HostName(h))
if p > 0 {
attrs = append(attrs, c.HostPort(int(p)))
attrs = append(attrs, c.HostPort(p))
}
return attrs
}
@ -252,7 +252,7 @@ func (c *NetConv) Peer(address string) []attribute.KeyValue {
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.PeerName(h))
if p > 0 {
attrs = append(attrs, c.PeerPort(int(p)))
attrs = append(attrs, c.PeerPort(p))
}
return attrs
}

View File

@ -61,7 +61,7 @@ func (c *NetConv) Host(address string) []attribute.KeyValue {
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.HostName(h))
if p > 0 {
attrs = append(attrs, c.HostPort(int(p)))
attrs = append(attrs, c.HostPort(p))
}
return attrs
}
@ -252,7 +252,7 @@ func (c *NetConv) Peer(address string) []attribute.KeyValue {
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.PeerName(h))
if p > 0 {
attrs = append(attrs, c.PeerPort(int(p)))
attrs = append(attrs, c.PeerPort(p))
}
return attrs
}