Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
868c55d
feat: add .golangci.yml configuration with a curated set of linters
SuperCoolPencil Apr 12, 2026
2c35b3a
automatically attempy to fix issues by using golangci-lint run --fix
SuperCoolPencil Apr 12, 2026
70f42f7
fix(lint): fixed makezero lint issue. we now create struct with a cap…
junaid2005p Apr 13, 2026
8a6b614
fix(lint): fixed contextcheck lint issues
junaid2005p Apr 13, 2026
d5323d0
Merge branch 'main' into lint, resolving signature conflicts in Lifec…
SuperCoolPencil Apr 14, 2026
c8f1469
refactor: replace fmt.Errorf with errors.New for static error messages
SuperCoolPencil Apr 14, 2026
ea6e5ae
perf: optimize slice allocations by pre-allocating capacity in multip…
SuperCoolPencil Apr 14, 2026
c1f80eb
refactor: improve database connection handling in state engine
SuperCoolPencil Apr 14, 2026
42200af
refactor: address linting and security vulnerabilities identified by …
SuperCoolPencil Apr 14, 2026
792e0b0
refactor: address linting, security, and code quality issues identifi…
SuperCoolPencil Apr 14, 2026
39f0a58
feat: implement validation error reporting for settings updates in TU…
SuperCoolPencil Apr 14, 2026
45d8802
update workflow and .golanci.yml
SuperCoolPencil Apr 15, 2026
2ff6865
add settings
SuperCoolPencil Apr 15, 2026
2f91d2f
drop goconst
SuperCoolPencil Apr 15, 2026
267ca1f
more
SuperCoolPencil Apr 15, 2026
cfb6146
golangci-lint new version
SuperCoolPencil Apr 15, 2026
be74225
updoot
SuperCoolPencil Apr 15, 2026
bfa3b84
fix(lint): separated logic for registering http handlers and the actu…
junaid2005p Apr 16, 2026
4a5c8ee
fix(lint): fixed lint issues
junaid2005p Apr 16, 2026
7eb6cec
Merge branch 'main' into lint
SuperCoolPencil Apr 16, 2026
5676f46
golangci-lint run --fix
SuperCoolPencil Apr 16, 2026
1124a55
chore: remove gocognit linter from golangci-lint configuration
SuperCoolPencil Apr 16, 2026
eb5ab54
Merge branch 'main' into lint
SuperCoolPencil Apr 16, 2026
0f63d84
golangci-lint run --fix
SuperCoolPencil Apr 16, 2026
7b5bf21
chore: disable nestif linter in golangci-lint configuration
SuperCoolPencil Apr 16, 2026
0d78137
chore: remove unparam configuration and add linter exclusions for tes…
SuperCoolPencil Apr 16, 2026
6c2da1e
feat: enable dupl linter in golangci-lint configuration
SuperCoolPencil Apr 16, 2026
d8f1ffb
refactor: simplify test helpers and settings reset logic while improv…
SuperCoolPencil Apr 16, 2026
184379c
refactor: optimize log viewport padding, simplify graph scaling, and …
SuperCoolPencil Apr 16, 2026
7d338fb
refactor: propagate context through core engine, download, and TUI me…
SuperCoolPencil Apr 16, 2026
a43a2d7
refactor: pass context to download processing functions and tighten f…
SuperCoolPencil Apr 16, 2026
d6c983f
refactor: propagate context through CLI API calls and clean up lintin…
SuperCoolPencil Apr 16, 2026
adcdda8
chore: add gosec lint suppressions for file operations in engine and …
SuperCoolPencil Apr 16, 2026
625712d
chore: fix linting issues by adding gosec ignores and improving code …
SuperCoolPencil Apr 16, 2026
b3a3a89
refactor: update golangci-lint configuration structure and remove lin…
SuperCoolPencil Apr 16, 2026
ff4aed8
refactor: replace nil with http.NoBody in HTTP requests
SuperCoolPencil Apr 16, 2026
fda7148
refactor: optimize performance and memory usage by passing structs by…
SuperCoolPencil Apr 16, 2026
f5d92a6
refactor: optimize performance by passing structs by pointer and usin…
SuperCoolPencil Apr 16, 2026
0a07357
refactor: change RootModel to a pointer type across TUI components an…
SuperCoolPencil Apr 16, 2026
b975609
refactor: change downloadDelegate methods to use pointer receivers an…
SuperCoolPencil Apr 16, 2026
97978a6
refactor: simplify function signatures by grouping consecutive parame…
SuperCoolPencil Apr 16, 2026
92f8041
refactor: clean up linter annotations and restructure TUI models for …
SuperCoolPencil Apr 17, 2026
e9969bc
go fmt
SuperCoolPencil Apr 17, 2026
84d57f9
refactor: update API endpoint, improve ProgressState struct, and prop…
SuperCoolPencil Apr 17, 2026
592db5f
fix(cli): resolve hang in ambiguous ID resolution and fix infinite re…
SuperCoolPencil Apr 17, 2026
c4eb023
refactor: inject context into system open utilities and command execu…
SuperCoolPencil Apr 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/core-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.25.0'
- name: golangci-lint
run: go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run
go-version-file: go.mod
cache: true

- uses: golangci/golangci-lint-action@v7
with:
version: v2.11.4
67 changes: 67 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# .golangci.yml
version: "2"

run:
tests: true

linters:
default: none
enable:
# correctness
- staticcheck
- govet
- errcheck
- unused
- ineffassign
- makezero
- nilerr
- errorlint
- contextcheck

# performance
- prealloc
- perfsprint
- usestdlibvars

# resource safety
- bodyclose
- noctx
- sqlclosecheck
- rowserrcheck
- gosec

# style / quality
- gocritic
- unparam
# - nestif
- dupword
- dupl

settings:
govet:
enable:
- shadow
- copylocks
- unusedresult

gosec:
excludes:
- G304

gocritic:
enabled-tags:
- performance
- diagnostic
- style

errorlint:
asserts: true

exclusions:
rules:
# Disable specific linters just for test files
- path: _test\.go
linters:
- gosec # Tests often have hardcoded credentials or weak rand sources
- errcheck # (Optional) If you don't care about unhandled errors in test setup
- dupl # If you enable the dupl linter later, table-driven tests often trigger it
9 changes: 5 additions & 4 deletions cmd/add.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"

"github.com/SurgeDM/Surge/internal/utils"
Expand All @@ -13,7 +14,7 @@ var addCmd = &cobra.Command{
Short: "Add a new download to the running Surge instance",
Long: `Add one or more URLs to the download queue of a running Surge instance.`,
RunE: func(cmd *cobra.Command, args []string) error {
//initializeGlobally is required to ensure that the config and logger are set up before we attempt to resolve the API connection or read the batch file.
// initializeGlobally is required to ensure that the config and logger are set up before we attempt to resolve the API connection or read the batch file.
if err := initializeGlobalState(); err != nil {
return err
}
Expand Down Expand Up @@ -53,7 +54,7 @@ var addCmd = &cobra.Command{
continue
}
attempted++
if err := sendToServer(url, mirrors, resolvedOutput, baseURL, token); err != nil {
if err := sendToServer(cmd.Context(), url, mirrors, resolvedOutput, baseURL, token); err != nil {
fmt.Printf("Error adding %s: %v\n", url, err)
continue
}
Expand All @@ -66,10 +67,10 @@ var addCmd = &cobra.Command{
}

if attempted > 0 {
return fmt.Errorf("failed to add any downloads")
return errors.New("failed to add any downloads")
}

return fmt.Errorf("no valid URLs to add")
return errors.New("no valid URLs to add")
},
}

Expand Down
9 changes: 5 additions & 4 deletions cmd/autoresume_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"context"
"encoding/json"
"os"
"path/filepath"
Expand Down Expand Up @@ -34,7 +35,7 @@ func TestCmd_AutoResume_Execution(t *testing.T) {
}()

surgeDir := config.GetSurgeDir()
if err := os.MkdirAll(surgeDir, 0o755); err != nil {
if err := os.MkdirAll(surgeDir, 0o750); err != nil {
t.Fatal(err)
}

Expand All @@ -45,14 +46,14 @@ func TestCmd_AutoResume_Execution(t *testing.T) {
settings.General.DefaultDownloadDir = tmpDir

data, _ := json.Marshal(settings)
if err := os.WriteFile(settingsPath, data, 0o644); err != nil {
if err := os.WriteFile(settingsPath, data, 0o600); err != nil {
t.Fatal(err)
}

// 3. Configure State DB
state.CloseDB() // Ensure clean state
dbPath := filepath.Join(surgeDir, "state", "surge.db")
if err := os.MkdirAll(filepath.Dir(dbPath), 0o755); err != nil {
if err := os.MkdirAll(filepath.Dir(dbPath), 0o750); err != nil {
t.Fatal(err)
}
state.Configure(dbPath)
Expand All @@ -72,7 +73,7 @@ func TestCmd_AutoResume_Execution(t *testing.T) {
PausedAt: time.Now().Unix(),
CreatedAt: time.Now().Unix(),
}
if err := state.SaveState(testURL, testDest, manualState); err != nil {
if err := state.SaveState(context.Background(), testURL, testDest, manualState); err != nil {
t.Fatal(err)
}

Expand Down
Loading
Loading