Skip to content

Commit 535bf43

Browse files
Stefan ErnstStefan Ernst
authored andcommitted
Full on linting work, everything reworked
1 parent 39c6196 commit 535bf43

308 files changed

Lines changed: 4547 additions & 4572 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ linters:
2222
settings:
2323
errcheck:
2424
check-type-assertions: true
25-
check-blank: true
25+
check-blank: false
2626
exclude-functions:
2727
- (io.Closer).Close
2828
- (*os.File).Close
2929
- (net.Conn).Close
30+
- (*database/sql.DB).Close
31+
- (*database/sql.Tx).Rollback
32+
- (*database/sql.Rows).Close
33+
- (*database/sql.Result).LastInsertId
34+
- (*database/sql.Result).RowsAffected
3035

3136
govet:
3237
enable-all: true

cmd/ws/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (e *APIError) Error() string {
5151
}
5252

5353
// doRequest executes an HTTP request with authentication
54-
func (c *Client) doRequest(method, path string, body interface{}, result interface{}) error {
54+
func (c *Client) doRequest(method, path string, body, result interface{}) error {
5555
var bodyReader io.Reader
5656
if body != nil {
5757
jsonBody, err := json.Marshal(body)
@@ -75,7 +75,7 @@ func (c *Client) doRequest(method, path string, body interface{}, result interfa
7575
if err != nil {
7676
return fmt.Errorf("request failed: %w", err)
7777
}
78-
defer resp.Body.Close()
78+
defer func() { _ = resp.Body.Close() }()
7979

8080
respBody, err := io.ReadAll(resp.Body)
8181
if err != nil {
@@ -105,12 +105,12 @@ func (c *Client) GET(path string, result interface{}) error {
105105
}
106106

107107
// POST performs a POST request
108-
func (c *Client) POST(path string, body interface{}, result interface{}) error {
108+
func (c *Client) POST(path string, body, result interface{}) error {
109109
return c.doRequest("POST", path, body, result)
110110
}
111111

112112
// PUT performs a PUT request
113-
func (c *Client) PUT(path string, body interface{}, result interface{}) error {
113+
func (c *Client) PUT(path string, body, result interface{}) error {
114114
return c.doRequest("PUT", path, body, result)
115115
}
116116

cmd/ws/config.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010

1111
// Config represents the CLI configuration
1212
type Config struct {
13-
Server ServerConfig `toml:"server"`
14-
Defaults DefaultsConfig `toml:"defaults"`
15-
Cache CacheConfig `toml:"cache"`
16-
StatusAliases map[string]string `toml:"status_aliases"`
13+
Server ServerConfig `toml:"server"`
14+
Defaults DefaultsConfig `toml:"defaults"`
15+
Cache CacheConfig `toml:"cache"`
16+
StatusAliases map[string]string `toml:"status_aliases"`
1717
}
1818

1919
type ServerConfig struct {
@@ -107,27 +107,19 @@ func getGlobalConfigPath() string {
107107
return filepath.Join(home, ".config", "ws", "config.toml")
108108
}
109109

110-
func getGlobalCachePath() string {
111-
home, err := os.UserHomeDir()
112-
if err != nil {
113-
return ""
114-
}
115-
return filepath.Join(home, ".cache", "ws")
116-
}
117-
118110
func saveGlobalConfig(config Config) error {
119111
path := getGlobalConfigPath()
120112
dir := filepath.Dir(path)
121113

122-
if err := os.MkdirAll(dir, 0755); err != nil {
114+
if err := os.MkdirAll(dir, 0o750); err != nil {
123115
return fmt.Errorf("failed to create config directory: %w", err)
124116
}
125117

126118
f, err := os.Create(path)
127119
if err != nil {
128120
return fmt.Errorf("failed to create config file: %w", err)
129121
}
130-
defer f.Close()
122+
defer func() { _ = f.Close() }()
131123

132124
encoder := toml.NewEncoder(f)
133125
return encoder.Encode(config)
@@ -138,7 +130,7 @@ func saveProjectConfig(config Config, path string) error {
138130
if err != nil {
139131
return fmt.Errorf("failed to create config file: %w", err)
140132
}
141-
defer f.Close()
133+
defer func() { _ = f.Close() }()
142134

143135
encoder := toml.NewEncoder(f)
144136
return encoder.Encode(config)

cmd/ws/config_cmd.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Examples:
4040
// Check if config already exists
4141
if _, err := os.Stat(configPath); err == nil {
4242
fmt.Printf("Config already exists at %s. Overwrite? [y/N]: ", configPath)
43-
input, _ := reader.ReadString('\n')
43+
input, _ := reader.ReadString('\n') //nolint:errcheck // interactive user input
4444
input = strings.TrimSpace(strings.ToLower(input))
4545
if input != "y" && input != "yes" {
4646
fmt.Println("Aborted.")
@@ -50,17 +50,17 @@ Examples:
5050

5151
// Prompt for server URL
5252
fmt.Print("Windshift server URL (e.g., https://windshift.example.com): ")
53-
serverURL, _ := reader.ReadString('\n')
53+
serverURL, _ = reader.ReadString('\n') //nolint:errcheck // interactive user input
5454
serverURL = strings.TrimSpace(serverURL)
5555

5656
// Prompt for token
5757
fmt.Print("API token (crw_...): ")
58-
token, _ := reader.ReadString('\n')
58+
token, _ = reader.ReadString('\n') //nolint:errcheck // interactive user input
5959
token = strings.TrimSpace(token)
6060

6161
// Prompt for default workspace (optional)
6262
fmt.Print("Default workspace key (optional, press Enter to skip): ")
63-
workspaceKey, _ := reader.ReadString('\n')
63+
workspaceKey, _ = reader.ReadString('\n') //nolint:errcheck // interactive user input
6464
workspaceKey = strings.TrimSpace(workspaceKey)
6565

6666
newConfig := Config{

cmd/ws/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Examples:
8383
// Generate WINDSHIFT.md
8484
content := generateWindshiftMD(workspace, statuses, itemTypes, transitions)
8585

86-
if err := os.WriteFile("WINDSHIFT.md", []byte(content), 0644); err != nil {
86+
if err := os.WriteFile("WINDSHIFT.md", []byte(content), 0o600); err != nil {
8787
return fmt.Errorf("failed to write WINDSHIFT.md: %w", err)
8888
}
8989
fmt.Println("Created WINDSHIFT.md")
@@ -304,7 +304,7 @@ func updateAgentsFile(filename string) {
304304
// Append Windshift section
305305
addition := "\n\n## Windshift Integration\n\nSee [WINDSHIFT.md](./WINDSHIFT.md) for task management commands.\n"
306306

307-
if err := os.WriteFile(filename, append(content, []byte(addition)...), 0644); err != nil {
307+
if err := os.WriteFile(filename, append(content, []byte(addition)...), 0o600); err != nil {
308308
fmt.Printf("Warning: Could not update %s: %s\n", filename, err)
309309
return
310310
}

cmd/ws/models.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ type User struct {
3838
}
3939

4040
type UserSummary struct {
41-
ID int `json:"id"`
42-
Name string `json:"name,omitempty"`
43-
Email string `json:"email,omitempty"`
44-
Avatar string `json:"avatar,omitempty"`
41+
ID int `json:"id"`
42+
Name string `json:"name,omitempty"`
43+
Email string `json:"email,omitempty"`
44+
Avatar string `json:"avatar,omitempty"`
4545
}
4646

4747
// ============================================

0 commit comments

Comments
 (0)