Skip to content

Commit e815133

Browse files
committed
Update linter, fix code style
1 parent fd3158e commit e815133

File tree

14 files changed

+86
-71
lines changed

14 files changed

+86
-71
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
go-version: stable
2525
- uses: actions/checkout@v4
2626
- name: golangci-lint
27-
uses: golangci/golangci-lint-action@v6.5.0
27+
uses: golangci/golangci-lint-action@v8.0.0
2828
with:
2929
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
30-
version: v1.64.5
30+
version: v2.5.0
3131

3232
# Optional: working directory, useful for monorepos
3333
# working-directory: somedir

.github/workflows/test-unit.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ jobs:
8080
curl -sLO https://github.com/vearutop/gocovdiff/releases/download/v1.4.2/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz && rm linux_amd64.tar.gz
8181
gocovdiff_hash=$(git hash-object ./gocovdiff)
8282
[ "$gocovdiff_hash" == "c37862c73a677e5a9c069470287823ab5bbf0244" ] || (echo "::error::unexpected hash for gocovdiff, possible tampering: $gocovdiff_hash" && exit 1)
83-
git fetch origin master ${{ github.event.pull_request.base.sha }}
84-
REP=$(./gocovdiff -mod github.com/$GITHUB_REPOSITORY -cov unit.coverprofile -gha-annotations gha-unit.txt -delta-cov-file delta-cov-unit.txt -target-delta-cov ${TARGET_DELTA_COV})
83+
# Fetch PR diff from GitHub API.
84+
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3.diff" https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} > pull_request.diff
85+
REP=$(./gocovdiff -diff pull_request.diff -mod github.com/$GITHUB_REPOSITORY -cov unit.coverprofile -gha-annotations gha-unit.txt -delta-cov-file delta-cov-unit.txt -target-delta-cov ${TARGET_DELTA_COV})
8586
echo "${REP}"
8687
cat gha-unit.txt
8788
DIFF=$(test -e unit-base.txt && ./gocovdiff -mod github.com/$GITHUB_REPOSITORY -func-cov unit.txt -func-base-cov unit-base.txt || echo "Missing base coverage file")

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@
44
/.vscode
55
/bench-*.txt
66
/vendor
7-
go.work
8-
go.work.sum

.golangci.yml

Lines changed: 72 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
1-
# See https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
1+
# See https://golangci-lint.run/docs/linters/configuration/
2+
version: "2"
23
run:
34
tests: true
4-
5-
linters-settings:
6-
errcheck:
7-
check-type-assertions: true
8-
check-blank: true
9-
gocyclo:
10-
min-complexity: 20
11-
dupl:
12-
threshold: 100
13-
misspell:
14-
locale: US
15-
unparam:
16-
check-exported: true
17-
185
linters:
19-
enable-all: true
6+
default: all
207
disable:
218
- nilnil
229
- err113
@@ -26,48 +13,79 @@ linters:
2613
- gocognit
2714
- musttag
2815
- intrange
16+
- noinlineerr
17+
- wsl_v5
18+
- funcorder
2919
- copyloopvar
30-
- lll
31-
- gochecknoglobals
32-
- wrapcheck
33-
- paralleltest
20+
- depguard
21+
- dupword
22+
- errname
23+
- exhaustruct
3424
- forbidigo
3525
- forcetypeassert
36-
- varnamelen
37-
- tagliatelle
38-
- errname
26+
- gochecknoglobals
27+
- intrange
3928
- ireturn
40-
- exhaustruct
29+
- lll
30+
- mnd
4131
- nonamedreturns
42-
- testableexamples
43-
- dupword
44-
- depguard
32+
- paralleltest
33+
- recvcheck
4534
- tagalign
46-
- mnd
35+
- tagliatelle
36+
- testableexamples
4737
- testifylint
48-
- recvcheck
49-
50-
issues:
51-
exclude-use-default: false
52-
exclude-rules:
53-
- linters:
54-
- staticcheck
55-
text: "SA1019: strings.Title .+ deprecated"
56-
57-
- linters:
58-
- mnd
59-
- goconst
60-
- noctx
61-
- funlen
62-
- dupl
63-
- unused
64-
- unparam
65-
path: "_test.go"
66-
- linters:
67-
- errcheck # Error checking omitted for brevity.
68-
- gosec
69-
path: "example_"
70-
- linters:
71-
- revive
72-
text: "unused-parameter: parameter"
73-
38+
- varnamelen
39+
- wrapcheck
40+
settings:
41+
dupl:
42+
threshold: 100
43+
errcheck:
44+
check-type-assertions: true
45+
check-blank: true
46+
gocyclo:
47+
min-complexity: 20
48+
misspell:
49+
locale: US
50+
unparam:
51+
check-exported: true
52+
exclusions:
53+
generated: lax
54+
rules:
55+
- linters:
56+
- embeddedstructfieldcheck
57+
- gosec
58+
- dupl
59+
- funlen
60+
- goconst
61+
- mnd
62+
- noctx
63+
- unparam
64+
- unused
65+
path: _test.go
66+
- linters:
67+
- errcheck
68+
- gosec
69+
path: example_
70+
- linters:
71+
- revive
72+
text: 'unused-parameter: parameter'
73+
- linters:
74+
- staticcheck
75+
text: "SA1019: strings.Title .+ deprecated"
76+
paths:
77+
- third_party$
78+
- builtin$
79+
- examples$
80+
formatters:
81+
enable:
82+
- gci
83+
- gofmt
84+
- gofumpt
85+
- goimports
86+
exclusions:
87+
generated: lax
88+
paths:
89+
- third_party$
90+
- builtin$
91+
- examples$

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#GOLANGCI_LINT_VERSION := "v1.64.5" # Optional configuration to pinpoint golangci-lint version.
1+
#GOLANGCI_LINT_VERSION := "v2.5.0" # Optional configuration to pinpoint golangci-lint version.
22

33
# The head of Makefile determines location of dev-go to include standard targets.
44
GO ?= go
@@ -27,9 +27,6 @@ ifeq ($(DEVGO_PATH),)
2727
endif
2828
endif
2929

30-
JSON_CLI_VERSION := "v1.8.6"
31-
JSON_CLI_VERSION_31 := "v1.11.1"
32-
3330
-include $(DEVGO_PATH)/makefiles/main.mk
3431
-include $(DEVGO_PATH)/makefiles/lint.mk
3532
-include $(DEVGO_PATH)/makefiles/test-unit.mk

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/swaggest/openapi-go
33
go 1.18
44

55
require (
6-
github.com/bool64/dev v0.2.39
6+
github.com/bool64/dev v0.2.43
77
github.com/stretchr/testify v1.8.2
88
github.com/swaggest/assertjson v1.9.0
99
github.com/swaggest/jsonschema-go v0.3.74

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/bool64/dev v0.2.39 h1:kP8DnMGlWXhGYJEZE/J0l/gVBdbuhoPGL+MJG4QbofE=
2-
github.com/bool64/dev v0.2.39/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
1+
github.com/bool64/dev v0.2.43 h1:yQ7qiZVef6WtCl2vDYU0Y+qSq+0aBrQzY8KXkklk9cQ=
2+
github.com/bool64/dev v0.2.43/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
33
github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E=
44
github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs=
55
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

openapi3/entities.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi3/example_misc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func ExampleReflector_options() {
1414
r := openapi3.Reflector{}
1515

1616
// Reflector embeds jsonschema.Reflector and it is possible to configure optional behavior.
17-
r.Reflector.DefaultOptions = append(r.Reflector.DefaultOptions,
17+
r.DefaultOptions = append(r.DefaultOptions,
1818
jsonschema.InterceptNullability(func(params jsonschema.InterceptNullabilityParams) {
1919
// Removing nullability from non-pointer slices (regardless of omitempty).
2020
if params.Type.Kind() != reflect.Ptr && params.Schema.HasType(jsonschema.Null) && params.Schema.HasType(jsonschema.Array) {

openapi3/reflect.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
// Reflector builds OpenAPI Schema with reflected structures.
1919
type Reflector struct {
2020
jsonschema.Reflector
21+
2122
Spec *Spec
2223
}
2324

0 commit comments

Comments
 (0)