Skip to content

feat: add .golangci.yml configuration with a curated set of linters#364

Draft
SuperCoolPencil wants to merge 2 commits intomainfrom
lint
Draft

feat: add .golangci.yml configuration with a curated set of linters#364
SuperCoolPencil wants to merge 2 commits intomainfrom
lint

Conversation

@SuperCoolPencil
Copy link
Copy Markdown
Member

@SuperCoolPencil SuperCoolPencil commented Apr 12, 2026

Greptile Summary

This PR introduces a .golangci.yml golangci-lint v2 configuration with a curated set of ~20 linters (correctness, performance, resource safety, and style), and simultaneously fixes all existing violations across 47 files. The fixes are mechanical: fmt.Errorf with static strings → errors.New, direct error equality → errors.Is, string literal HTTP method/status constants → http.Method*/http.Status*, fmt.Sprintf for simple string/int formatting → concatenation or strconv.

Confidence Score: 5/5

Safe to merge — all changes are mechanical linter-driven fixes with no behavioral impact.

All findings are P2 style suggestions (missing EOF newline, auto-generated variable name). No logic changes, no new error paths, no functional regressions introduced.

.golangci.yml (missing trailing newline) and internal/download/manager_test.go (odd auto-generated variable name longNameSb651).

Important Files Changed

Filename Overview
.golangci.yml New golangci-lint v2 config enabling ~20 linters across correctness, performance, resource safety, and style categories; missing trailing newline.
internal/download/manager_test.go Replaced loop-based string concatenation with strings.Builder, but used an auto-generated variable name (longNameSb651); strings.Repeat would be cleaner.
internal/engine/state/state.go Replaced fmt.Errorf static strings with errors.New and == comparisons with errors.Is throughout; all changes are mechanical and correct.
internal/engine/concurrent/downloader.go Switched err != context.Canceled to errors.Is for proper wrapped-error comparison; static error strings moved to errors.New.
internal/processing/pause_resume.go All fmt.Errorf static strings replaced with errors.New; no logic changes.
internal/download/resume_test.go Fixed error comparison to use errors.Is(err, context.Canceled) instead of direct equality, correctly handling wrapped context errors.
cmd/root_http_server.go Replaced string literal HTTP methods with http.Method* constants, strconv.Itoa for port conversion, and errors.New for static errors.
internal/tui/view_settings.go Converted if/else chain to switch statement, replaced fmt.Sprintf integer formatting with strconv.FormatInt; clean mechanical changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[golangci-lint runs on CI] --> B{Linter checks}
    B --> C[correctness\nstaticcheck · govet · errcheck\nunused · ineffassign · errorlint\ncontextcheck · nilerr · makezero]
    B --> D[performance\nprealloc · perfsprint\nusestdlibvars]
    B --> E[resource safety\nbodyclose · noctx · sqlclosecheck\nrowserrcheck · gosec]
    B --> F[style / quality\ngocritic · revive · goconst]
    C --> G[Fixed: errors.New · errors.Is\nhttp.Method* constants]
    D --> H[Fixed: strconv · string concat\nstrings.Builder]
    E --> I[Fixed: bodyclose · noctx patterns]
    F --> J[Fixed: comment spacing\nif→switch · blank lines]
Loading

Comments Outside Diff (1)

  1. internal/download/manager_test.go, line 725-731 (link)

    P2 Auto-generated variable name and unnecessary complexity

    longNameSb651 is a machine-generated name that's hard to read. Additionally, the whole strings.Builder loop can be replaced with the idiomatic strings.Repeat, which is clearer and already in the stdlib per the project's preference for built-in functions.

    (Remove the loop, the strings.Builder variable, and the longName += longNameSb651.String() and longName += ".txt" lines below it.)

    Rule Used: What: Prefer built-in or existing library function... (source)

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: internal/download/manager_test.go
    Line: 725-731
    
    Comment:
    **Auto-generated variable name and unnecessary complexity**
    
    `longNameSb651` is a machine-generated name that's hard to read. Additionally, the whole `strings.Builder` loop can be replaced with the idiomatic `strings.Repeat`, which is clearer and already in the stdlib per the project's preference for built-in functions.
    
    
    (Remove the loop, the `strings.Builder` variable, and the `longName += longNameSb651.String()` and `longName += ".txt"` lines below it.)
    
    **Rule Used:** What: Prefer built-in or existing library function... ([source](https://app.greptile.com/review/custom-context?memory=545c1730-b3a2-4153-a981-7f3f23c2e226))
    
    How can I resolve this? If you propose a fix, please make it concise.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix All With AI
This is a comment left during a code review.
Path: .golangci.yml
Line: 36

Comment:
**Missing newline at end of file**

The file is missing a trailing newline (`\ No newline at end of file` in the diff). This violates POSIX conventions and can cause issues with tools that process the config (e.g., shell scripts, `cat` output, and some CI parsers). Add a newline after the last line.

```suggestion
    - goconst
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: internal/download/manager_test.go
Line: 725-731

Comment:
**Auto-generated variable name and unnecessary complexity**

`longNameSb651` is a machine-generated name that's hard to read. Additionally, the whole `strings.Builder` loop can be replaced with the idiomatic `strings.Repeat`, which is clearer and already in the stdlib per the project's preference for built-in functions.

```suggestion
	longName := strings.Repeat("a", 50) + ".txt"
```
(Remove the loop, the `strings.Builder` variable, and the `longName += longNameSb651.String()` and `longName += ".txt"` lines below it.)

**Rule Used:** What: Prefer built-in or existing library function... ([source](https://app.greptile.com/review/custom-context?memory=545c1730-b3a2-4153-a981-7f3f23c2e226))

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "automatically attempy to fix issues by u..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

@SuperCoolPencil SuperCoolPencil marked this pull request as draft April 12, 2026 07:41
# style / quality
- gocritic
- revive
- goconst No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing newline at end of file

The file is missing a trailing newline (\ No newline at end of file in the diff). This violates POSIX conventions and can cause issues with tools that process the config (e.g., shell scripts, cat output, and some CI parsers). Add a newline after the last line.

Suggested change
- goconst
- goconst
Prompt To Fix With AI
This is a comment left during a code review.
Path: .golangci.yml
Line: 36

Comment:
**Missing newline at end of file**

The file is missing a trailing newline (`\ No newline at end of file` in the diff). This violates POSIX conventions and can cause issues with tools that process the config (e.g., shell scripts, `cat` output, and some CI parsers). Add a newline after the last line.

```suggestion
    - goconst
```

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant