Skip to content

Commit ff3425a

Browse files
committed
chore: refactor codebase and update linter configurations
- Simplify configuration by setting linters default to none - Enable additional linters including `copyloopvar` - Remove some linters such as `gofmt`, `goimports`, `gosimple`, `stylecheck`, and `typecheck` - Add exclusions for generated files, common false positives, and legacy code - Specify paths to exclude from linters and formatters, including `third_party`, `builtin`, and `examples` - Enable `gofmt` and `goimports` in formatters - Replace `if-else` priority check with a `switch` statement for better readability and extensibility in APNS notification handling Signed-off-by: appleboy <appleboy.tw@gmail.com>
1 parent 18c9b47 commit ff3425a

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

.golangci.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
version: "2"
12
linters:
2-
enable-all: false
3-
disable-all: true
4-
fast: false
3+
default: none
54
enable:
65
- bodyclose
6+
- copyloopvar
77
- dogsled
88
- dupl
99
- errcheck
@@ -12,11 +12,8 @@ linters:
1212
- goconst
1313
- gocritic
1414
- gocyclo
15-
- gofmt
16-
- goimports
1715
- goprintffuncname
1816
- gosec
19-
- gosimple
2017
- govet
2118
- ineffassign
2219
- lll
@@ -25,14 +22,29 @@ linters:
2522
- noctx
2623
- nolintlint
2724
- staticcheck
28-
- stylecheck
29-
- typecheck
3025
- unconvert
3126
- unparam
3227
- unused
3328
- whitespace
29+
exclusions:
30+
generated: lax
31+
presets:
32+
- comments
33+
- common-false-positives
34+
- legacy
35+
- std-error-handling
36+
paths:
37+
- third_party$
38+
- builtin$
39+
- examples$
40+
formatters:
41+
enable:
42+
- gofmt
3443
- gofumpt
35-
- copyloopvar
36-
37-
run:
38-
timeout: 3m
44+
- goimports
45+
exclusions:
46+
generated: lax
47+
paths:
48+
- third_party$
49+
- builtin$
50+
- examples$

notify/notification_apns.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,10 @@ func GetIOSNotification(req *PushNotification) *apns2.Notification {
333333
}
334334

335335
if len(req.Priority) > 0 {
336-
if req.Priority == "normal" {
336+
switch req.Priority {
337+
case "normal":
337338
notification.Priority = apns2.PriorityLow
338-
} else if req.Priority == HIGH {
339+
case "high": // Assuming the original HIGH constant meant "high"
339340
notification.Priority = apns2.PriorityHigh
340341
}
341342
}

0 commit comments

Comments
 (0)