Skip to content

Commit 4d7ae99

Browse files
authored
Merge pull request #1627 from dgageot/linters
Enable more linters and fix existing issues
2 parents 5e67c9b + d764543 commit 4d7ae99

34 files changed

Lines changed: 112 additions & 52 deletions

File tree

.golangci.yml

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,62 @@ run:
33
tests: true
44
linters:
55
enable:
6+
- asasalint
7+
- asciicheck
8+
- bidichk
69
- containedctx
710
- copyloopvar
11+
- decorder
812
- depguard
13+
- dogsled
14+
- durationcheck
915
- errcheck
16+
- errname
17+
- errorlint
18+
- exptostd
19+
- fatcontext
20+
- forbidigo
1021
- ginkgolinter
22+
- gocheckcompilerdirectives
23+
- gochecknoinits
24+
- gochecksumtype
1125
- gocritic
26+
- gomoddirectives
27+
- gomodguard
28+
- goprintffuncname
1229
- govet
30+
- grouper
31+
- iface
1332
- importas # Enforces consistent import aliases.
33+
- inamedparam
1434
- ineffassign
1535
- intrange
36+
- iotamixing
37+
- loggercheck
1638
- misspell
39+
- mirror
1740
- nakedret
1841
- nolintlint
42+
- nosprintfhostport
43+
- nilnesserr
44+
- predeclared
45+
- reassign
46+
- recvcheck
1947
- revive
48+
- rowserrcheck
49+
- sloglint
2050
- staticcheck
51+
- testableexamples
2152
- testifylint
2253
- thelper
2354
- unconvert
2455
- unparam
2556
- unused
2657
- usestdlibvars
27-
- forbidigo
28-
- iotamixing
29-
- gochecknoinits
58+
- unqueryvet
59+
- usetesting
60+
- whitespace
61+
- wastedassign
3062
settings:
3163
forbidigo:
3264
forbid:
@@ -63,6 +95,9 @@ linters:
6395
deny:
6496
- pkg: github.com/stretchr/testify
6597
desc: don't use testify in production code
98+
gomoddirectives:
99+
replace-allow-list:
100+
- github.com/charmbracelet/ultraviolet
66101
gocritic:
67102
disabled-checks:
68103
- dupImport

cmd/root/run.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package root
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"io"
78
"log/slog"
@@ -422,7 +423,8 @@ func (f *runExecFlags) handleExecMode(ctx context.Context, out *cli.Printer, rt
422423
OutputJSON: f.outputJSON,
423424
AutoApprove: f.autoApprove,
424425
}, rt, sess, execArgs)
425-
if cliErr, ok := err.(cli.RuntimeError); ok {
426+
var cliErr cli.RuntimeError
427+
if errors.As(err, &cliErr) {
426428
return RuntimeError{Err: cliErr.Err}
427429
}
428430
return err

pkg/app/transcript/transcript.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func toJSONString(builder *strings.Builder, in string) {
8787
if err := json.Unmarshal([]byte(in), &content); err == nil {
8888
if formatted, err := json.MarshalIndent(content, "", " "); err == nil {
8989
builder.WriteString("```json\n")
90-
builder.WriteString(string(formatted))
90+
builder.Write(formatted)
9191
builder.WriteString("\n```\n")
9292
} else {
9393
builder.WriteString(in)

pkg/config/auto.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ var cloudProviders = []providerConfig{
3232
}, "AWS_ACCESS_KEY_ID (or AWS_PROFILE, AWS_ROLE_ARN, AWS_BEARER_TOKEN_BEDROCK)"},
3333
}
3434

35-
// ErrAutoModelFallback is returned when auto model selection fails because
35+
// AutoModelFallbackError is returned when auto model selection fails because
3636
// no providers are available (no API keys configured and DMR not installed).
37-
type ErrAutoModelFallback struct{}
37+
type AutoModelFallbackError struct{}
3838

39-
func (e *ErrAutoModelFallback) Error() string {
39+
func (e *AutoModelFallbackError) Error() string {
4040
var hints []string
4141
for _, p := range cloudProviders {
4242
hints = append(hints, fmt.Sprintf(" - %s: %s", p.name, p.hint))

pkg/config/config_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ func TestCheckRequiredEnvVars(t *testing.T) {
271271
require.NoError(t, err)
272272
} else {
273273
require.Error(t, err)
274-
assert.Equal(t, test.expectedMissing, err.(*environment.RequiredEnvError).Missing)
274+
var reqErr *environment.RequiredEnvError
275+
require.ErrorAs(t, err, &reqErr)
276+
assert.Equal(t, test.expectedMissing, reqErr.Missing)
275277
}
276278
})
277279
}

pkg/config/latest/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ type SandboxConfig struct {
484484
// DeferConfig represents the deferred loading configuration for a toolset.
485485
// It can be either a boolean (true to defer all tools) or a slice of strings
486486
// (list of tool names to defer).
487-
type DeferConfig struct {
487+
type DeferConfig struct { //nolint:recvcheck // MarshalYAML must use value receiver for YAML slice encoding, UnmarshalYAML must use pointer
488488
// DeferAll is true when all tools should be deferred
489489
DeferAll bool `json:"-"`
490490
// Tools is the list of specific tool names to defer (empty if DeferAll is true)
@@ -635,7 +635,7 @@ func (c *RAGConfig) GetRespectVCS() bool {
635635

636636
// RAGStrategyConfig represents a single retrieval strategy configuration
637637
// Strategy-specific fields are stored in Params (validated by strategy implementation)
638-
type RAGStrategyConfig struct {
638+
type RAGStrategyConfig struct { //nolint:recvcheck // Marshal methods must use value receiver for YAML/JSON slice encoding, Unmarshal must use pointer
639639
Type string `json:"type"` // Strategy type: "chunked-embeddings", "bm25", etc.
640640
Docs []string `json:"docs,omitempty"` // Strategy-specific documents (augments shared docs)
641641
Database RAGDatabaseConfig `json:"database,omitempty"` // Database configuration

pkg/config/types/commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (c *Commands) UnmarshalYAML(unmarshal func(any) error) error {
112112

113113
// parseCommandValue parses a command value which can be either:
114114
// - a simple string (becomes the instruction)
115-
// - a map with description/instruction fields
115+
// - a map with description/instruction fields.
116116
func parseCommandValue(v any) (Command, error) {
117117
switch val := v.(type) {
118118
case string:

pkg/config/v0/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
const Version = "0"
1010

11-
// Toolset represents a tool configuration
11+
// Toolset represents a tool configuration.
1212
type Toolset struct {
1313
Type string `json:"type,omitempty" yaml:"type,omitempty"`
1414
Command string `json:"command,omitempty" yaml:"command,omitempty"`
@@ -25,7 +25,7 @@ type Remote struct {
2525
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`
2626
}
2727

28-
// Ensure that either Command or Remote is set, but not both empty
28+
// Ensure that either Command or Remote is set, but not both empty.
2929
func (t *Toolset) validate() error {
3030
if t.Type != "mcp" {
3131
return nil

pkg/config/v2/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ type RAGConfig struct {
251251

252252
// RAGStrategyConfig represents a single retrieval strategy configuration
253253
// Strategy-specific fields are stored in Params (validated by strategy implementation)
254-
type RAGStrategyConfig struct {
254+
type RAGStrategyConfig struct { //nolint:recvcheck // Marshal methods must use value receiver for YAML/JSON slice encoding, Unmarshal must use pointer
255255
Type string `json:"type"` // Strategy type: "chunked-embeddings", "bm25", etc.
256256
Docs []string `json:"docs,omitempty"` // Strategy-specific documents (augments shared docs)
257257
Database RAGDatabaseConfig `json:"database,omitempty"` // Database configuration

pkg/config/v3/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ type SandboxConfig struct {
230230
// DeferConfig represents the deferred loading configuration for a toolset.
231231
// It can be either a boolean (true to defer all tools) or a slice of strings
232232
// (list of tool names to defer).
233-
type DeferConfig struct {
233+
type DeferConfig struct { //nolint:recvcheck // MarshalYAML must use value receiver for YAML slice encoding, UnmarshalYAML must use pointer
234234
// DeferAll is true when all tools should be deferred
235235
DeferAll bool `json:"-"`
236236
// Tools is the list of specific tool names to defer (empty if DeferAll is true)
@@ -381,7 +381,7 @@ func (c *RAGConfig) GetRespectVCS() bool {
381381

382382
// RAGStrategyConfig represents a single retrieval strategy configuration
383383
// Strategy-specific fields are stored in Params (validated by strategy implementation)
384-
type RAGStrategyConfig struct {
384+
type RAGStrategyConfig struct { //nolint:recvcheck // Marshal methods must use value receiver for YAML/JSON slice encoding, Unmarshal must use pointer
385385
Type string `json:"type"` // Strategy type: "chunked-embeddings", "bm25", etc.
386386
Docs []string `json:"docs,omitempty"` // Strategy-specific documents (augments shared docs)
387387
Database RAGDatabaseConfig `json:"database,omitempty"` // Database configuration

0 commit comments

Comments
 (0)