Skip to content

Commit

Permalink
Enable Lint Rules: bare-return & empty-lines (#5512)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
-  Partial Fix for #5506

## Description of the changes
- Enabled bare-return in revive linter. 
- Removed naked returns.
- Enabled empty-lines in revive linter.

## How was this change tested?
- `make lint` `make test`

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: FlamingSaint <[email protected]>
  • Loading branch information
FlamingSaint authored Jun 3, 2024
1 parent c428138 commit bd33dc2
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 23 deletions.
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
}

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
}
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 @@ func (x *scramClient) Begin(userName, password, authzID string) (err error) {

// 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)
}

// Done should return true when the SCRAM conversation
Expand Down Expand Up @@ -84,7 +83,6 @@ func setPlainTextConfiguration(config *PlainTextConfig, saramaConfig *sarama.Con

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

0 comments on commit bd33dc2

Please sign in to comment.