Skip to content

Commit 76affd2

Browse files
committed
Merge branch 'main' into lunny/fix_failed_contributors
2 parents b728b57 + a2e8a28 commit 76affd2

File tree

394 files changed

+4295
-3120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

394 files changed

+4295
-3120
lines changed

.golangci.yml

Lines changed: 146 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,169 @@
1+
version: "2"
2+
output:
3+
sort-order:
4+
- file
15
linters:
2-
enable-all: false
3-
disable-all: true
4-
fast: false
6+
default: none
57
enable:
68
- bidichk
79
- depguard
810
- dupl
911
- errcheck
1012
- forbidigo
1113
- gocritic
12-
- gofmt
13-
- gofumpt
14-
- gosimple
1514
- govet
1615
- ineffassign
1716
- nakedret
1817
- nolintlint
1918
- revive
2019
- staticcheck
21-
- stylecheck
2220
- testifylint
23-
- typecheck
2421
- unconvert
25-
- unused
2622
- unparam
23+
- unused
2724
- usetesting
2825
- wastedassign
29-
30-
run:
31-
timeout: 10m
32-
33-
output:
34-
sort-results: true
35-
sort-order: [file]
36-
show-stats: true
37-
38-
linters-settings:
39-
testifylint:
40-
disable:
41-
- go-require
42-
- require-error
43-
stylecheck:
44-
checks: ["all", "-ST1005", "-ST1003"]
45-
nakedret:
46-
max-func-lines: 0
47-
gocritic:
48-
disabled-checks:
49-
- ifElseChain
50-
- singleCaseSwitch # Every time this occurred in the code, there was no other way.
51-
revive:
52-
severity: error
53-
rules:
54-
- name: atomic
55-
- name: bare-return
56-
- name: blank-imports
57-
- name: constant-logical-expr
58-
- name: context-as-argument
59-
- name: context-keys-type
60-
- name: dot-imports
61-
- name: duplicated-imports
62-
- name: empty-lines
63-
- name: error-naming
64-
- name: error-return
65-
- name: error-strings
66-
- name: errorf
67-
- name: exported
68-
- name: identical-branches
69-
- name: if-return
70-
- name: increment-decrement
71-
- name: indent-error-flow
72-
- name: modifies-value-receiver
73-
- name: package-comments
74-
- name: range
75-
- name: receiver-naming
76-
- name: redefines-builtin-id
77-
- name: string-of-int
78-
- name: superfluous-else
79-
- name: time-naming
80-
- name: unconditional-recursion
81-
- name: unexported-return
82-
- name: unreachable-code
83-
- name: var-declaration
84-
- name: var-naming
85-
gofumpt:
86-
extra-rules: true
87-
depguard:
26+
settings:
27+
depguard:
28+
rules:
29+
main:
30+
deny:
31+
- pkg: encoding/json
32+
desc: use gitea's modules/json instead of encoding/json
33+
- pkg: github.com/unknwon/com
34+
desc: use gitea's util and replacements
35+
- pkg: io/ioutil
36+
desc: use os or io instead
37+
- pkg: golang.org/x/exp
38+
desc: it's experimental and unreliable
39+
- pkg: code.gitea.io/gitea/modules/git/internal
40+
desc: do not use the internal package, use AddXxx function instead
41+
- pkg: gopkg.in/ini.v1
42+
desc: do not use the ini package, use gitea's config system instead
43+
- pkg: gitea.com/go-chi/cache
44+
desc: do not use the go-chi cache package, use gitea's cache system
45+
gocritic:
46+
disabled-checks:
47+
- ifElseChain
48+
- singleCaseSwitch # Every time this occurred in the code, there was no other way.
49+
revive:
50+
severity: error
51+
rules:
52+
- name: atomic
53+
- name: bare-return
54+
- name: blank-imports
55+
- name: constant-logical-expr
56+
- name: context-as-argument
57+
- name: context-keys-type
58+
- name: dot-imports
59+
- name: duplicated-imports
60+
- name: empty-lines
61+
- name: error-naming
62+
- name: error-return
63+
- name: error-strings
64+
- name: errorf
65+
- name: exported
66+
- name: identical-branches
67+
- name: if-return
68+
- name: increment-decrement
69+
- name: indent-error-flow
70+
- name: modifies-value-receiver
71+
- name: package-comments
72+
- name: range
73+
- name: receiver-naming
74+
- name: redefines-builtin-id
75+
- name: string-of-int
76+
- name: superfluous-else
77+
- name: time-naming
78+
- name: unconditional-recursion
79+
- name: unexported-return
80+
- name: unreachable-code
81+
- name: var-declaration
82+
- name: var-naming
83+
staticcheck:
84+
checks:
85+
- all
86+
- -ST1003
87+
- -ST1005
88+
- -QF1001
89+
- -QF1006
90+
- -QF1008
91+
testifylint:
92+
disable:
93+
- go-require
94+
- require-error
95+
usetesting:
96+
os-temp-dir: true
97+
exclusions:
98+
generated: lax
99+
presets:
100+
- comments
101+
- common-false-positives
102+
- legacy
103+
- std-error-handling
88104
rules:
89-
main:
90-
deny:
91-
- pkg: encoding/json
92-
desc: use gitea's modules/json instead of encoding/json
93-
- pkg: github.com/unknwon/com
94-
desc: use gitea's util and replacements
95-
- pkg: io/ioutil
96-
desc: use os or io instead
97-
- pkg: golang.org/x/exp
98-
desc: it's experimental and unreliable
99-
- pkg: code.gitea.io/gitea/modules/git/internal
100-
desc: do not use the internal package, use AddXxx function instead
101-
- pkg: gopkg.in/ini.v1
102-
desc: do not use the ini package, use gitea's config system instead
103-
- pkg: gitea.com/go-chi/cache
104-
desc: do not use the go-chi cache package, use gitea's cache system
105-
usetesting:
106-
os-temp-dir: true
107-
105+
- linters:
106+
- dupl
107+
- errcheck
108+
- gocyclo
109+
- gosec
110+
- staticcheck
111+
- unparam
112+
path: _test\.go
113+
- linters:
114+
- dupl
115+
- errcheck
116+
- gocyclo
117+
- gosec
118+
path: models/migrations/v
119+
- linters:
120+
- forbidigo
121+
path: cmd
122+
- linters:
123+
- dupl
124+
text: (?i)webhook
125+
- linters:
126+
- gocritic
127+
text: (?i)`ID' should not be capitalized
128+
- linters:
129+
- deadcode
130+
- unused
131+
text: (?i)swagger
132+
- linters:
133+
- staticcheck
134+
text: (?i)argument x is overwritten before first use
135+
- linters:
136+
- gocritic
137+
text: '(?i)commentFormatting: put a space between `//` and comment text'
138+
- linters:
139+
- gocritic
140+
text: '(?i)exitAfterDefer:'
141+
paths:
142+
- node_modules
143+
- public
144+
- web_src
145+
- third_party$
146+
- builtin$
147+
- examples$
108148
issues:
109149
max-issues-per-linter: 0
110150
max-same-issues: 0
111-
exclude-dirs: [node_modules, public, web_src]
112-
exclude-case-sensitive: true
113-
exclude-rules:
114-
- path: _test\.go
115-
linters:
116-
- gocyclo
117-
- errcheck
118-
- dupl
119-
- gosec
120-
- unparam
121-
- staticcheck
122-
- path: models/migrations/v
123-
linters:
124-
- gocyclo
125-
- errcheck
126-
- dupl
127-
- gosec
128-
- path: cmd
129-
linters:
130-
- forbidigo
131-
- text: "webhook"
132-
linters:
133-
- dupl
134-
- text: "`ID' should not be capitalized"
135-
linters:
136-
- gocritic
137-
- text: "swagger"
138-
linters:
139-
- unused
140-
- deadcode
141-
- text: "argument x is overwritten before first use"
142-
linters:
143-
- staticcheck
144-
- text: "commentFormatting: put a space between `//` and comment text"
145-
linters:
146-
- gocritic
147-
- text: "exitAfterDefer:"
148-
linters:
149-
- gocritic
151+
formatters:
152+
enable:
153+
- gofmt
154+
- gofumpt
155+
settings:
156+
gofumpt:
157+
extra-rules: true
158+
exclusions:
159+
generated: lax
160+
paths:
161+
- node_modules
162+
- public
163+
- web_src
164+
- third_party$
165+
- builtin$
166+
- examples$
167+
168+
run:
169+
timeout: 10m

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ XGO_VERSION := go-1.24.x
2828
AIR_PACKAGE ?= github.com/air-verse/air@v1
2929
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/[email protected]
3030
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
31-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.7
31+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3333
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]
@@ -410,12 +410,12 @@ watch-backend: go-check ## watch backend files and continuously rebuild
410410
test: test-frontend test-backend ## test everything
411411

412412
.PHONY: test-backend
413-
test-backend: ## test frontend files
413+
test-backend: ## test backend files
414414
@echo "Running go test with $(GOTESTFLAGS) -tags '$(TEST_TAGS)'..."
415415
@$(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' $(GO_TEST_PACKAGES)
416416

417417
.PHONY: test-frontend
418-
test-frontend: node_modules ## test backend files
418+
test-frontend: node_modules ## test frontend files
419419
npx vitest
420420

421421
.PHONY: test-check
@@ -737,7 +737,7 @@ generate-go: $(TAGS_PREREQ)
737737

738738
.PHONY: security-check
739739
security-check:
740-
go run $(GOVULNCHECK_PACKAGE) ./...
740+
go run $(GOVULNCHECK_PACKAGE) -show color ./...
741741

742742
$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
743743
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@

cmd/admin_auth_ldap_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ func TestAddLdapBindDn(t *testing.T) {
229229
return nil
230230
},
231231
updateAuthSource: func(ctx context.Context, authSource *auth.Source) error {
232-
assert.FailNow(t, "case %d: should not call updateAuthSource", n)
232+
assert.FailNow(t, "updateAuthSource called", "case %d: should not call updateAuthSource", n)
233233
return nil
234234
},
235235
getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) {
236-
assert.FailNow(t, "case %d: should not call getAuthSourceByID", n)
236+
assert.FailNow(t, "getAuthSourceByID called", "case %d: should not call getAuthSourceByID", n)
237237
return nil, nil
238238
},
239239
}
@@ -460,11 +460,11 @@ func TestAddLdapSimpleAuth(t *testing.T) {
460460
return nil
461461
},
462462
updateAuthSource: func(ctx context.Context, authSource *auth.Source) error {
463-
assert.FailNow(t, "case %d: should not call updateAuthSource", n)
463+
assert.FailNow(t, "updateAuthSource called", "case %d: should not call updateAuthSource", n)
464464
return nil
465465
},
466466
getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) {
467-
assert.FailNow(t, "case %d: should not call getAuthSourceByID", n)
467+
assert.FailNow(t, "getAuthSourceById called", "case %d: should not call getAuthSourceByID", n)
468468
return nil, nil
469469
},
470470
}
@@ -925,7 +925,7 @@ func TestUpdateLdapBindDn(t *testing.T) {
925925
return nil
926926
},
927927
createAuthSource: func(ctx context.Context, authSource *auth.Source) error {
928-
assert.FailNow(t, "case %d: should not call createAuthSource", n)
928+
assert.FailNow(t, "createAuthSource called", "case %d: should not call createAuthSource", n)
929929
return nil
930930
},
931931
updateAuthSource: func(ctx context.Context, authSource *auth.Source) error {
@@ -1315,7 +1315,7 @@ func TestUpdateLdapSimpleAuth(t *testing.T) {
13151315
return nil
13161316
},
13171317
createAuthSource: func(ctx context.Context, authSource *auth.Source) error {
1318-
assert.FailNow(t, "case %d: should not call createAuthSource", n)
1318+
assert.FailNow(t, "createAuthSource called", "case %d: should not call createAuthSource", n)
13191319
return nil
13201320
},
13211321
updateAuthSource: func(ctx context.Context, authSource *auth.Source) error {

cmd/admin_user_create_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ func TestAdminUserCreate(t *testing.T) {
6161
assert.NoError(t, createUser("u", "--user-type bot"))
6262
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{LowerName: "u"})
6363
assert.Equal(t, user_model.UserTypeBot, u.Type)
64-
assert.Equal(t, "", u.Passwd)
64+
assert.Empty(t, u.Passwd)
6565
})
6666
}

cmd/doctor.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,12 @@ func setupDoctorDefaultLogger(ctx *cli.Context, colorize bool) {
144144
setupConsoleLogger(log.FATAL, log.CanColorStderr, os.Stderr)
145145

146146
logFile := ctx.String("log-file")
147-
if logFile == "" {
147+
switch logFile {
148+
case "":
148149
return // if no doctor log-file is set, do not show any log from default logger
149-
} else if logFile == "-" {
150+
case "-":
150151
setupConsoleLogger(log.TRACE, colorize, os.Stdout)
151-
} else {
152+
default:
152153
logFile, _ = filepath.Abs(logFile)
153154
writeMode := log.WriterMode{Level: log.TRACE, WriterOption: log.WriterFileOption{FileName: logFile}}
154155
writer, err := log.NewEventWriter("console-to-file", "file", writeMode)

0 commit comments

Comments
 (0)