Skip to content

Commit 260cca7

Browse files
committed
Update golangci-lint and update code to satisfy checks
1 parent 381f879 commit 260cca7

File tree

5 files changed

+49
-39
lines changed

5 files changed

+49
-39
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ jobs:
5151
steps:
5252
- uses: actions/setup-go@v5
5353
- uses: actions/checkout@v4
54-
- uses: golangci/golangci-lint-action@v6
55-
with:
56-
version: v1.57.2
54+
- uses: golangci/golangci-lint-action@v8
5755

5856
- name: Go mod
5957
env:

.golangci.yml

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
1+
version: "2"
12
linters:
23
enable:
3-
- structcheck
4-
- varcheck
5-
- staticcheck
6-
- unconvert
7-
- gofmt
8-
- goimports
9-
- golint
10-
- ineffassign
11-
- vet
12-
- unused
13-
- misspell
144
- bodyclose
15-
- interfacer
16-
- unconvert
17-
- maligned
18-
# - depguard
5+
- misspell
196
- nakedret
207
- prealloc
8+
- unconvert
219
- whitespace
10+
- staticcheck
11+
- ineffassign
12+
- unused
2213
disable:
2314
- errcheck
24-
15+
exclusions:
16+
generated: lax
17+
presets:
18+
- comments
19+
- common-false-positives
20+
- legacy
21+
- std-error-handling
22+
paths:
23+
- bin
24+
- docs
25+
formatters:
26+
enable:
27+
- gofmt
28+
- goimports
29+
exclusions:
30+
generated: lax
31+
paths:
32+
- bin
33+
- docs
34+
- third_party$
35+
- builtin$
36+
- examples$
2537
run:
2638
timeout: 3m
27-
28-
issues:
29-
exclude-dirs:
30-
- bin
31-
- docs

pkg/db/badger.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,12 @@ func (b *Badger) setObj(txn *badger.Txn, key []byte, obj interface{}, overwrite
272272
if !overwrite {
273273
// Overwrites are not allowed, make sure there is no object with the given key
274274
_, err := txn.Get(key)
275-
if err == nil {
275+
switch err {
276+
case nil:
276277
return model.ErrAlreadyExists
277-
} else if err == badger.ErrKeyNotFound {
278+
case badger.ErrKeyNotFound:
278279
// Key not found, do nothing
279-
} else {
280+
default:
280281
return errors.Wrap(err, "failed to check whether key exists")
281282
}
282283
}

pkg/feed/xml.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,22 @@ func EpisodeName(feedConfig *Config, episode *model.Episode) string {
178178
func EnclosureFromExtension(feedConfig *Config) itunes.EnclosureType {
179179
ext := feedConfig.CustomFormat.Extension
180180

181-
switch {
182-
case ext == "m4a":
181+
switch ext {
182+
case "m4a":
183183
return itunes.M4A
184-
case ext == "m4v":
184+
case "m4v":
185185
return itunes.M4V
186-
case ext == "mp4":
186+
case "mp4":
187187
return itunes.MP4
188-
case ext == "mp3":
188+
case "mp3":
189189
return itunes.MP3
190-
case ext == "mov":
190+
case "mov":
191191
return itunes.MOV
192-
case ext == "pdf":
192+
case "pdf":
193193
return itunes.PDF
194-
case ext == "epub":
194+
case "epub":
195195
return itunes.EPUB
196+
default:
197+
return -1
196198
}
197-
return -1
198199
}

pkg/ytdl/ytdl.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ func (dl *YoutubeDl) exec(ctx context.Context, args ...string) (string, error) {
227227
func buildArgs(feedConfig *feed.Config, episode *model.Episode, outputFilePath string) []string {
228228
var args []string
229229

230-
if feedConfig.Format == model.FormatVideo {
230+
switch feedConfig.Format {
231+
case model.FormatVideo:
231232
// Video, mp4, high by default
232233

233234
format := "bestvideo[ext=mp4][vcodec^=avc1]+bestaudio[ext=m4a]/best[ext=mp4][vcodec^=avc1]/best[ext=mp4]/best"
@@ -239,15 +240,17 @@ func buildArgs(feedConfig *feed.Config, episode *model.Episode, outputFilePath s
239240
}
240241

241242
args = append(args, "--format", format)
242-
} else if feedConfig.Format == model.FormatAudio {
243+
244+
case model.FormatAudio:
243245
// Audio, mp3, high by default
244246
format := "bestaudio"
245247
if feedConfig.Quality == model.QualityLow {
246248
format = "worstaudio"
247249
}
248250

249251
args = append(args, "--extract-audio", "--audio-format", "mp3", "--format", format)
250-
} else {
252+
253+
default:
251254
args = append(args, "--audio-format", feedConfig.CustomFormat.Extension, "--format", feedConfig.CustomFormat.YouTubeDLFormat)
252255
}
253256

0 commit comments

Comments
 (0)