Skip to content

Commit

Permalink
Add unconvert linter (open-telemetry#5802)
Browse files Browse the repository at this point in the history
This is the contrib counterpart of
open-telemetry/opentelemetry-go#5529.

Co-authored-by: Robert Pająk <pellared@hotmail.com>
  • Loading branch information
dmathieu and pellared committed Jun 26, 2024
1 parent ff65757 commit 114000d
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 22 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ linters:
- revive
- staticcheck
- typecheck
- unconvert
- unused

issues:
Expand Down
6 changes: 3 additions & 3 deletions bridges/otelzap/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestCore(t *testing.T) {
assert.Equal(t, zap.InfoLevel.String(), got.SeverityText())
assert.Equal(t, 1, got.AttributesLen())
got.WalkAttributes(func(kv log.KeyValue) bool {
assert.Equal(t, testKey, string(kv.Key))
assert.Equal(t, testKey, kv.Key)
assert.Equal(t, testValue, value2Result(kv.Value))
return true
})
Expand All @@ -68,7 +68,7 @@ func TestCore(t *testing.T) {

index := 0
got.WalkAttributes(func(kv log.KeyValue) bool {
assert.Equal(t, testCases[index][0], string(kv.Key))
assert.Equal(t, testCases[index][0], kv.Key)
assert.Equal(t, testCases[index][1], value2Result(kv.Value))
index++
return true
Expand All @@ -91,7 +91,7 @@ func TestCore(t *testing.T) {

index := 0
got.WalkAttributes(func(kv log.KeyValue) bool {
assert.Equal(t, testCases[index][0], string(kv.Key))
assert.Equal(t, testCases[index][0], kv.Key)
assert.Equal(t, testCases[index][1], value2Result(kv.Value))
index++
return true
Expand Down
2 changes: 1 addition & 1 deletion bridges/otelzap/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (a *arrayEncoder) AppendDuration(v time.Duration) { a.AppendInt64(v.Nanosec
func (a *arrayEncoder) AppendInt32(v int32) { a.AppendInt64(int64(v)) }
func (a *arrayEncoder) AppendInt16(v int16) { a.AppendInt64(int64(v)) }
func (a *arrayEncoder) AppendInt8(v int8) { a.AppendInt64(int64(v)) }
func (a *arrayEncoder) AppendTime(v time.Time) { a.AppendInt64(int64(v.UnixNano())) }
func (a *arrayEncoder) AppendTime(v time.Time) { a.AppendInt64(v.UnixNano()) }
func (a *arrayEncoder) AppendUint(v uint) { a.AppendUint64(uint64(v)) }
func (a *arrayEncoder) AppendUint32(v uint32) { a.AppendInt64(int64(v)) }
func (a *arrayEncoder) AppendUint16(v uint16) { a.AppendInt64(int64(v)) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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
}
Expand Down Expand Up @@ -138,7 +138,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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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
}
Expand Down Expand Up @@ -138,7 +138,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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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
}
Expand Down Expand Up @@ -138,7 +138,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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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
}
Expand Down Expand Up @@ -138,7 +138,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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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
}
Expand Down Expand Up @@ -138,7 +138,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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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
}
Expand Down Expand Up @@ -138,7 +138,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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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
}
Expand Down Expand Up @@ -138,7 +138,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
}
Expand Down
4 changes: 2 additions & 2 deletions internal/shared/semconvutil/netconv.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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
}
Expand Down Expand Up @@ -138,7 +138,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
}
Expand Down
4 changes: 2 additions & 2 deletions propagators/b3/b3_propagator.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ func extractSingle(ctx context.Context, contextHeader string) (context.Context,
case string(contextHeader[traceID64BitsWidth]) == "-":
// traceID must be 64 bits
pos += traceID64BitsWidth // {traceID}
traceID = b3TraceIDPadding + string(contextHeader[0:pos])
traceID = b3TraceIDPadding + contextHeader[0:pos]
case string(contextHeader[32]) == "-":
// traceID must be 128 bits
pos += traceID128BitsWidth // {traceID}
traceID = string(contextHeader[0:pos])
traceID = contextHeader[0:pos]
default:
return ctx, empty, errInvalidTraceIDValue
}
Expand Down

0 comments on commit 114000d

Please sign in to comment.