diff --git a/.golangci.yml b/.golangci.yml index f2cf97e2725..dba726230dd 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,6 +24,7 @@ linters: - staticcheck - typecheck - unconvert + - unparam - unused issues: diff --git a/detectors/gcp/cloud-function.go b/detectors/gcp/cloud-function.go index 113aa277347..debdc2484c1 100644 --- a/detectors/gcp/cloud-function.go +++ b/detectors/gcp/cloud-function.go @@ -41,7 +41,7 @@ func (f *cloudFunction) Detect(ctx context.Context) (*resource.Resource, error) if err != nil { return nil, err } - region, err := f.cloudRun.cloudRegion(ctx) + region, err := f.cloudRun.cloudRegion() if err != nil { return nil, err } diff --git a/detectors/gcp/cloud-run.go b/detectors/gcp/cloud-run.go index 11c1d8823da..2168f4854bc 100644 --- a/detectors/gcp/cloud-run.go +++ b/detectors/gcp/cloud-run.go @@ -50,7 +50,7 @@ func NewCloudRun() *CloudRun { } } -func (c *CloudRun) cloudRegion(ctx context.Context) (string, error) { +func (c *CloudRun) cloudRegion() (string, error) { region, err := c.mc.Get("instance/region") if err != nil { return "", err @@ -84,7 +84,7 @@ func (c *CloudRun) Detect(ctx context.Context) (*resource.Resource, error) { attributes = append(attributes, semconv.CloudAccountID(projectID)) } - if region, err := c.cloudRegion(ctx); hasProblem(err) { + if region, err := c.cloudRegion(); hasProblem(err) { errInfo = append(errInfo, err.Error()) } else if region != "" { attributes = append(attributes, semconv.CloudRegion(region)) diff --git a/instrgen/lib/context_propagation.go b/instrgen/lib/context_propagation.go index b4d70294e88..de4f5907be1 100644 --- a/instrgen/lib/context_propagation.go +++ b/instrgen/lib/context_propagation.go @@ -41,7 +41,7 @@ func (pass *ContextPropagationPass) Execute( // when callexpr is inside var decl // instead of functiondecl currentFun := FuncDescriptor{} - emitEmptyContext := func(callExpr *ast.CallExpr, fun FuncDescriptor, ctxArg *ast.Ident) { + emitEmptyContext := func(callExpr *ast.CallExpr, ctxArg *ast.Ident) { addImports = true if currentFun != (FuncDescriptor{}) { visited := map[FuncDescriptor]bool{} @@ -96,7 +96,7 @@ func (pass *ContextPropagationPass) Execute( visited := map[FuncDescriptor]bool{} if isPath(analysis.Callgraph, fun, analysis.RootFunctions[0], visited) { fmt.Println("\t\t\tContextPropagation FuncCall:", funId, pkg.TypesInfo.Uses[ident].Type().String()) - emitEmptyContext(callExpr, fun, ctxArg) + emitEmptyContext(callExpr, ctxArg) } } } diff --git a/instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go b/instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go index 13e900b5ca1..15e4b340567 100644 --- a/instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go +++ b/instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go @@ -138,7 +138,7 @@ func TestNotFoundIsNotError(t *testing.T) { func assertSpan(t *testing.T, span sdktrace.ReadOnlySpan, name string, kind trace.SpanKind, attrs ...attribute.KeyValue) { assert.Equal(t, name, span.Name()) - assert.Equal(t, trace.SpanKindServer, span.SpanKind()) + assert.Equal(t, kind, span.SpanKind()) got := make(map[attribute.Key]attribute.Value, len(span.Attributes())) for _, a := range span.Attributes() { diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/test/grpc_test.go b/instrumentation/google.golang.org/grpc/otelgrpc/test/grpc_test.go index 991fad2efd6..42f4e368deb 100644 --- a/instrumentation/google.golang.org/grpc/otelgrpc/test/grpc_test.go +++ b/instrumentation/google.golang.org/grpc/otelgrpc/test/grpc_test.go @@ -635,7 +635,7 @@ func checkUnaryServerSpans(t *testing.T, spans []trace.ReadOnlySpan) { }, largeSpan.Attributes()) } -func assertEvents(t *testing.T, expected, actual []trace.Event) bool { +func assertEvents(t *testing.T, expected, actual []trace.Event) bool { //nolint:unparam if !assert.Len(t, actual, len(expected)) { return false } @@ -694,7 +694,7 @@ func checkUnaryServerRecords(t *testing.T, reader metric.Reader) { metricdatatest.AssertEqual(t, want, rm.ScopeMetrics[0], metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue()) } -func findAttribute(kvs []attribute.KeyValue, key attribute.Key) (attribute.KeyValue, bool) { +func findAttribute(kvs []attribute.KeyValue, key attribute.Key) (attribute.KeyValue, bool) { //nolint:unparam for _, kv := range kvs { if kv.Key == key { return kv, true diff --git a/instrumentation/runtime/internal/x/x_test.go b/instrumentation/runtime/internal/x/x_test.go index 86db0d845f0..fac942514ff 100644 --- a/instrumentation/runtime/internal/x/x_test.go +++ b/instrumentation/runtime/internal/x/x_test.go @@ -33,7 +33,7 @@ func run(steps ...func(*testing.T)) func(*testing.T) { } } -func setenv(k, v string) func(t *testing.T) { +func setenv(k, v string) func(t *testing.T) { //nolint:unparam return func(t *testing.T) { t.Setenv(k, v) } } diff --git a/samplers/aws/xray/fallback_sampler.go b/samplers/aws/xray/fallback_sampler.go index 728cadc5938..2b23704aac8 100644 --- a/samplers/aws/xray/fallback_sampler.go +++ b/samplers/aws/xray/fallback_sampler.go @@ -50,7 +50,7 @@ func (fs *FallbackSampler) Description() string { } // take consumes quota from reservoir, if any remains, then returns true. False otherwise. -func (fs *FallbackSampler) take(now time.Time, itemCost float64) bool { +func (fs *FallbackSampler) take(now time.Time, itemCost float64) bool { //nolint:unparam fs.mu.Lock() defer fs.mu.Unlock() diff --git a/samplers/aws/xray/internal/client.go b/samplers/aws/xray/internal/client.go index eb65391af60..4efa16b39a1 100644 --- a/samplers/aws/xray/internal/client.go +++ b/samplers/aws/xray/internal/client.go @@ -107,7 +107,7 @@ type xrayClient struct { } // newClient returns an HTTP client with proxy endpoint. -func newClient(endpoint url.URL) (client *xrayClient, err error) { +func newClient(endpoint url.URL) (client *xrayClient, err error) { //nolint:unparam // Construct resolved URLs for getSamplingRules and getSamplingTargets API calls. endpoint.Path = "/GetSamplingRules" samplingRulesURL := endpoint diff --git a/samplers/aws/xray/internal/manifest.go b/samplers/aws/xray/internal/manifest.go index 2d4d7dfa1a2..78b5f20588a 100644 --- a/samplers/aws/xray/internal/manifest.go +++ b/samplers/aws/xray/internal/manifest.go @@ -289,7 +289,7 @@ func (m *Manifest) updateReservoir(t *samplingTargetDocument) (err error) { // snapshots takes a snapshot of sampling statistics from all rules, resetting // statistics counters in the process. -func (m *Manifest) snapshots() ([]*samplingStatisticsDocument, error) { +func (m *Manifest) snapshots() ([]*samplingStatisticsDocument, error) { //nolint:unparam statistics := make([]*samplingStatisticsDocument, 0, len(m.Rules)) // Generate sampling statistics for user-defined rules. diff --git a/samplers/aws/xray/internal/manifest_test.go b/samplers/aws/xray/internal/manifest_test.go index e6c9654d2f4..4bb6706938d 100644 --- a/samplers/aws/xray/internal/manifest_test.go +++ b/samplers/aws/xray/internal/manifest_test.go @@ -20,7 +20,7 @@ import ( "github.com/stretchr/testify/assert" ) -func createSamplingTargetDocument(name string, interval int64, rate, quota, ttl float64) *samplingTargetDocument { +func createSamplingTargetDocument(name string, interval int64, rate, quota, ttl float64) *samplingTargetDocument { //nolint:unparam return &samplingTargetDocument{ FixedRate: &rate, Interval: &interval, diff --git a/samplers/aws/xray/internal/reservoir.go b/samplers/aws/xray/internal/reservoir.go index 3b41e2a1dcf..62412f6e51d 100644 --- a/samplers/aws/xray/internal/reservoir.go +++ b/samplers/aws/xray/internal/reservoir.go @@ -44,7 +44,7 @@ func (r *reservoir) expired(now time.Time) bool { } // take consumes quota from reservoir, if any remains, then returns true. False otherwise. -func (r *reservoir) take(now time.Time, borrowed bool, itemCost float64) bool { // nolint: revive // borrowed is not a control flag. +func (r *reservoir) take(now time.Time, borrowed bool, itemCost float64) bool { // nolint:unparam,revive // borrowed is not a control flag. r.mu.Lock() defer r.mu.Unlock()