Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Lint Rules: bare-return & empty-lines #5512

Merged
merged 5 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,6 @@ linters-settings:
# enable after cleanup
- name: early-return
disabled: true
# enable after cleanup
- name: bare-return
disabled: true
# enable after cleanup
- name: empty-lines
disabled: true
# investigate, could be real bugs. But didn't recent Go version changed loop variables semantics?
- name: range-val-address
disabled: true
Expand Down
1 change: 0 additions & 1 deletion cmd/collector/app/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ func (c *Collector) Start(options *flags.CollectorOptions) error {
return fmt.Errorf("could not start Zipkin receiver: %w", err)
}
c.zipkinReceiver = zipkinReceiver

}

if options.OTLP.Enabled {
Expand Down
1 change: 0 additions & 1 deletion cmd/query/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ func createHTTPServer(
return nil, err
}
server.TLSConfig = tlsCfg

}

server.staticHandlerCloser = RegisterStaticHandler(r, logger, queryOpts, querySvc.GetCapabilities())
Expand Down
2 changes: 0 additions & 2 deletions cmd/query/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,7 @@ func TestServerHTTPTLS(t *testing.T) {
if conn != nil {
clientClose = conn.Close
}

} else {

conn, err1 := net.DialTimeout("tcp", "localhost:"+fmt.Sprintf("%d", ports.QueryHTTP), 2*time.Second)
clientError = err1
clientClose = nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/fswatcher/fswatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func createTestFiles(t *testing.T) (file1 string, file2 string, file3 string) {
err = os.WriteFile(file3, []byte("test data"), 0o600)
require.NoError(t, err)

return
return file1, file2, file3
}

func TestFSWatcherAddFiles(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/gzipfs/gzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ func (f file) Stat() (fs.FileInfo, error) {
}, nil
}

func (f *file) Read(buf []byte) (n int, err error) {
func (f *file) Read(buf []byte) (int, error) {
if len(buf) > len(f.content)-f.offset {
buf = buf[0:len(f.content[f.offset:])]
}

n = copy(buf, f.content[f.offset:])
n := copy(buf, f.content[f.offset:])
if n == len(f.content)-f.offset {
return n, io.EOF
}
f.offset += n
return
return n, nil
FlamingSaint marked this conversation as resolved.
Show resolved Hide resolved
}

func (f file) Close() error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/httpmetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,5 @@ func (r *requestDurations) buildTimer(metricsFactory metrics.Factory, key record
"method": key.method,
},
})
return
return out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the name "out" from the signature

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defer function on top requires the named output as its assigning a value to it

}
6 changes: 2 additions & 4 deletions pkg/kafka/auth/plaintext.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@

// Step steps client through the SCRAM exchange. It is
// called repeatedly until it errors or `Done` returns true.
func (x *scramClient) Step(challenge string) (response string, err error) {
response, err = x.ClientConversation.Step(challenge)
return
func (x *scramClient) Step(challenge string) (string, error) {
return x.ClientConversation.Step(challenge)

Check warning on line 46 in pkg/kafka/auth/plaintext.go

View check run for this annotation

Codecov / codecov/patch

pkg/kafka/auth/plaintext.go#L45-L46

Added lines #L45 - L46 were not covered by tests
}

// Done should return true when the SCRAM conversation
Expand Down Expand Up @@ -84,7 +83,6 @@

default:
return fmt.Errorf("config plaintext.mechanism error: %s, only support 'SCRAM-SHA-256' or 'SCRAM-SHA-512' or 'PLAIN'", config.Mechanism)

}
return nil
}
1 change: 0 additions & 1 deletion plugin/sampling/strategystore/static/strategy_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ func (h *strategyStore) parseStrategies(strategies *strategies) {

opS := newStore.serviceStrategies[s.Service].OperationSampling
if opS == nil {

// Service does not have its own per-operation rules, so copy (by value) from the default strategy.
newOpS := *newStore.defaultStrategy.OperationSampling

Expand Down
1 change: 0 additions & 1 deletion plugin/storage/badger/spanstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ func serviceQueries(query *spanstore.TraceQueryParameters, indexSeeks [][]byte)
} else if !tagQueryUsed { // Tag query already reduces the search set with a serviceName
indexSearchKey = append(indexSearchKey, serviceNameIndexKey)
indexSearchKey = append(indexSearchKey, []byte(query.ServiceName)...)

}

if len(indexSearchKey) > 0 {
Expand Down
1 change: 0 additions & 1 deletion plugin/storage/cassandra/spanstore/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ func TestSpanReaderFindTraces(t *testing.T) {
if testCase.queryDuration {
queryParams.DurationMin = time.Minute
queryParams.DurationMax = time.Minute * 3

}
res, err := r.reader.FindTraces(context.Background(), queryParams)
if testCase.expectedError == "" {
Expand Down
1 change: 0 additions & 1 deletion plugin/storage/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ func (st *Store) WriteSpan(ctx context.Context, span *model.Span) error {
// update the ring with the trace id
m.ids[m.index] = &span.TraceID
}

}
m.traces[span.TraceID].Spans = append(m.traces[span.TraceID].Spans, span)

Expand Down
Loading