Skip to content

Commit 066d634

Browse files
committed
chore(lint): upadate linting
* updated linter config * relinter code Signed-off-by: Frédéric BIDON <[email protected]>
1 parent 640cd0c commit 066d634

File tree

10 files changed

+347
-333
lines changed

10 files changed

+347
-333
lines changed

.github/dependabot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ updates:
3737
patterns:
3838
- "github.com/stretchr/testify"
3939

40-
golang.org-dependencies:
40+
golang-org-dependencies:
4141
patterns:
4242
- "golang.org/*"
4343

.github/workflows/auto-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
3636

3737
- name: Auto-merge dependabot PRs for golang.org updates
38-
if: contains(steps.metadata.outputs.dependency-group, 'golang.org-dependencies')
38+
if: contains(steps.metadata.outputs.dependency-group, 'golang-org-dependencies')
3939
run: gh pr merge --auto --rebase "$PR_URL"
4040
env:
4141
PR_URL: ${{github.event.pull_request.html_url}}

.golangci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ linters:
1414
- gocognit
1515
- godot
1616
- godox
17+
- gomoddirectives
1718
- gosmopolitan
1819
- inamedparam
20+
- intrange # disabled while < go1.22
1921
- ireturn
2022
- lll
2123
- musttag
2224
- nestif
2325
- nlreturn
2426
- nonamedreturns
27+
- noinlineerr
2528
- paralleltest
29+
- recvcheck
2630
- testpackage
2731
- thelper
2832
- tparallel
@@ -31,6 +35,7 @@ linters:
3135
- whitespace
3236
- wrapcheck
3337
- wsl
38+
- wsl_v5
3439
settings:
3540
dupl:
3641
threshold: 200
@@ -60,3 +65,12 @@ formatters:
6065
- third_party$
6166
- builtin$
6267
- examples$
68+
issues:
69+
# Maximum issues count per one linter.
70+
# Set to 0 to disable.
71+
# Default: 50
72+
max-issues-per-linter: 0
73+
# Maximum count of issues with the same text.
74+
# Set to 0 to disable.
75+
# Default: 3
76+
max-same-issues: 0

default_validator.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ type defaultValidator struct {
2929
schemaOptions *SchemaValidatorOptions
3030
}
3131

32+
// Validate validates the default values declared in the swagger spec
33+
func (d *defaultValidator) Validate() *Result {
34+
errs := pools.poolOfResults.BorrowResult() // will redeem when merged
35+
36+
if d == nil || d.SpecValidator == nil {
37+
return errs
38+
}
39+
d.resetVisited()
40+
errs.Merge(d.validateDefaultValueValidAgainstSchema()) // error -
41+
return errs
42+
}
43+
3244
// resetVisited resets the internal state of visited schemas
3345
func (d *defaultValidator) resetVisited() {
3446
if d.visitedSchemas == nil {
@@ -82,18 +94,6 @@ func (d *defaultValidator) isVisited(path string) bool {
8294
return isVisited(path, d.visitedSchemas)
8395
}
8496

85-
// Validate validates the default values declared in the swagger spec
86-
func (d *defaultValidator) Validate() *Result {
87-
errs := pools.poolOfResults.BorrowResult() // will redeem when merged
88-
89-
if d == nil || d.SpecValidator == nil {
90-
return errs
91-
}
92-
d.resetVisited()
93-
errs.Merge(d.validateDefaultValueValidAgainstSchema()) // error -
94-
return errs
95-
}
96-
9797
func (d *defaultValidator) validateDefaultValueValidAgainstSchema() *Result {
9898
// every default value that is specified must validate against the schema for that property
9999
// headers, items, parameters, schema
@@ -285,7 +285,7 @@ func (d *defaultValidator) validateDefaultValueSchemaAgainstSchema(path, in stri
285285

286286
// TODO: Temporary duplicated code. Need to refactor with examples
287287

288-
func (d *defaultValidator) validateDefaultValueItemsAgainstSchema(path, in string, root interface{}, items *spec.Items) *Result {
288+
func (d *defaultValidator) validateDefaultValueItemsAgainstSchema(path, in string, root any, items *spec.Items) *Result {
289289
res := pools.poolOfResults.BorrowResult()
290290
s := d.SpecValidator
291291
if items != nil {

example_validator.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@ type exampleValidator struct {
2727
schemaOptions *SchemaValidatorOptions
2828
}
2929

30+
// Validate validates the example values declared in the swagger spec
31+
// Example values MUST conform to their schema.
32+
//
33+
// With Swagger 2.0, examples are supported in:
34+
// - schemas
35+
// - individual property
36+
// - responses
37+
func (ex *exampleValidator) Validate() *Result {
38+
errs := pools.poolOfResults.BorrowResult()
39+
40+
if ex == nil || ex.SpecValidator == nil {
41+
return errs
42+
}
43+
ex.resetVisited()
44+
errs.Merge(ex.validateExampleValueValidAgainstSchema()) // error -
45+
46+
return errs
47+
}
48+
3049
// resetVisited resets the internal state of visited schemas
3150
func (ex *exampleValidator) resetVisited() {
3251
if ex.visitedSchemas == nil {
@@ -51,25 +70,6 @@ func (ex *exampleValidator) isVisited(path string) bool {
5170
return isVisited(path, ex.visitedSchemas)
5271
}
5372

54-
// Validate validates the example values declared in the swagger spec
55-
// Example values MUST conform to their schema.
56-
//
57-
// With Swagger 2.0, examples are supported in:
58-
// - schemas
59-
// - individual property
60-
// - responses
61-
func (ex *exampleValidator) Validate() *Result {
62-
errs := pools.poolOfResults.BorrowResult()
63-
64-
if ex == nil || ex.SpecValidator == nil {
65-
return errs
66-
}
67-
ex.resetVisited()
68-
errs.Merge(ex.validateExampleValueValidAgainstSchema()) // error -
69-
70-
return errs
71-
}
72-
7373
func (ex *exampleValidator) validateExampleValueValidAgainstSchema() *Result {
7474
// every example value that is specified must validate against the schema for that property
7575
// in: schemas, properties, object, items
@@ -278,7 +278,7 @@ func (ex *exampleValidator) validateExampleValueSchemaAgainstSchema(path, in str
278278
// TODO: Temporary duplicated code. Need to refactor with examples
279279
//
280280

281-
func (ex *exampleValidator) validateExampleValueItemsAgainstSchema(path, in string, root interface{}, items *spec.Items) *Result {
281+
func (ex *exampleValidator) validateExampleValueItemsAgainstSchema(path, in string, root any, items *spec.Items) *Result {
282282
res := pools.poolOfResults.BorrowResult()
283283
s := ex.SpecValidator
284284
if items != nil {

helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func (h *paramHelper) checkExpandedParam(pr *spec.Parameter, path, in, operation
273273
simpleZero := spec.SimpleSchema{}
274274
// Try to explain why... best guess
275275
switch {
276-
case pr.In == swaggerBody && (pr.SimpleSchema != simpleZero && pr.SimpleSchema.Type != objectType):
276+
case pr.In == swaggerBody && (pr.SimpleSchema != simpleZero && pr.Type != objectType):
277277
if isRef {
278278
// Most likely, a $ref with a sibling is an unwanted situation: in itself this is a warning...
279279
// but we detect it because of the following error:

0 commit comments

Comments
 (0)