Skip to content

Commit 35b5892

Browse files
committed
chore(lint): relinted
Signed-off-by: Frederic BIDON <[email protected]>
1 parent e6a1173 commit 35b5892

File tree

13 files changed

+49
-43
lines changed

13 files changed

+49
-43
lines changed

client/opentelemetry_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ func Test_OpenTelemetryRuntime_submit(t *testing.T) {
3030
otel.SetTracerProvider(tp)
3131

3232
tracer := tp.Tracer("go-runtime")
33-
ctx, _ := tracer.Start(context.Background(), "op")
33+
ctx, span := tracer.Start(context.Background(), "op")
34+
defer span.End()
3435

3536
assertOpenTelemetrySubmit(t, testOperation(ctx), exporter, 1)
3637
}
@@ -48,7 +49,8 @@ func Test_OpenTelemetryRuntime_submit_nilAuthInfo(t *testing.T) {
4849
otel.SetTracerProvider(tp)
4950

5051
tracer := tp.Tracer("go-runtime")
51-
ctx, _ := tracer.Start(context.Background(), "op")
52+
ctx, span := tracer.Start(context.Background(), "op")
53+
defer span.End()
5254

5355
operation := testOperation(ctx)
5456
operation.AuthInfo = nil
@@ -66,7 +68,8 @@ func Test_OpenTelemetryRuntime_submit_nilContext(t *testing.T) {
6668
otel.SetTracerProvider(tp)
6769

6870
tracer := tp.Tracer("go-runtime")
69-
ctx, _ := tracer.Start(context.Background(), "op")
71+
ctx, span := tracer.Start(context.Background(), "op")
72+
defer span.End()
7073
operation := testOperation(ctx)
7174
operation.Context = nil
7275

@@ -86,7 +89,8 @@ func Test_injectOpenTelemetrySpanContext(t *testing.T) {
8689
otel.SetTracerProvider(tp)
8790

8891
tracer := tp.Tracer("go-runtime")
89-
ctx, _ := tracer.Start(context.Background(), "op")
92+
ctx, span := tracer.Start(context.Background(), "op")
93+
defer span.End()
9094
operation := testOperation(ctx)
9195

9296
header := map[string][]string{}

client/opentracing_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func testOperation(ctx context.Context) *runtime.ClientOperation {
5656
Reader: runtime.ClientResponseReaderFunc(func(runtime.ClientResponse, runtime.Consumer) (interface{}, error) {
5757
return nil, nil
5858
}),
59-
Params: runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, reg strfmt.Registry) error {
59+
Params: runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
6060
return nil
6161
}),
6262
AuthInfo: PassThroughAuth,

client/request_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ func TestBuildRequest_BuildHTTP_Files(t *testing.T) {
428428
emptyFile, err := os.CreateTemp("", "empty")
429429
require.NoError(t, err)
430430

431-
reqWrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, reg strfmt.Registry) error {
431+
reqWrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
432432
_ = req.SetFormParam("something", "some value")
433433
_ = req.SetFileParam("file", mustGetFile("./runtime.go"))
434434
_ = req.SetFileParam("otherfiles", mustGetFile("./runtime.go"), mustGetFile("./request.go"))
@@ -736,7 +736,7 @@ func TestGetBodyCallsBeforeRoundTrip(t *testing.T) {
736736
bodyContent, e := io.ReadAll(io.Reader(body))
737737
require.NoError(t, e)
738738

739-
require.EqualValues(t, req.ContentLength, len(bodyContent))
739+
require.Len(t, bodyContent, int(req.ContentLength))
740740
require.EqualValues(t, "\"test body\"\n", string(bodyContent))
741741

742742
// Read the body a second time before sending the request

client/runtime.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"crypto/tls"
2323
"crypto/x509"
2424
"encoding/pem"
25+
"errors"
2526
"fmt"
2627
"mime"
2728
"net/http"
@@ -142,7 +143,7 @@ func TLSClientAuth(opts TLSClientOptions) (*tls.Config, error) {
142143
return nil, fmt.Errorf("tls client priv key: %v", err)
143144
}
144145
default:
145-
return nil, fmt.Errorf("tls client priv key: unsupported key type")
146+
return nil, errors.New("tls client priv key: unsupported key type")
146147
}
147148

148149
block = pem.Block{Type: "PRIVATE KEY", Bytes: keyBytes}

client/runtime_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func TestRuntime_Concurrent(t *testing.T) {
7373
}))
7474
defer server.Close()
7575

76-
rwrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
76+
rwrtr := runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
7777
return nil
7878
})
7979

@@ -149,7 +149,7 @@ func TestRuntime_Canary(t *testing.T) {
149149
}))
150150
defer server.Close()
151151

152-
rwrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
152+
rwrtr := runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
153153
return nil
154154
})
155155

@@ -200,7 +200,7 @@ func TestRuntime_XMLCanary(t *testing.T) {
200200
}))
201201
defer server.Close()
202202

203-
rwrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
203+
rwrtr := runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
204204
return nil
205205
})
206206

@@ -242,7 +242,7 @@ func TestRuntime_TextCanary(t *testing.T) {
242242
}))
243243
defer server.Close()
244244

245-
rwrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
245+
rwrtr := runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
246246
return nil
247247
})
248248

@@ -287,7 +287,7 @@ func TestRuntime_CSVCanary(t *testing.T) {
287287
}))
288288
defer server.Close()
289289

290-
rwrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
290+
rwrtr := runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
291291
return nil
292292
})
293293

@@ -325,7 +325,7 @@ func (fn roundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error)
325325
}
326326

327327
func TestRuntime_CustomTransport(t *testing.T) {
328-
rwrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
328+
rwrtr := runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
329329
return nil
330330
})
331331
result := []task{
@@ -402,7 +402,7 @@ func TestRuntime_CustomCookieJar(t *testing.T) {
402402
}))
403403
defer server.Close()
404404

405-
rwrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
405+
rwrtr := runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
406406
return nil
407407
})
408408

@@ -457,7 +457,7 @@ func TestRuntime_AuthCanary(t *testing.T) {
457457
}))
458458
defer server.Close()
459459

460-
rwrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
460+
rwrtr := runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
461461
return nil
462462
})
463463

@@ -559,7 +559,7 @@ func TestRuntime_ContentTypeCanary(t *testing.T) {
559559
}))
560560
defer server.Close()
561561

562-
rwrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
562+
rwrtr := runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
563563
return nil
564564
})
565565

@@ -613,7 +613,7 @@ func TestRuntime_ChunkedResponse(t *testing.T) {
613613
}))
614614
defer server.Close()
615615

616-
rwrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
616+
rwrtr := runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
617617
return nil
618618
})
619619

@@ -728,7 +728,7 @@ func TestRuntime_OverrideClientOperation(t *testing.T) {
728728

729729
_, err := rt.Submit(&runtime.ClientOperation{
730730
Client: client2,
731-
Params: runtime.ClientRequestWriterFunc(func(r runtime.ClientRequest, _ strfmt.Registry) error {
731+
Params: runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
732732
return nil
733733
}),
734734
Reader: runtime.ClientResponseReaderFunc(func(_ runtime.ClientResponse, _ runtime.Consumer) (interface{}, error) {
@@ -759,7 +759,7 @@ func TestRuntime_PreserveTrailingSlash(t *testing.T) {
759759
require.NoError(t, err)
760760

761761
rt := New(hu.Host, "/", []string{schemeHTTP})
762-
rwrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
762+
rwrtr := runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
763763
return nil
764764
})
765765

@@ -1200,7 +1200,7 @@ func TestRuntime_Timeout(t *testing.T) { //nolint:maintidx // linter evaluates t
12001200
})
12011201
})
12021202
t.Run("with no context, request uses the default timeout", func(t *testing.T) {
1203-
requestEmptyWriter := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
1203+
requestEmptyWriter := runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
12041204
return nil
12051205
})
12061206
host, cleaner := serverBuilder(t, serverDelay, result)

client/runtime_tls_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func TestRuntimeTLSOptions(t *testing.T) {
116116
})
117117

118118
t.Run("with TLSAuthConfig with VerifyPeer option", func(t *testing.T) {
119-
verify := func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
119+
verify := func(_ [][]byte, _ [][]*x509.Certificate) error {
120120
return nil
121121
}
122122

@@ -156,7 +156,7 @@ func TestRuntimeManualCertificateValidation(t *testing.T) {
156156
ID: "getTasks",
157157
Method: http.MethodGet,
158158
PathPattern: "/",
159-
Params: runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, _ strfmt.Registry) error {
159+
Params: runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
160160
return nil
161161
}),
162162
Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {

internal/testing/simplepetstore/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func NewPetstore() (http.Handler, error) {
4444
return middleware.Serve(spec, api), nil
4545
}
4646

47-
var getAllPets = runtime.OperationHandlerFunc(func(data interface{}) (interface{}, error) {
47+
var getAllPets = runtime.OperationHandlerFunc(func(_ interface{}) (interface{}, error) {
4848
return pets, nil
4949
})
5050

middleware/denco/router.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package denco
33

44
import (
5+
"errors"
56
"fmt"
67
"sort"
78
"strings"
@@ -71,7 +72,7 @@ func (rt *Router) Lookup(path string) (data interface{}, params Params, found bo
7172
func (rt *Router) Build(records []Record) error {
7273
statics, params := makeRecords(records)
7374
if len(params) > MaxSize {
74-
return fmt.Errorf("denco: too many records")
75+
return errors.New("denco: too many records")
7576
}
7677
if rt.SizeHint < 0 {
7778
rt.SizeHint = 0
@@ -331,7 +332,7 @@ func (da *doubleArray) arrange(records []*record, idx, depth int, usedBase map[i
331332
}
332333
base = da.findBase(siblings, idx, usedBase)
333334
if base > MaxSize {
334-
return -1, nil, nil, fmt.Errorf("denco: too many elements of internal slice")
335+
return -1, nil, nil, errors.New("denco: too many elements of internal slice")
335336
}
336337
da.setBase(idx, base)
337338
return base, siblings, leaf, err
@@ -392,7 +393,7 @@ func makeSiblings(records []*record, depth int) (sib []sibling, leaf *record, er
392393
case pc == c:
393394
continue
394395
default:
395-
return nil, nil, fmt.Errorf("denco: BUG: routing table hasn't been sorted")
396+
return nil, nil, errors.New("denco: BUG: routing table hasn't been sorted")
396397
}
397398
if n > 0 {
398399
sib[n-1].end = i

middleware/operation_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
func TestOperationExecutor(t *testing.T) {
3131
spec, api := petstore.NewAPI(t)
32-
api.RegisterOperation("get", "/pets", runtime.OperationHandlerFunc(func(params interface{}) (interface{}, error) {
32+
api.RegisterOperation("get", "/pets", runtime.OperationHandlerFunc(func(_ interface{}) (interface{}, error) {
3333
return []interface{}{
3434
map[string]interface{}{"id": 1, "name": "a dog"},
3535
}, nil
@@ -49,7 +49,7 @@ func TestOperationExecutor(t *testing.T) {
4949
assert.Equal(t, `[{"id":1,"name":"a dog"}]`+"\n", recorder.Body.String())
5050

5151
spec, api = petstore.NewAPI(t)
52-
api.RegisterOperation("get", "/pets", runtime.OperationHandlerFunc(func(params interface{}) (interface{}, error) {
52+
api.RegisterOperation("get", "/pets", runtime.OperationHandlerFunc(func(_ interface{}) (interface{}, error) {
5353
return nil, errors.New(http.StatusUnprocessableEntity, "expected")
5454
}))
5555

middleware/request_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ func TestRequestBindingDefaultValue(t *testing.T) {
219219
assert.Equal(t, delivered, data["delivered"])
220220
assert.Equal(t, confirmed, data["confirmed"])
221221
assert.Equal(t, age, data["age"])
222-
assert.Equal(t, factor, data["factor"])
223-
assert.Equal(t, score, data["score"])
222+
assert.InDelta(t, factor, data["factor"], 1e-6)
223+
assert.InDelta(t, score, data["score"], 1e-6)
224224
assert.Equal(t, "hello", string(data["picture"].(strfmt.Base64)))
225225
}
226226

0 commit comments

Comments
 (0)