Skip to content

Commit 7938fea

Browse files
authored
Merge pull request #1455 from ogen-go/dependabot/github_actions/golangci/golangci-lint-action-8
chore: bump golangci/golangci-lint-action from 6 to 8
2 parents c7efec3 + ffe2ea8 commit 7938fea

12 files changed

Lines changed: 145 additions & 164 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
${{ runner.os }}-${{ runner.arch }}-go-
4040
4141
- name: Lint
42-
uses: golangci/golangci-lint-action@v6
42+
uses: golangci/golangci-lint-action@v8
4343
with:
4444
version: latest
4545
args: --timeout 5m

.golangci.yml

Lines changed: 120 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,133 @@
1-
linters-settings:
2-
gosec:
3-
config:
4-
# Maximum allowed permissions mode file creation
5-
# Default: "0600"
6-
G306: "0644"
7-
excludes:
8-
- G115 # Annoying and have a lot of false-positive results.
9-
gocyclo:
10-
min-complexity: 15
11-
dupl:
12-
threshold: 120
13-
goconst:
14-
min-len: 2
15-
min-occurrences: 3
16-
misspell:
17-
locale: US
18-
lll:
19-
line-length: 140
20-
gocritic:
21-
enabled-tags:
22-
- diagnostic
23-
- experimental
24-
- opinionated
25-
- performance
26-
- style
27-
disabled-checks:
28-
- emptyStringTest # len(<string>) > 0 is fine and easier to read in some contexts
29-
- hugeParam
30-
- rangeValCopy
31-
- exitAfterDefer
32-
- octalLiteral
33-
- httpNoBody
34-
- unnecessaryBlock # for UUID encoder
35-
goimports:
36-
local-prefixes: github.com/ogen-go/ogen
37-
1+
version: "2"
382
linters:
393
enable:
404
- dogsled
41-
- errcheck
425
- goconst
436
- gocritic
44-
- revive
457
- gosec
46-
- govet
47-
- ineffassign
488
- lll
499
- misspell
5010
- nakedret
51-
- typecheck
11+
- revive
5212
- unconvert
5313
- unparam
5414
- whitespace
55-
- unused
15+
settings:
16+
dupl:
17+
threshold: 120
18+
goconst:
19+
min-len: 2
20+
min-occurrences: 3
21+
gocritic:
22+
disabled-checks:
23+
- emptyStringTest
24+
- hugeParam
25+
- rangeValCopy
26+
- exitAfterDefer
27+
- octalLiteral
28+
- httpNoBody
29+
- unnecessaryBlock
30+
enabled-tags:
31+
- diagnostic
32+
- experimental
33+
- opinionated
34+
- performance
35+
- style
36+
gocyclo:
37+
min-complexity: 15
38+
gosec:
39+
excludes:
40+
- G115
41+
config:
42+
G306: "0644"
43+
lll:
44+
line-length: 140
45+
misspell:
46+
locale: US
47+
exclusions:
48+
generated: lax
49+
rules:
50+
- linters:
51+
- lll
52+
source: //go:generate
53+
- linters:
54+
- lll
55+
source: // See https://
56+
- linters:
57+
- dupl
58+
- errcheck
59+
- funlen
60+
- gocognit
61+
- goconst
62+
- gocyclo
63+
- gosec
64+
- lll
65+
- scopelint
66+
path: _test\.go
67+
- linters:
68+
- unparam
69+
path: _test\.go
70+
text: .*\$\d?
71+
- linters:
72+
- govet
73+
text: declaration of "(err|ctx|log)"
74+
- linters:
75+
- funlen
76+
- gocognit
77+
- goconst
78+
- gocyclo
79+
path: (cmd|tools)
80+
- linters:
81+
- golint
82+
- revive
83+
path: (conv|uri|gen|otelogen)
84+
text: (should have comment.+or be unexported|comment on exported)
85+
- linters:
86+
- golint
87+
- revive
88+
path: (cmd|tools|internal)
89+
text: should have (comment.+or be unexported|a package comment)
90+
- linters:
91+
- golint
92+
- revive
93+
text: (unused-parameter|if-return)
94+
- linters:
95+
- gocritic
96+
text: ptrToRefParam
97+
source: handleSchemaDepth
98+
- path: (cmd|tools)
99+
text: G(304|306|307)
100+
- path: techempower
101+
text: G114
102+
- linters:
103+
- gocritic
104+
path: (http|uri)
105+
text: sprintfQuotedString
106+
source: form-data; name="%s"
107+
- linters:
108+
- gocritic
109+
path: ogenregex[/\\]convert\.go
110+
text: emptyFallthrough
111+
- linters:
112+
- goconst
113+
text: string `(string|number|u?int\d{0,2}|float\d{2})`
114+
- linters:
115+
- goconst
116+
text: string `(Unix|unix|date|time|ipv6|String|DateTime|Number)
117+
paths:
118+
- third_party$
119+
- builtin$
120+
- examples$
121+
formatters:
122+
enable:
56123
- goimports
57-
# Do not enable:
58-
# - wsl (too opinionated about newlines)
59-
# - godox (todos are OK)
60-
# - bodyclose (false positives on helper functions)
61-
# - prealloc (not worth it in scope of this project)
62-
# - maligned (same as prealloc)
63-
# - funlen (gocyclo is enough)
64-
# - gochecknoglobals (we know when it is ok to use globals)
65-
# - gochecknoinits (we know when it is ok to use inits)
66-
# - dupl (validator/parser package are false positive)
67-
68-
issues:
69-
exclude-use-default: false
70-
exclude-rules:
71-
# Exclude go:generate from lll
72-
- source: "//go:generate"
73-
linters: [lll]
74-
75-
# Exclude links from lll
76-
- source: "// See https://"
77-
linters: [lll]
78-
79-
# Disable linters that are annoying in tests.
80-
- path: _test\.go
81-
linters:
82-
- gocyclo
83-
- errcheck
84-
- dupl
85-
- gosec
86-
- funlen
87-
- goconst
88-
- gocognit
89-
- scopelint
90-
- lll
91-
# Do not warn about unused closure parameters in test files.
92-
- path: _test\.go
93-
linters: [unparam]
94-
text: .*\$\d?
95-
96-
# Ignore shadowing of err.
97-
- linters: [govet]
98-
text: 'declaration of "(err|ctx|log)"'
99-
100-
# Ignore linters in main packages.
101-
- path: (cmd|tools)
102-
linters: [goconst, funlen, gocognit, gocyclo]
103-
104-
# TODO(tdakkota): add comments?
105-
- path: (conv|uri|gen|otelogen)
106-
linters: [revive, golint]
107-
text: "(should have comment.+or be unexported|comment on exported)"
108-
109-
# We don't need package comments for internal packages.
110-
# We don't need comments for command packages.
111-
- path: (cmd|tools|internal)
112-
linters: [revive, golint]
113-
text: "should have (comment.+or be unexported|a package comment)"
114-
115-
# Annoying and useless.
116-
- linters: [revive, golint]
117-
text: "(unused-parameter|if-return)"
118-
119-
- linters: [gocritic]
120-
text: ptrToRefParam
121-
source: handleSchemaDepth
122-
123-
# Intended in commands:
124-
# G307: Deferring unsafe method "Close" on type "*os.File"
125-
# G304: Potential file inclusion via variable
126-
- path: (cmd|tools)
127-
text: G(304|306|307)
128-
129-
# Nobody cares.
130-
# G114: Use of net/http serve function that has no support for setting timeouts
131-
- path: techempower
132-
text: G114
133-
134-
# We are using quoting algorithm from mime/multipart package. False-positive.
135-
- path: (http|uri)
136-
source: form-data; name="%s"
137-
linters: [gocritic]
138-
text: sprintfQuotedString
139-
140-
# Keep empty fallthrough for better readability.
141-
- path: ogenregex[/\\]convert\.go
142-
linters: [gocritic]
143-
text: emptyFallthrough
144-
145-
# Not supposed to be constant.
146-
- linters: [goconst]
147-
text: 'string `(string|number|u?int\d{0,2}|float\d{2})`'
148-
- linters: [goconst]
149-
text: "string `(Unix|unix|date|time|ipv6)"
124+
settings:
125+
goimports:
126+
local-prefixes:
127+
- github.com/ogen-go/ogen
128+
exclusions:
129+
generated: lax
130+
paths:
131+
- third_party$
132+
- builtin$
133+
- examples$

cmd/ogen/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ func cleanDir(targetDir string, files []os.DirEntry) (rerr error) {
3535
continue
3636
}
3737
name := f.Name()
38-
if !(strings.HasSuffix(name, "_gen.go") || strings.HasSuffix(name, "_gen_test.go")) {
38+
if !strings.HasSuffix(name, "_gen.go") && !strings.HasSuffix(name, "_gen_test.go") {
3939
continue
4040
}
41-
if !(strings.HasPrefix(name, "openapi") || strings.HasPrefix(name, "oas")) {
41+
if !strings.HasPrefix(name, "openapi") && !strings.HasPrefix(name, "oas") {
4242
continue
4343
}
4444
// Do not return error if file does not exist.

gen/schema_gen.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ func (g *schemaGen) generate2(name string, schema *jsonschema.Schema) (ret *ir.T
354354

355355
slot = fieldSlot{
356356
original: fmt.Sprintf("property %q (overridden by extension as %q)", prop.Name, *n),
357-
nameDefinedAt: prop.X.Pointer.Field("name"),
357+
nameDefinedAt: prop.X.Field("name"),
358358
}
359359
} else {
360360
propertyName := strings.TrimSpace(prop.Name)
@@ -406,7 +406,7 @@ func (g *schemaGen) generate2(name string, schema *jsonschema.Schema) (ret *ir.T
406406
const key = "additionalProperties"
407407
slot := fieldSlot{
408408
original: key,
409-
nameDefinedAt: schema.Pointer.Key(key),
409+
nameDefinedAt: schema.Key(key),
410410
}
411411
if err := addField(&ir.Field{
412412
Name: "AdditionalProps",
@@ -462,7 +462,7 @@ func (g *schemaGen) generate2(name string, schema *jsonschema.Schema) (ret *ir.T
462462
if anyOf != nil {
463463
slot := fieldSlot{
464464
original: "anyOf",
465-
nameDefinedAt: schema.Pointer.Key("anyOf"),
465+
nameDefinedAt: schema.Key("anyOf"),
466466
}
467467
if err := addField(&ir.Field{
468468
Name: "AnyOf",
@@ -475,7 +475,7 @@ func (g *schemaGen) generate2(name string, schema *jsonschema.Schema) (ret *ir.T
475475
if oneOf != nil {
476476
slot := fieldSlot{
477477
original: "oneOf",
478-
nameDefinedAt: schema.Pointer.Key("oneOf"),
478+
nameDefinedAt: schema.Key("oneOf"),
479479
}
480480
if err := addField(&ir.Field{
481481
Name: "OneOf",
@@ -654,7 +654,7 @@ func (g *schemaGen) checkDefaultType(s *jsonschema.Schema, val any) error {
654654

655655
if !ok {
656656
err := errors.Errorf("expected schema type is %q, default value is %T", s.Type, val)
657-
p := s.Pointer.Field("default")
657+
p := s.Field("default")
658658

659659
pos, ok := p.Position()
660660
if !ok {

gen/schema_gen_primitive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (g *schemaGen) validateEnumValues(s *jsonschema.Schema) error {
157157
return err
158158
}
159159
return &location.Error{
160-
File: s.Pointer.File(),
160+
File: s.File(),
161161
Pos: pos,
162162
Err: err,
163163
}

gen/schema_gen_sum.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func ensureNoInfiniteRecursion(parent *jsonschema.Schema) error {
9494
if _, ok := ctx[ref]; ok {
9595
err := errors.Errorf("reference %q [%d] leads to infinite recursion", ref, i)
9696

97-
pos, ok := s.Pointer.Position()
97+
pos, ok := s.Position()
9898
if !ok {
9999
return err
100100
}

0 commit comments

Comments
 (0)