Skip to content

Commit

Permalink
Merge pull request #503 from Unpackerr/unstable
Browse files Browse the repository at this point in the history
Update linter, fix some bugs
  • Loading branch information
davidnewhall authored Nov 22, 2024
2 parents 7b21608 + f913f10 commit 0e05c0c
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codetests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: 'v1.59'
version: 'v1.62'

golangci-linux:
# description: "Runs golangci-lint on linux against linux and windows."
Expand All @@ -60,4 +60,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: 'v1.59'
version: 'v1.62'
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ linters:
enable-all: true
disable:
# deprecated
- execinquery
- gomnd
- exportloopref
# unused
- exhaustruct
- exhaustive
Expand Down
2 changes: 1 addition & 1 deletion examples/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ services:
- UN_CMDHOOK_0_EXCLUDE_1=lidarr
- UN_CMDHOOK_0_TIMEOUT=10s

## => Content Auto Generated, 02 AUG 2024 22:38 UTC
## => Content Auto Generated, 15 NOV 2024 21:29 UTC
2 changes: 1 addition & 1 deletion examples/unpackerr.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,4 @@ dir_mode = "0755"
## You can adjust how long to wait for the command to run.
# timeout = "10s"

## => Content Auto Generated, 02 AUG 2024 22:38 UTC
## => Content Auto Generated, 15 NOV 2024 21:29 UTC
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func main() {
}()

if err := unpackerr.Start(); err != nil {
_, _ = ui.Error("Unpackerr Error", err.Error())
_, _ = ui.Error("Unpackerr Error", "%v", err)
log.Fatalln("[ERROR]", err) //nolint:gocritic
}
}
6 changes: 3 additions & 3 deletions pkg/ui/dlgs_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ func Warning(_, _ string) (bool, error) {
}

// Error wraps dlgs.Error.
func Error(_, _ string) (bool, error) {
func Error(_, _ string, _ any) (bool, error) {
return true, nil
}

// Info wraps dlgs.Info.
func Info(_, _ string) (bool, error) {
func Info(_, _ string, _ any) (bool, error) {
return true, nil
}

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

// Question wraps dlgs.Question.
func Question(_, _ string, _ bool) (bool, error) {
func Question(_ string, _ bool, _ string, _ any) (bool, error) {
return true, nil
}
4 changes: 2 additions & 2 deletions pkg/unpackerr/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ func (slice *StringSlice) UnmarshalENV(_, envval string) error {
return nil
}

func (slice StringSlice) MarshalENV(tag string) (map[string]string, error) {
return map[string]string{tag: strings.Join(slice, ",")}, nil
func (slice *StringSlice) MarshalENV(tag string) (map[string]string, error) {
return map[string]string{tag: strings.Join(*slice, ",")}, nil
}

func buildStatusReason(status string, messages []*starr.StatusMessage) string {
Expand Down
1 change: 1 addition & 0 deletions pkg/unpackerr/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func (u *Unpackerr) logCurrentQueue(now time.Time) {
len(u.folders.Events)+len(u.updates)+len(u.folders.Updates), len(u.hookChan), len(u.delChan),
durafmt.Parse(now.Sub(version.Started)).LimitFirstN(3).Format(durafmtUnits)) //nolint:mnd

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

Expand Down
4 changes: 3 additions & 1 deletion pkg/unpackerr/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ func New() *Unpackerr {
}

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

Expand All @@ -146,7 +148,7 @@ func Start() error {
unpackerr.Printf("Unpackerr v%s-%s Starting! PID: %v, UID: %d, GID: %d, Umask: %d, Now: %v",
version.Version, version.Revision, os.Getpid(),
os.Getuid(), os.Getgid(), getUmask(), version.Started.Round(time.Second))
unpackerr.Debugf(strings.Join(strings.Fields(strings.ReplaceAll(version.Print("unpackerr"), "\n", ", ")), " "))
unpackerr.Debugf("%s", strings.Join(strings.Fields(strings.ReplaceAll(version.Print("unpackerr"), "\n", ", ")), " "))
// Parse filepath: strings from the config and read in extra config files.
output, err := cnfgfile.Parse(unpackerr.Config, &cnfgfile.Opts{
Name: "Unpackerr",
Expand Down
10 changes: 5 additions & 5 deletions pkg/unpackerr/tray.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ func (u *Unpackerr) makeHistoryChannels() {
u.menu[histNone].SetTooltip("history is disabled in the config")
}

for i := range int(u.KeepHistory) {
u.menu[hist+strconv.Itoa(i)] = ui.WrapMenu(history.AddSubMenuItem("", ""))
u.menu[hist+strconv.Itoa(i)].Disable()
u.menu[hist+strconv.Itoa(i)].Hide()
for i := range u.KeepHistory {
u.menu[hist+strconv.FormatUint(uint64(i), 10)] = ui.WrapMenu(history.AddSubMenuItem("", ""))
u.menu[hist+strconv.FormatUint(uint64(i), 10)].Disable()
u.menu[hist+strconv.FormatUint(uint64(i), 10)].Hide()
}
}

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

return
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/unpackerr/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ func (statuses *ExtractStatuses) UnmarshalENV(tag, envval string) error {
return nil
}

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

for idx, status := range statuses {
for idx, status := range *statuses {
vals[idx] = status.String()
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/unpackerr/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (u *Unpackerr) runWebServer() {
err = u.Webserver.server.ListenAndServe()
}

if err != nil && !errors.Is(http.ErrServerClosed, err) {
if err != nil && !errors.Is(err, http.ErrServerClosed) {
u.Errorf("Web Server Failed: %v", err)
}
}
Expand Down

0 comments on commit 0e05c0c

Please sign in to comment.