Skip to content

Commit e4d06b0

Browse files
julianknutsenclaude
andcommitted
Fix all 104 lint issues and install pre-commit hook
- Configure errcheck to exclude fmt.Fprint* (standard for CLIs) - Fix golangci-lint v2 config format (linters.settings, not linters-settings) - Add doc comments on all exported methods (revive) - Rename unused parameters to _ (revive) - Apply De Morgan's law to hex char checks (staticcheck) - Fix filepath.Join single-arg call (gocritic) - Use errors.As instead of type assertion on error (errorlint) - Remove unused newFakeWLCommonsStore in commons package - Check errcheck on os.Remove, os.RemoveAll, tmpFile.Close, store.Save Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4dac7b2 commit e4d06b0

24 files changed

+65
-41
lines changed

.golangci.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ linters:
1515
- revive
1616
- unconvert
1717
- unparam
18-
19-
linters-settings:
20-
misspell:
21-
locale: US
18+
settings:
19+
errcheck:
20+
# CLI output to stdout/stderr — writes that fail are not recoverable.
21+
exclude-functions:
22+
- fmt.Fprint
23+
- fmt.Fprintf
24+
- fmt.Fprintln
25+
misspell:
26+
locale: US
2227

2328
issues:
2429
# Show all issues, don't limit per-linter.

cmd/wl/cmd_browse.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"errors"
45
"fmt"
56
"io"
67
"os"
@@ -40,7 +41,7 @@ EXAMPLES:
4041
wl browse --priority 0 # Critical priority only
4142
wl browse --limit 5 # Show 5 items
4243
wl browse --json # JSON output`,
43-
RunE: func(cmd *cobra.Command, args []string) error {
44+
RunE: func(_ *cobra.Command, _ []string) error {
4445
return runBrowse(stdout, stderr, project, status, itemType, priority, limit, jsonOut)
4546
},
4647
}
@@ -55,7 +56,7 @@ EXAMPLES:
5556
return cmd
5657
}
5758

58-
func runBrowse(stdout, stderr io.Writer, project, status, itemType string, priority, limit int, jsonOut bool) error {
59+
func runBrowse(stdout, _ io.Writer, project, status, itemType string, priority, limit int, jsonOut bool) error {
5960
doltPath, err := exec.LookPath("dolt")
6061
if err != nil {
6162
return fmt.Errorf("dolt not found in PATH — install from https://docs.dolthub.com/introduction/installation")
@@ -65,7 +66,7 @@ func runBrowse(stdout, stderr io.Writer, project, status, itemType string, prior
6566
if err != nil {
6667
return fmt.Errorf("creating temp directory: %w", err)
6768
}
68-
defer os.RemoveAll(tmpDir)
69+
defer func() { _ = os.RemoveAll(tmpDir) }()
6970

7071
commonsOrg := "hop"
7172
commonsDB := "wl-commons"
@@ -140,7 +141,8 @@ func renderBrowseTable(stdout io.Writer, doltPath, cloneDir, query string) error
140141
sqlCmd.Dir = cloneDir
141142
output, err := sqlCmd.Output()
142143
if err != nil {
143-
if exitErr, ok := err.(*exec.ExitError); ok {
144+
var exitErr *exec.ExitError
145+
if errors.As(err, &exitErr) {
144146
return fmt.Errorf("query failed: %s", string(exitErr.Stderr))
145147
}
146148
return fmt.Errorf("running query: %w", err)

cmd/wl/cmd_claim.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Examples:
3333
}
3434
}
3535

36-
func runClaim(cmd *cobra.Command, stdout, stderr io.Writer, wantedID string) error {
36+
func runClaim(cmd *cobra.Command, stdout, _ io.Writer, wantedID string) error {
3737
wlCfg, err := resolveWasteland(cmd)
3838
if err != nil {
3939
return fmt.Errorf("loading wasteland config: %w", err)

cmd/wl/cmd_done.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Examples:
4545
return cmd
4646
}
4747

48-
func runDone(cmd *cobra.Command, stdout, stderr io.Writer, wantedID, evidence string) error {
48+
func runDone(cmd *cobra.Command, stdout, _ io.Writer, wantedID, evidence string) error {
4949
wlCfg, err := resolveWasteland(cmd)
5050
if err != nil {
5151
return fmt.Errorf("loading wasteland config: %w", err)

cmd/wl/cmd_done_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestGenerateCompletionID_Format(t *testing.T) {
1919
}
2020
hexPart := id[2:]
2121
for _, c := range hexPart {
22-
if !((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) {
22+
if (c < '0' || c > '9') && (c < 'a' || c > 'f') {
2323
t.Errorf("generateCompletionID() contains non-hex char %q in %q", string(c), id)
2424
}
2525
}

cmd/wl/cmd_fake_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (f *fakeWLCommonsStore) ClaimWanted(wantedID, rigHandle string) error {
8686
return nil
8787
}
8888

89-
func (f *fakeWLCommonsStore) SubmitCompletion(completionID, wantedID, rigHandle, evidence string) error {
89+
func (f *fakeWLCommonsStore) SubmitCompletion(_, wantedID, rigHandle, _ string) error {
9090
if f.SubmitCompletionErr != nil {
9191
return f.SubmitCompletionErr
9292
}

cmd/wl/cmd_join.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Examples:
5656
wl join test-org/wl-commons --remote-base /tmp/remotes --fork-org my-fork
5757
wl join test-org/wl-commons --git-remote /tmp/git-remotes --fork-org my-fork`,
5858
Args: cobra.ExactArgs(1),
59-
RunE: func(cmd *cobra.Command, args []string) error {
59+
RunE: func(_ *cobra.Command, args []string) error {
6060
return runJoin(stdout, stderr, args[0], handle, displayName, email, forkOrg, remoteBase, gitRemote)
6161
},
6262
}

cmd/wl/cmd_leave.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Examples:
3636
}
3737
}
3838

39-
func runLeave(cmd *cobra.Command, stdout, stderr io.Writer, positional string) error {
39+
func runLeave(cmd *cobra.Command, stdout, _ io.Writer, positional string) error {
4040
store := federation.NewConfigStore()
4141

4242
// Determine which upstream to leave: positional arg > --wasteland flag > auto.

cmd/wl/cmd_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ for each wasteland.
2121
Examples:
2222
wl list`,
2323
Args: cobra.NoArgs,
24-
RunE: func(cmd *cobra.Command, args []string) error {
24+
RunE: func(_ *cobra.Command, _ []string) error {
2525
return runList(stdout, stderr)
2626
},
2727
}

cmd/wl/cmd_post.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Examples:
3737
wl post --title "Fix auth bug" --project gastown --type bug
3838
wl post --title "Add federation sync" --type feature --priority 1 --effort large
3939
wl post --title "Update docs" --tags "docs,federation" --effort small`,
40-
RunE: func(cmd *cobra.Command, args []string) error {
40+
RunE: func(cmd *cobra.Command, _ []string) error {
4141
return runPost(cmd, stdout, stderr, title, description, project, itemType, priority, effort, tags)
4242
},
4343
}
@@ -55,7 +55,7 @@ Examples:
5555
return cmd
5656
}
5757

58-
func runPost(cmd *cobra.Command, stdout, stderr io.Writer, title, description, project, itemType string, priority int, effort, tags string) error {
58+
func runPost(cmd *cobra.Command, stdout, _ io.Writer, title, description, project, itemType string, priority int, effort, tags string) error {
5959
var tagList []string
6060
if tags != "" {
6161
for _, t := range strings.Split(tags, ",") {

0 commit comments

Comments
 (0)