Skip to content

Commit c58668d

Browse files
committed
chore(lint): updated linters, relinted code
Signed-off-by: Frédéric BIDON <[email protected]>
1 parent cebbc5a commit c58668d

25 files changed

+160
-149
lines changed

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ linters:
2222
- nestif
2323
- nlreturn
2424
- nonamedreturns
25+
- noinlineerr
2526
- paralleltest
27+
- recvcheck
2628
- testpackage
2729
- thelper
2830
- tparallel
@@ -31,6 +33,7 @@ linters:
3133
- whitespace
3234
- wrapcheck
3335
- wsl
36+
- wsl_v5
3437
settings:
3538
dupl:
3639
threshold: 200

contact_info_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ func TestIntegrationContactInfo(t *testing.T) {
4343
actual := ContactInfo{}
4444
err = json.Unmarshal([]byte(contactInfoJSON), &actual)
4545
require.NoError(t, err)
46-
assert.EqualValues(t, contactInfo, actual)
46+
assert.Equal(t, contactInfo, actual)
4747
}

header_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func int64Ptr(f int64) *int64 {
3333
}
3434

3535
var header = Header{
36-
VendorExtensible: VendorExtensible{Extensions: map[string]interface{}{
36+
VendorExtensible: VendorExtensible{Extensions: map[string]any{
3737
"x-framework": "swagger-go",
3838
}},
3939
HeaderProps: HeaderProps{Description: "the description of this header"},
@@ -57,7 +57,7 @@ var header = Header{
5757
MinItems: int64Ptr(5),
5858
UniqueItems: true,
5959
MultipleOf: float64Ptr(5),
60-
Enum: []interface{}{"hello", "world"},
60+
Enum: []any{"hello", "world"},
6161
},
6262
}
6363

@@ -87,7 +87,7 @@ const headerJSON = `{
8787
func TestIntegrationHeader(t *testing.T) {
8888
var actual Header
8989
require.NoError(t, json.Unmarshal([]byte(headerJSON), &actual))
90-
assert.EqualValues(t, actual, header)
90+
assert.Equal(t, actual, header)
9191

9292
assertParsesJSON(t, headerJSON, header)
9393
}
@@ -104,13 +104,13 @@ func TestJSONLookupHeader(t *testing.T) {
104104
require.True(t, ok)
105105
assert.Equal(t, "8", def)
106106

107-
var x *interface{}
107+
var x *any
108108
res, err = header.JSONLookup("x-framework")
109109
require.NoError(t, err)
110110
require.NotNil(t, res)
111111
require.IsType(t, x, res)
112112

113-
x, ok = res.(*interface{})
113+
x, ok = res.(*any)
114114
require.True(t, ok)
115115
assert.EqualValues(t, "swagger-go", *x)
116116

@@ -144,7 +144,7 @@ func TestWithHeader(t *testing.T) {
144144
i := new(Items).Typed("string", "date")
145145
h = new(Header).CollectionOf(i, "pipe")
146146

147-
assert.EqualValues(t, *i, *h.Items)
147+
assert.Equal(t, *i, *h.Items)
148148
assert.Equal(t, "pipe", h.CollectionFormat)
149149

150150
h = new(Header).WithDefault([]string{"a", "b", "c"}).WithMaxLength(10).WithMinLength(3)
@@ -162,7 +162,7 @@ func TestWithHeader(t *testing.T) {
162162
h = new(Header).WithEnum("a", "b", "c")
163163
assert.Equal(t, Header{
164164
CommonValidations: CommonValidations{
165-
Enum: []interface{}{
165+
Enum: []any{
166166
"a",
167167
"b",
168168
"c",
@@ -173,5 +173,5 @@ func TestWithHeader(t *testing.T) {
173173

174174
func TestHeaderWithValidation(t *testing.T) {
175175
h := new(Header).WithValidations(CommonValidations{MaxLength: swag.Int64(15)})
176-
assert.EqualValues(t, swag.Int64(15), h.MaxLength)
176+
assert.Equal(t, swag.Int64(15), h.MaxLength)
177177
}

info_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var testInfo = Info{
5353
},
5454
},
5555
},
56-
VendorExtensible: VendorExtensible{Extensions: map[string]interface{}{"x-framework": "go-swagger"}},
56+
VendorExtensible: VendorExtensible{Extensions: map[string]any{"x-framework": "go-swagger"}},
5757
}
5858

5959
func TestInfo(t *testing.T) {
@@ -66,13 +66,13 @@ func TestInfo(t *testing.T) {
6666
t.Run("should unmarshal Info", func(t *testing.T) {
6767
actual := Info{}
6868
require.NoError(t, json.Unmarshal([]byte(infoJSON), &actual))
69-
assert.EqualValues(t, testInfo, actual)
69+
assert.Equal(t, testInfo, actual)
7070
})
7171

7272
t.Run("should GobEncode Info", func(t *testing.T) {
7373
var src, dst Info
7474
require.NoError(t, json.Unmarshal([]byte(infoJSON), &src))
75-
assert.EqualValues(t, src, testInfo)
75+
assert.Equal(t, src, testInfo)
7676
doTestAnyGobEncoding(t, &src, &dst)
7777
})
7878
}

items_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ const itemsJSON = `{
7676
func TestIntegrationItems(t *testing.T) {
7777
var actual Items
7878
require.NoError(t, json.Unmarshal([]byte(itemsJSON), &actual))
79-
assert.EqualValues(t, actual, testItems)
79+
assert.Equal(t, actual, testItems)
8080

8181
assertParsesJSON(t, itemsJSON, testItems)
8282
}
8383

8484
func TestTypeNameItems(t *testing.T) {
8585
var nilItems Items
86-
assert.Equal(t, "", nilItems.TypeName())
86+
assert.Empty(t, nilItems.TypeName())
8787

8888
assert.Equal(t, "date", testItems.TypeName())
89-
assert.Equal(t, "", testItems.ItemsTypeName())
89+
assert.Empty(t, testItems.ItemsTypeName())
9090

9191
nested := Items{
9292
SimpleSchema: SimpleSchema{
@@ -110,7 +110,7 @@ func TestTypeNameItems(t *testing.T) {
110110
}
111111

112112
assert.Equal(t, "string", simple.TypeName())
113-
assert.Equal(t, "", simple.ItemsTypeName())
113+
assert.Empty(t, simple.ItemsTypeName())
114114

115115
simple.Items = NewItems()
116116
simple.Type = "array"
@@ -159,7 +159,7 @@ func TestJSONLookupItems(t *testing.T) {
159159

160160
ref, ok := res.(*Ref)
161161
require.True(t, ok)
162-
assert.EqualValues(t, MustCreateRef("Dog"), *ref)
162+
assert.Equal(t, MustCreateRef("Dog"), *ref)
163163
})
164164

165165
t.Run(`lookup should find "maximum"`, func(t *testing.T) {
@@ -196,5 +196,5 @@ func TestJSONLookupItems(t *testing.T) {
196196

197197
func TestItemsWithValidation(t *testing.T) {
198198
i := new(Items).WithValidations(CommonValidations{MaxLength: swag.Int64(15)})
199-
assert.EqualValues(t, swag.Int64(15), i.MaxLength)
199+
assert.Equal(t, swag.Int64(15), i.MaxLength)
200200
}

license_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ func TestIntegrationLicense(t *testing.T) {
4545
actual := License{}
4646
err := json.Unmarshal([]byte(licenseJSON), &actual)
4747
require.NoError(t, err)
48-
assert.EqualValues(t, testLicense, actual)
48+
assert.Equal(t, testLicense, actual)
4949
})
5050
}

operation.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
)
2626

2727
func init() {
28-
gob.Register(map[string]interface{}{})
29-
gob.Register([]interface{}{})
28+
gob.Register(map[string]any{})
29+
gob.Register([]any{})
3030
}
3131

3232
// OperationProps describes an operation
@@ -58,19 +58,22 @@ func (op OperationProps) MarshalJSON() ([]byte, error) {
5858
type Alias OperationProps
5959
if op.Security == nil {
6060
return json.Marshal(&struct {
61-
Security []map[string][]string `json:"security,omitempty"`
6261
*Alias
62+
63+
Security []map[string][]string `json:"security,omitempty"`
6364
}{
64-
Security: op.Security,
6565
Alias: (*Alias)(&op),
66+
Security: op.Security,
6667
})
6768
}
69+
6870
return json.Marshal(&struct {
69-
Security []map[string][]string `json:"security"`
7071
*Alias
72+
73+
Security []map[string][]string `json:"security"`
7174
}{
72-
Security: op.Security,
7375
Alias: (*Alias)(&op),
76+
Security: op.Security,
7477
})
7578
}
7679

@@ -82,6 +85,14 @@ type Operation struct {
8285
OperationProps
8386
}
8487

88+
// NewOperation creates a new operation instance.
89+
// It expects an ID as parameter but not passing an ID is also valid.
90+
func NewOperation(id string) *Operation {
91+
op := new(Operation)
92+
op.ID = id
93+
return op
94+
}
95+
8596
// SuccessResponse gets a success response model
8697
func (o *Operation) SuccessResponse() (*Response, int, bool) {
8798
if o.Responses == nil {
@@ -104,7 +115,7 @@ func (o *Operation) SuccessResponse() (*Response, int, bool) {
104115
}
105116

106117
// JSONLookup look up a value by the json property name
107-
func (o Operation) JSONLookup(token string) (interface{}, error) {
118+
func (o Operation) JSONLookup(token string) (any, error) {
108119
if ex, ok := o.Extensions[token]; ok {
109120
return &ex, nil
110121
}
@@ -134,14 +145,6 @@ func (o Operation) MarshalJSON() ([]byte, error) {
134145
return concated, nil
135146
}
136147

137-
// NewOperation creates a new operation instance.
138-
// It expects an ID as parameter but not passing an ID is also valid.
139-
func NewOperation(id string) *Operation {
140-
op := new(Operation)
141-
op.ID = id
142-
return op
143-
}
144-
145148
// WithID sets the ID property on this operation, allows for chaining.
146149
func (o *Operation) WithID(id string) *Operation {
147150
o.ID = id

operation_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ func TestOperationBuilder(t *testing.T) {
259259
func TestIntegrationOperation(t *testing.T) {
260260
var actual Operation
261261
require.NoError(t, json.Unmarshal([]byte(operationJSON), &actual))
262-
assert.EqualValues(t, actual, operation)
262+
assert.Equal(t, actual, operation)
263263

264264
assertParsesJSON(t, operationJSON, operation)
265265
}

parameters_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ var parameterJSON = `{
9494
func TestIntegrationParameter(t *testing.T) {
9595
var actual Parameter
9696
require.NoError(t, json.Unmarshal([]byte(parameterJSON), &actual))
97-
assert.EqualValues(t, actual, parameter)
97+
assert.Equal(t, actual, parameter)
9898

9999
assertParsesJSON(t, parameterJSON, parameter)
100100
}
@@ -164,5 +164,5 @@ func TestParameterGobEncoding(t *testing.T) {
164164

165165
func TestParametersWithValidation(t *testing.T) {
166166
p := new(Parameter).WithValidations(CommonValidations{MaxLength: swag.Int64(15)})
167-
assert.EqualValues(t, swag.Int64(15), p.MaxLength)
167+
assert.Equal(t, swag.Int64(15), p.MaxLength)
168168
}

path_item_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const pathItemJSON = `{
7575
func TestIntegrationPathItem(t *testing.T) {
7676
var actual PathItem
7777
require.NoError(t, json.Unmarshal([]byte(pathItemJSON), &actual))
78-
assert.EqualValues(t, actual, pathItem)
78+
assert.Equal(t, actual, pathItem)
7979

8080
assertParsesJSON(t, pathItemJSON, pathItem)
8181
}

0 commit comments

Comments
 (0)