Skip to content

Commit 8d766fb

Browse files
fix(ci): migrate to golangci-lint v2, fix lint violations
golangci-lint-action >= v7 only supports v2.x. v2 requires: - version: "2" at top of .golangci.yml - gosimple removed (merged into staticcheck in v2) Also fix the 4 issues v2 surfaced: - defer resp.Body.Close() / f.Close(): add //nolint:errcheck (idiomatic Go, errors from deferred closes cannot be meaningfully handled) - pkg/embedding/cohere: lowercase error string (ST1005) Co-authored-by: Ona <no-reply@ona.com>
1 parent e72e2b4 commit 8d766fb

5 files changed

Lines changed: 8 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ jobs:
3939
- name: golangci-lint
4040
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
4141
with:
42-
version: v1.64.8
42+
version: v2.1.6

.golangci.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1+
version: "2"
2+
13
linters:
4+
default: none
25
enable:
36
- errcheck
4-
- gosimple
57
- govet
68
- ineffassign
79
- staticcheck
810
- unused
911

10-
linters-settings:
11-
errcheck:
12-
check-type-assertions: false
13-
check-blank: false
14-
1512
issues:
1613
exclude-rules:
17-
# Test files: allow unchecked errors on t.Log, t.Error etc.
1814
- path: _test\.go
1915
linters:
2016
- errcheck

pkg/embedding/cohere/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type Client struct {
6161
// NewClient creates a new Cohere embedding client.
6262
func NewClient(cfg Config) (*Client, error) {
6363
if cfg.APIKey == "" {
64-
return nil, fmt.Errorf("Cohere API key is required")
64+
return nil, fmt.Errorf("cohere API key is required")
6565
}
6666
if cfg.Model == "" {
6767
cfg.Model = defaultModel
@@ -129,7 +129,7 @@ func (c *Client) EmbedBatch(ctx context.Context, texts []string) ([][]float32, e
129129
if err != nil {
130130
return nil, fmt.Errorf("cohere request: %w", err)
131131
}
132-
defer resp.Body.Close()
132+
defer resp.Body.Close() //nolint:errcheck
133133

134134
if resp.StatusCode == http.StatusTooManyRequests {
135135
return nil, embedding.ErrRateLimited

pkg/embedding/ollama/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (c *Client) Embed(ctx context.Context, text string) ([]float32, error) {
8585
if err != nil {
8686
return nil, fmt.Errorf("ollama request: %w", err)
8787
}
88-
defer resp.Body.Close()
88+
defer resp.Body.Close() //nolint:errcheck
8989

9090
if resp.StatusCode != http.StatusOK {
9191
b, _ := io.ReadAll(resp.Body)

pkg/graph/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func parseGoImports(path string) ([]string, error) {
8080
if err != nil {
8181
return nil, err
8282
}
83-
defer f.Close()
83+
defer f.Close() //nolint:errcheck
8484

8585
var imports []string
8686
scanner := bufio.NewScanner(f)

0 commit comments

Comments
 (0)