Skip to content

Commit 022a5ea

Browse files
authored
chore: enable more rules from go-critic (#7434)
## Description of the changes - Enable more rules from go-critic ## How was this change tested? - ## Checklist - [ ] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [ ] I have signed all commits - [ ] I have added unit tests for the new functionality - [ ] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `npm run lint` and `npm run test` --------- Signed-off-by: Matthieu MOREL <[email protected]>
1 parent a5de984 commit 022a5ea

File tree

41 files changed

+170
-158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+170
-158
lines changed

.golangci.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,13 @@ linters:
7171
- deferInLoop
7272
- dupArg
7373
- exitAfterDefer
74-
- exposedSyncMutex
7574
- hugeParam
7675
- importShadow
77-
- nestingReduce
78-
- paramTypeCombine
76+
- paramTypeCombine # WON'T FIX
7977
- rangeValCopy
80-
- regexpSimplify
8178
- returnAfterHttpError
8279
- todoCommentWithoutDetail
83-
- typeAssertChain
8480
- unnamedResult
85-
- whyNoLint
8681
enable-all: true
8782
gosec:
8883
excludes:

cmd/collector/app/collector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (c *Collector) Start(options *flags.CollectorOptions) error {
149149

150150
func (*Collector) publishOpts(cOpts *flags.CollectorOptions) {
151151
safeexpvar.SetInt(metricNumWorkers, int64(cOpts.NumWorkers))
152-
//nolint: gosec // G115
152+
//nolint:gosec // G115
153153
safeexpvar.SetInt(metricQueueSize, int64(cOpts.QueueSize))
154154
}
155155

cmd/collector/app/queue/bounded_queue.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func NewBoundedQueue[T any](capacity int, onDroppedItem func(item T)) *BoundedQu
4343
stopCh: make(chan struct{}),
4444
}
4545
bq.items.Store(&queue)
46-
//nolint: gosec // G115
46+
//nolint:gosec // G115
4747
bq.capacity.Store(uint32(capacity))
4848
return bq
4949
}
@@ -187,7 +187,7 @@ func (q *BoundedQueue[T]) Resize(capacity int) bool {
187187
close(*previous)
188188

189189
// update the capacity
190-
//nolint: gosec // G115
190+
//nolint:gosec // G115
191191
q.capacity.Store(uint32(capacity))
192192
}
193193

cmd/collector/app/span_handler_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (b *SpanHandlerBuilder) BuildSpanProcessor(additional ...ProcessSpan) (proc
4949
Options.Logger(b.logger()),
5050
Options.SpanFilter(defaultSpanFilter),
5151
Options.NumWorkers(b.CollectorOpts.NumWorkers),
52-
//nolint: gosec // G115
52+
//nolint:gosec // G115
5353
Options.QueueSize(int(b.CollectorOpts.QueueSize)),
5454
Options.CollectorTags(b.CollectorOpts.CollectorTags),
5555
Options.DynQueueSizeWarmup(b.CollectorOpts.QueueSize), // same as queue size for now

cmd/collector/app/span_processor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func (sp *spanProcessor) writeSpan(ctx context.Context, span *model.Span) error
232232
}
233233

234234
func (sp *spanProcessor) countSpansInQueue(span *model.Span, _ string /* tenant */) {
235-
//nolint: gosec // G115
235+
//nolint:gosec // G115
236236
sp.bytesProcessed.Add(uint64(span.Size()))
237237
sp.spansProcessed.Add(1)
238238
}
@@ -394,7 +394,7 @@ func (sp *spanProcessor) updateQueueSize() {
394394
}
395395

396396
func (sp *spanProcessor) updateGauges() {
397-
//nolint: gosec // G115
397+
//nolint:gosec // G115
398398
sp.metrics.SpansBytes.Update(int64(sp.bytesProcessed.Load()))
399399
sp.metrics.QueueLength.Update(int64(sp.queue.Size()))
400400
sp.metrics.QueueCapacity.Update(int64(sp.queue.Capacity()))

cmd/jaeger/internal/extension/remotesampling/extension.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ func (ext *rsExtension) startFileBasedStrategyProvider(_ context.Context) error
169169
DefaultSamplingProbability: ext.cfg.File.DefaultSamplingProbability,
170170
}
171171

172-
// contextcheck linter complains about next line that context is not passed.
173-
//nolint:contextcheck
172+
//nolint:contextcheck // contextcheck linter complains about next line that context is not passed.
174173
provider, err := file.NewProvider(opts, ext.telemetry.Logger)
175174
if err != nil {
176175
return fmt.Errorf("failed to create the local file strategy store: %w", err)

cmd/jaeger/internal/integration/trace_reader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (r *traceReader) FindTraces(
126126
StartTimeMax: query.StartTimeMax,
127127
DurationMin: query.DurationMin,
128128
DurationMax: query.DurationMax,
129-
//nolint: gosec // G115
129+
//nolint:gosec // G115
130130
SearchDepth: int32(query.SearchDepth),
131131
RawTraces: true,
132132
},

cmd/query/app/apiv3/http_gateway.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (h *HTTPGateway) tryHandleError(w http.ResponseWriter, err error, statusCod
9595
}
9696
errorResponse := api_v3.GRPCGatewayError{
9797
Error: &api_v3.GRPCGatewayError_GRPCGatewayErrorDetails{
98-
//nolint: gosec // G115
98+
//nolint:gosec // G115
9999
HttpCode: int32(statusCode),
100100
Message: err.Error(),
101101
},

cmd/query/app/querysvc/internal/adjuster/clockskew.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func hostKey(span *model.Span) string {
7474
if tag.VType == model.Int64Type {
7575
var buf [4]byte // avoid heap allocation
7676
ip := buf[0:4] // utils require a slice, not an array
77-
//nolint: gosec // G115
77+
//nolint:gosec // G115
7878
binary.BigEndian.PutUint32(ip, uint32(tag.Int64()))
7979
return net.IP(ip).String()
8080
}

cmd/query/app/querysvc/internal/adjuster/ip_tag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func IPTagAdjuster() Adjuster {
2626
var value uint32
2727
switch tag.VType {
2828
case model.Int64Type:
29-
//nolint: gosec // G115
29+
//nolint:gosec // G115
3030
value = uint32(tag.Int64())
3131
case model.Float64Type:
3232
value = uint32(tag.Float64())

0 commit comments

Comments
 (0)