Skip to content

golangci-lint errors #2550

@chmouel

Description

@chmouel
Linting go files...
pkg/pipelinerunmetrics/injection.go:81:35: G118: context cancellation function returned by WithCancel/WithTimeout/WithDeadline is not called (gosec)
        ctx, cancel := context.WithCancel(ri.ctx)
                                         ^
pkg/adapter/incoming_test.go:836:30: net/http/httptest.NewRequest must not be called. use net/http/httptest.NewRequestWithContext (noctx)
                        req := httptest.NewRequest(tt.args.method,
                                                  ^
pkg/adapter/incoming_test.go:1124:28: net/http/httptest.NewRequest must not be called. use net/http/httptest.NewRequestWithContext (noctx)
                        req: httptest.NewRequest(http.MethodPost,
                                                ^
pkg/adapter/incoming_test.go:1140:29: net/http/httptest.NewRequest must not be called. use net/http/httptest.NewRequestWithContext (noctx)
                                r := httptest.NewRequest(http.MethodPost,
                                                        ^
pkg/adapter/incoming_test.go:1222:28: net/http/httptest.NewRequest must not be called. use net/http/httptest.NewRequestWithContext (noctx)
        req := httptest.NewRequest(http.MethodPost,
                                  ^
pkg/adapter/incoming_test.go:1326:30: net/http/httptest.NewRequest must not be called. use net/http/httptest.NewRequestWithContext (noctx)
                        req := httptest.NewRequest(tt.method, tt.url, strings.NewReader(tt.body))
                                                  ^
pkg/provider/github/app/token_test.go:147:45: net/http/httptest.NewRequest must not be called. use net/http/httptest.NewRequestWithContext (noctx)
                        ip := NewInstallation(httptest.NewRequest(http.MethodGet, "http://localhost", strings.NewReader("")), run, &v1alpha1.Repository{}, &github.Provider{}, tt.namespace.GetName())
                                                                 ^
pkg/provider/github/app/token_test.go:209:43: net/http/httptest.NewRequest must not be called. use net/http/httptest.NewRequestWithContext (noctx)
        ip := NewInstallation(httptest.NewRequest(http.MethodGet, "http://localhost", strings.NewReader("")), run, &v1alpha1.Repository{}, &github.Provider{}, testNamespace.GetName())
                                                 ^
pkg/provider/github/app/token_test.go:212:28: net/http/httptest.NewRequest must not be called. use net/http/httptest.NewRequestWithContext (noctx)
        req := httptest.NewRequest(http.MethodGet, "http://localhost", strings.NewReader(""))
                                  ^
pkg/provider/github/app/token_test.go:396:45: net/http/httptest.NewRequest must not be called. use net/http/httptest.NewRequestWithContext (noctx)
                        ip := NewInstallation(httptest.NewRequest(http.MethodGet, "http://localhost", strings.NewReader("")), run, &v1alpha1.Repository{}, &github.Provider{}, testNamespace.GetName())
                                                                 ^
pkg/provider/github/app/token_test.go:415:44: net/http/httptest.NewRequest must not be called. use net/http/httptest.NewRequestWithContext (noctx)
                        ip = NewInstallation(httptest.NewRequest(http.MethodGet, "http://localhost", strings.NewReader("")), run, repo, gprovider, testNamespace.GetName())
                                                                ^
pkg/provider/github/github.go:900:2: Consider preallocating baseFields with capacity 18 + len(kv) (prealloc)
        baseFields := []any{
        ^
12 issues:
* gosec: 1
* noctx: 10
* prealloc: 1
make: *** [Makefile:98: lint-go] Error 1

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions