Skip to content

Commit a14625e

Browse files
committed
fix: satisfy golangci checks
1 parent e2063bd commit a14625e

File tree

7 files changed

+18
-9
lines changed

7 files changed

+18
-9
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ jobs:
5656
- name: Build frontend assets
5757
run: make build-frontend
5858

59+
- name: Install golangci-lint v2
60+
run: |
61+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(go env GOPATH)/bin" v2.4.0
62+
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
63+
5964
- name: Lint
60-
uses: golangci/golangci-lint-action@v4
61-
with:
62-
version: v2.4.0
63-
args: --timeout=10m
65+
run: golangci-lint run --timeout=10m
6466

6567
- name: Security check with gosec
6668
run: |

.github/workflows/verify.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- name: Install golangci-lint v2
2222
run: |
2323
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(go env GOPATH)/bin" v2.4.0
24+
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
2425
2526
- name: Run verification task
2627
run: make verify

pkg/ai/engine.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ type aiEngine struct {
9999
manager *Manager
100100
}
101101

102-
// NewEngine creates a new AI engine based on configuration
103-
102+
// NewEngine creates a new AI engine based on configuration.
104103
func NewEngine(cfg config.AIConfig) (Engine, error) {
105104
manager, err := NewAIManager(cfg)
106105
if err != nil {
@@ -156,6 +155,7 @@ func newEngineFromManager(manager *Manager, cfg config.AIConfig) (Engine, error)
156155
}, nil
157156
}
158157

158+
// NewEngineWithManager constructs an Engine using a pre-configured Manager.
159159
func NewEngineWithManager(manager *Manager, cfg config.AIConfig) (Engine, error) {
160160
if manager == nil {
161161
return nil, fmt.Errorf("manager cannot be nil")

pkg/ai/generator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ func (g *SQLGenerator) getOrCreateRuntimeClient(options *GenerateOptions) (inter
676676
return client, false, nil
677677
}
678678

679+
// Close releases all cached runtime clients held by the generator.
679680
func (g *SQLGenerator) Close() {
680681
g.runtimeMu.Lock()
681682
defer g.runtimeMu.Unlock()

pkg/ai/providers/openai/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"time"
2626

2727
"github.com/linuxsuren/atest-ext-ai/pkg/interfaces"
28+
"github.com/linuxsuren/atest-ext-ai/pkg/logging"
2829
"github.com/tmc/langchaingo/llms"
2930
"github.com/tmc/langchaingo/llms/openai"
3031
)
@@ -289,7 +290,11 @@ func (c *Client) HealthCheck(ctx context.Context) (*interfaces.HealthStatus, err
289290
status.Errors = []string{err.Error()}
290291
return status, nil
291292
}
292-
defer resp.Body.Close()
293+
defer func() {
294+
if cerr := resp.Body.Close(); cerr != nil {
295+
logging.Logger.Warn("Failed to close OpenAI health check response body", "error", cerr)
296+
}
297+
}()
293298

294299
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
295300
status.Healthy = true

pkg/ai/providers/openai/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestHealthCheckSuccess(t *testing.T) {
3434
}
3535

3636
func TestHealthCheckFailure(t *testing.T) {
37-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
37+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
3838
w.WriteHeader(http.StatusServiceUnavailable)
3939
}))
4040
t.Cleanup(server.Close)

pkg/plugin/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ func (s *AIPluginService) handleTestConnection(ctx context.Context, req *server.
12581258
}
12591259

12601260
// handleUpdateConfig updates the configuration for a provider
1261-
func (s *AIPluginService) handleUpdateConfig(ctx context.Context, req *server.DataQuery) (*server.DataQueryResult, error) {
1261+
func (s *AIPluginService) handleUpdateConfig(_ context.Context, req *server.DataQuery) (*server.DataQueryResult, error) {
12621262
logging.Logger.Debug("Handling update config request", "sql_length", len(req.Sql))
12631263

12641264
// Parse update request from SQL field

0 commit comments

Comments
 (0)