Skip to content

Commit f913f10

Browse files
committed
Update linter, fix some bugs
1 parent 20ff63a commit f913f10

12 files changed

+24
-22
lines changed

.github/workflows/codetests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: golangci-lint
4040
uses: golangci/golangci-lint-action@v6
4141
with:
42-
version: 'v1.59'
42+
version: 'v1.62'
4343

4444
golangci-linux:
4545
# description: "Runs golangci-lint on linux against linux and windows."
@@ -60,4 +60,4 @@ jobs:
6060
- name: golangci-lint
6161
uses: golangci/golangci-lint-action@v6
6262
with:
63-
version: 'v1.59'
63+
version: 'v1.62'

.golangci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ linters:
22
enable-all: true
33
disable:
44
# deprecated
5-
- execinquery
6-
- gomnd
5+
- exportloopref
76
# unused
87
- exhaustruct
98
- exhaustive

examples/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,4 @@ services:
135135
- UN_CMDHOOK_0_EXCLUDE_1=lidarr
136136
- UN_CMDHOOK_0_TIMEOUT=10s
137137

138-
## => Content Auto Generated, 02 AUG 2024 22:38 UTC
138+
## => Content Auto Generated, 15 NOV 2024 21:29 UTC

examples/unpackerr.conf.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,4 @@ dir_mode = "0755"
301301
## You can adjust how long to wait for the command to run.
302302
# timeout = "10s"
303303

304-
## => Content Auto Generated, 02 AUG 2024 22:38 UTC
304+
## => Content Auto Generated, 15 NOV 2024 21:29 UTC

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func main() {
1717
}()
1818

1919
if err := unpackerr.Start(); err != nil {
20-
_, _ = ui.Error("Unpackerr Error", err.Error())
20+
_, _ = ui.Error("Unpackerr Error", "%v", err)
2121
log.Fatalln("[ERROR]", err) //nolint:gocritic
2222
}
2323
}

pkg/ui/dlgs_other.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ func Warning(_, _ string) (bool, error) {
88
}
99

1010
// Error wraps dlgs.Error.
11-
func Error(_, _ string) (bool, error) {
11+
func Error(_, _ string, _ any) (bool, error) {
1212
return true, nil
1313
}
1414

1515
// Info wraps dlgs.Info.
16-
func Info(_, _ string) (bool, error) {
16+
func Info(_, _ string, _ any) (bool, error) {
1717
return true, nil
1818
}
1919

@@ -23,6 +23,6 @@ func Entry(_, _, val string) (string, bool, error) {
2323
}
2424

2525
// Question wraps dlgs.Question.
26-
func Question(_, _ string, _ bool) (bool, error) {
26+
func Question(_ string, _ bool, _ string, _ any) (bool, error) {
2727
return true, nil
2828
}

pkg/unpackerr/apps.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ func (slice *StringSlice) UnmarshalENV(_, envval string) error {
189189
return nil
190190
}
191191

192-
func (slice StringSlice) MarshalENV(tag string) (map[string]string, error) {
193-
return map[string]string{tag: strings.Join(slice, ",")}, nil
192+
func (slice *StringSlice) MarshalENV(tag string) (map[string]string, error) {
193+
return map[string]string{tag: strings.Join(*slice, ",")}, nil
194194
}
195195

196196
func buildStatusReason(status string, messages []*starr.StatusMessage) string {

pkg/unpackerr/logs.go

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ func (u *Unpackerr) logCurrentQueue(now time.Time) {
126126
len(u.folders.Events)+len(u.updates)+len(u.folders.Updates), len(u.hookChan), len(u.delChan),
127127
durafmt.Parse(now.Sub(version.Started)).LimitFirstN(3).Format(durafmtUnits)) //nolint:mnd
128128

129+
//nolint:gosec
129130
u.updateTray(stats, uint(len(u.folders.Events)+len(u.updates)+len(u.folders.Updates)+len(u.delChan)+len(u.hookChan)))
130131
}
131132

pkg/unpackerr/start.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ func New() *Unpackerr {
125125
}
126126

127127
// Start runs the app.
128+
//
129+
//nolint:gosec // not too concerned with possible integer overflows reading user-provided config files.
128130
func Start() error {
129131
log.SetFlags(log.LstdFlags) // in case we throw an error for main.go before logging is setup.
130132

@@ -146,7 +148,7 @@ func Start() error {
146148
unpackerr.Printf("Unpackerr v%s-%s Starting! PID: %v, UID: %d, GID: %d, Umask: %d, Now: %v",
147149
version.Version, version.Revision, os.Getpid(),
148150
os.Getuid(), os.Getgid(), getUmask(), version.Started.Round(time.Second))
149-
unpackerr.Debugf(strings.Join(strings.Fields(strings.ReplaceAll(version.Print("unpackerr"), "\n", ", ")), " "))
151+
unpackerr.Debugf("%s", strings.Join(strings.Fields(strings.ReplaceAll(version.Print("unpackerr"), "\n", ", ")), " "))
150152
// Parse filepath: strings from the config and read in extra config files.
151153
output, err := cnfgfile.Parse(unpackerr.Config, &cnfgfile.Opts{
152154
Name: "Unpackerr",

pkg/unpackerr/tray.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ func (u *Unpackerr) makeHistoryChannels() {
140140
u.menu[histNone].SetTooltip("history is disabled in the config")
141141
}
142142

143-
for i := range int(u.KeepHistory) {
144-
u.menu[hist+strconv.Itoa(i)] = ui.WrapMenu(history.AddSubMenuItem("", ""))
145-
u.menu[hist+strconv.Itoa(i)].Disable()
146-
u.menu[hist+strconv.Itoa(i)].Hide()
143+
for i := range u.KeepHistory {
144+
u.menu[hist+strconv.FormatUint(uint64(i), 10)] = ui.WrapMenu(history.AddSubMenuItem("", ""))
145+
u.menu[hist+strconv.FormatUint(uint64(i), 10)].Disable()
146+
u.menu[hist+strconv.FormatUint(uint64(i), 10)].Hide()
147147
}
148148
}
149149

@@ -227,7 +227,7 @@ func (u *Unpackerr) checkForUpdate() {
227227
update, err := update.Check("Unpackerr/unpackerr", version.Version)
228228
if err != nil {
229229
u.Errorf("Update Check: %v", err)
230-
_, _ = ui.Error("Unpackerr", "Failure checking version on GitHub: "+err.Error())
230+
_, _ = ui.Error("Unpackerr", "Failure checking version on GitHub: %v", err)
231231

232232
return
233233
}

pkg/unpackerr/webhook.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ func (statuses *ExtractStatuses) UnmarshalENV(tag, envval string) error {
7878
return nil
7979
}
8080

81-
func (statuses ExtractStatuses) MarshalENV(tag string) (map[string]string, error) {
82-
vals := make([]string, len(statuses))
81+
func (statuses *ExtractStatuses) MarshalENV(tag string) (map[string]string, error) {
82+
vals := make([]string, len(*statuses))
8383

84-
for idx, status := range statuses {
84+
for idx, status := range *statuses {
8585
vals[idx] = status.String()
8686
}
8787

pkg/unpackerr/webserver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (u *Unpackerr) runWebServer() {
113113
err = u.Webserver.server.ListenAndServe()
114114
}
115115

116-
if err != nil && !errors.Is(http.ErrServerClosed, err) {
116+
if err != nil && !errors.Is(err, http.ErrServerClosed) {
117117
u.Errorf("Web Server Failed: %v", err)
118118
}
119119
}

0 commit comments

Comments
 (0)