1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00

chore: enable gocritic linter (#7095)

#### Description

Enable and fixes several rules from
[gocritic](https://golangci-lint.run/usage/linters/#gocritic) linter

---------

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
Matthieu MOREL
2025-07-29 18:20:32 +02:00
committed by GitHub
parent 8955578fef
commit 982391315f
37 changed files with 158 additions and 146 deletions
+1 -1
View File
@@ -1008,7 +1008,7 @@ func kvStr(kvs []attribute.KeyValue) string {
if idx > 0 {
_, _ = sb.WriteString(", ")
}
_, _ = sb.WriteString((string)(attr.Key))
_, _ = sb.WriteString(string(attr.Key))
_, _ = sb.WriteString(": ")
_, _ = sb.WriteString(attr.Value.Emit())
}
+13 -9
View File
@@ -91,8 +91,7 @@ func (c *HTTPConv) ClientRequest(req *http.Request) []attribute.KeyValue {
}
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.method(req.Method))
attrs = append(attrs, c.proto(req.Proto))
attrs = append(attrs, c.method(req.Method), c.proto(req.Proto))
var u string
if req.URL != nil {
@@ -103,9 +102,11 @@ func (c *HTTPConv) ClientRequest(req *http.Request) []attribute.KeyValue {
// Restore any username/password info that was removed.
req.URL.User = userinfo
}
attrs = append(attrs, c.HTTPURLKey.String(u))
attrs = append(attrs, c.NetConv.PeerName(peer))
attrs = append(
attrs,
c.HTTPURLKey.String(u),
c.NetConv.PeerName(peer),
)
if port > 0 {
attrs = append(attrs, c.NetConv.PeerPort(port))
}
@@ -191,10 +192,13 @@ func (c *HTTPConv) ServerRequest(server string, req *http.Request) []attribute.K
}
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.method(req.Method))
attrs = append(attrs, c.scheme(req.TLS != nil))
attrs = append(attrs, c.proto(req.Proto))
attrs = append(attrs, c.NetConv.HostName(host))
attrs = append(
attrs,
c.method(req.Method),
c.scheme(req.TLS != nil),
c.proto(req.Proto),
c.NetConv.HostName(host),
)
if hostPort > 0 {
attrs = append(attrs, c.NetConv.HostPort(hostPort))
+13 -9
View File
@@ -91,8 +91,7 @@ func (c *HTTPConv) ClientRequest(req *http.Request) []attribute.KeyValue {
}
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.method(req.Method))
attrs = append(attrs, c.proto(req.Proto))
attrs = append(attrs, c.method(req.Method), c.proto(req.Proto))
var u string
if req.URL != nil {
@@ -103,9 +102,11 @@ func (c *HTTPConv) ClientRequest(req *http.Request) []attribute.KeyValue {
// Restore any username/password info that was removed.
req.URL.User = userinfo
}
attrs = append(attrs, c.HTTPURLKey.String(u))
attrs = append(attrs, c.NetConv.PeerName(peer))
attrs = append(
attrs,
c.HTTPURLKey.String(u),
c.NetConv.PeerName(peer),
)
if port > 0 {
attrs = append(attrs, c.NetConv.PeerPort(port))
}
@@ -191,10 +192,13 @@ func (c *HTTPConv) ServerRequest(server string, req *http.Request) []attribute.K
}
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.method(req.Method))
attrs = append(attrs, c.scheme(req.TLS != nil))
attrs = append(attrs, c.proto(req.Proto))
attrs = append(attrs, c.NetConv.HostName(host))
attrs = append(
attrs,
c.method(req.Method),
c.scheme(req.TLS != nil),
c.proto(req.Proto),
c.NetConv.HostName(host),
)
if hostPort > 0 {
attrs = append(attrs, c.NetConv.HostPort(hostPort))
+13 -9
View File
@@ -92,8 +92,7 @@ func (c *HTTPConv) ClientRequest(req *http.Request) []attribute.KeyValue {
}
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.method(req.Method))
attrs = append(attrs, c.proto(req.Proto))
attrs = append(attrs, c.method(req.Method), c.proto(req.Proto))
var u string
if req.URL != nil {
@@ -104,9 +103,11 @@ func (c *HTTPConv) ClientRequest(req *http.Request) []attribute.KeyValue {
// Restore any username/password info that was removed.
req.URL.User = userinfo
}
attrs = append(attrs, c.HTTPURLKey.String(u))
attrs = append(attrs, c.NetConv.PeerName(peer))
attrs = append(
attrs,
c.HTTPURLKey.String(u),
c.NetConv.PeerName(peer),
)
if port > 0 {
attrs = append(attrs, c.NetConv.PeerPort(port))
}
@@ -192,10 +193,13 @@ func (c *HTTPConv) ServerRequest(server string, req *http.Request) []attribute.K
}
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.method(req.Method))
attrs = append(attrs, c.scheme(req.TLS != nil))
attrs = append(attrs, c.proto(req.Proto))
attrs = append(attrs, c.NetConv.HostName(host))
attrs = append(
attrs,
c.method(req.Method),
c.scheme(req.TLS != nil),
c.proto(req.Proto),
c.NetConv.HostName(host),
)
if hostPort > 0 {
attrs = append(attrs, c.NetConv.HostPort(hostPort))