You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our current .golangci.yml is outdated. Originally it is based on golden gist which has multiple of new rules added.
I've tried updating rules from the new one and got the following log of possible improvements (note: nonamedreturns rule is disabled):
batch.go:138:4: avoid allocations with (*bytes.Buffer).WriteString (mirror)
buff.Write([]byte("\n"))
^
audio_test.go:89:14: avoid allocations with bytes.NewBufferString (mirror)
Reader: bytes.NewBuffer([]byte(`wav test contents`)),
^
client.go:95:19: non-canonical header "OpenAI-Beta", instead use: "Openai-Beta" (canonicalheader)
args.header.Set("OpenAI-Beta", fmt.Sprintf("assistants=%s", version))
^
client.go:187:18: const "AzureAPIKeyHeader" used as a key at http.Header, but "api-key" is not canonical, want "Api-Key" (canonicalheader)
req.Header.Set(AzureAPIKeyHeader, c.config.authToken)
^
client.go:193:18: non-canonical header "OpenAI-Organization", instead use: "Openai-Organization" (canonicalheader)
req.Header.Set("OpenAI-Organization", c.config.OrgID)
^
ratelimit.go:31:36: non-canonical header "x-ratelimit-limit-requests", instead use: "X-Ratelimit-Limit-Requests" (canonicalheader)
limitReq, _ := strconv.Atoi(h.Get("x-ratelimit-limit-requests"))
^
ratelimit.go:32:39: non-canonical header "x-ratelimit-limit-tokens", instead use: "X-Ratelimit-Limit-Tokens" (canonicalheader)
limitTokens, _ := strconv.Atoi(h.Get("x-ratelimit-limit-tokens"))
^
ratelimit.go:33:40: non-canonical header "x-ratelimit-remaining-requests", instead use: "X-Ratelimit-Remaining-Requests" (canonicalheader)
remainingReq, _ := strconv.Atoi(h.Get("x-ratelimit-remaining-requests"))
^
ratelimit.go:34:43: non-canonical header "x-ratelimit-remaining-tokens", instead use: "X-Ratelimit-Remaining-Tokens" (canonicalheader)
remainingTokens, _ := strconv.Atoi(h.Get("x-ratelimit-remaining-tokens"))
^
ratelimit.go:40:38: non-canonical header "x-ratelimit-reset-requests", instead use: "X-Ratelimit-Reset-Requests" (canonicalheader)
ResetRequests: ResetTime(h.Get("x-ratelimit-reset-requests")),
^
ratelimit.go:41:38: non-canonical header "x-ratelimit-reset-tokens", instead use: "X-Ratelimit-Reset-Tokens" (canonicalheader)
ResetTokens: ResetTime(h.Get("x-ratelimit-reset-tokens")),
^
client.go:237:5: azureDeploymentsEndpoints is a global variable (gochecknoglobals)
var azureDeploymentsEndpoints = []string{
^
completion.go:99:5: O1SeriesModels is a global variable (gochecknoglobals)
var O1SeriesModels = map[string]struct{}{
^
completion.go:106:5: disabledModelsForEndpoints is a global variable (gochecknoglobals)
var disabledModelsForEndpoints = map[string]map[string]bool{
^
completion.go:183:5: unsupportedToolsForO1Models is a global variable (gochecknoglobals)
var unsupportedToolsForO1Models = map[ToolType]struct{}{
^
completion.go:187:5: availableMessageRoleForO1Models is a global variable (gochecknoglobals)
var availableMessageRoleForO1Models = map[string]struct{}{
^
moderation.go:29:5: validModerationModel is a global variable (gochecknoglobals)
var validModerationModel = map[string]struct{}{
^
stream_reader.go:14:2: headerData is a global variable (gochecknoglobals)
headerData = []byte("data: ")
^
stream_reader.go:15:2: errorPrefix is a global variable (gochecknoglobals)
errorPrefix = []byte(`data: {"error":`)
^
chat.go:158:31: the given struct should be annotated with the `json` tag (musttag)
if err := json.Unmarshal(bs, &msg); err == nil {
^
chat.go:172:31: the given struct should be annotated with the `json` tag (musttag)
if err := json.Unmarshal(bs, &multiMsg); err != nil {
^
assistant.go:142:3: naked return in func `CreateAssistant` with 9 lines of code (nakedret)
return
^
assistant.go:146:2: naked return in func `CreateAssistant` with 9 lines of code (nakedret)
return
^
assistant.go:158:3: naked return in func `RetrieveAssistant` with 13 lines of code (nakedret)
return
^
assistant.go:162:2: naked return in func `RetrieveAssistant` with 13 lines of code (nakedret)
return
^
assistant.go:175:3: naked return in func `ModifyAssistant` with 14 lines of code (nakedret)
return
^
assistant.go:179:2: naked return in func `ModifyAssistant` with 14 lines of code (nakedret)
return
^
assistant.go:191:3: naked return in func `DeleteAssistant` with 13 lines of code (nakedret)
return
^
assistant.go:195:2: naked return in func `DeleteAssistant` with 13 lines of code (nakedret)
return
^
assistant.go:229:3: naked return in func `ListAssistants` with 35 lines of code (nakedret)
return
^
assistant.go:233:2: naked return in func `ListAssistants` with 35 lines of code (nakedret)
return
^
assistant.go:247:3: naked return in func `CreateAssistantFile` with 15 lines of code (nakedret)
return
^
assistant.go:251:2: naked return in func `CreateAssistantFile` with 15 lines of code (nakedret)
return
^
assistant.go:264:3: naked return in func `RetrieveAssistantFile` with 14 lines of code (nakedret)
return
^
assistant.go:268:2: naked return in func `RetrieveAssistantFile` with 14 lines of code (nakedret)
return
^
assistant.go:281:3: naked return in func `DeleteAssistantFile` with 14 lines of code (nakedret)
return
^
assistant.go:285:2: naked return in func `DeleteAssistantFile` with 14 lines of code (nakedret)
return
^
assistant.go:320:3: naked return in func `ListAssistantFiles` with 36 lines of code (nakedret)
return
^
assistant.go:324:2: naked return in func `ListAssistantFiles` with 36 lines of code (nakedret)
return
^
audio.go:146:2: naked return in func `callAudioAPI` with 35 lines of code (nakedret)
return
^
batch.go:122:3: naked return in func `CreateBatch` with 15 lines of code (nakedret)
return
^
batch.go:126:2: naked return in func `CreateBatch` with 15 lines of code (nakedret)
return
^
batch.go:202:3: naked return in func `CreateBatchWithUploadFile` with 18 lines of code (nakedret)
return
^
batch.go:220:3: naked return in func `RetrieveBatch` with 11 lines of code (nakedret)
return
^
batch.go:223:2: naked return in func `RetrieveBatch` with 11 lines of code (nakedret)
return
^
batch.go:234:3: naked return in func `CancelBatch` with 11 lines of code (nakedret)
return
^
batch.go:237:2: naked return in func `CancelBatch` with 11 lines of code (nakedret)
return
^
batch.go:266:3: naked return in func `ListBatch` with 21 lines of code (nakedret)
return
^
batch.go:270:2: naked return in func `ListBatch` with 21 lines of code (nakedret)
return
^
chat.go:384:3: naked return in func `CreateChatCompletion` with 31 lines of code (nakedret)
return
^
chat.go:390:3: naked return in func `CreateChatCompletion` with 31 lines of code (nakedret)
return
^
chat.go:394:3: naked return in func `CreateChatCompletion` with 31 lines of code (nakedret)
return
^
chat.go:404:3: naked return in func `CreateChatCompletion` with 31 lines of code (nakedret)
return
^
chat.go:408:2: naked return in func `CreateChatCompletion` with 31 lines of code (nakedret)
return
^
chat_stream.go:79:3: naked return in func `CreateChatCompletionStream` with 33 lines of code (nakedret)
return
^
chat_stream.go:84:3: naked return in func `CreateChatCompletionStream` with 33 lines of code (nakedret)
return
^
chat_stream.go:99:3: naked return in func `CreateChatCompletionStream` with 33 lines of code (nakedret)
return
^
chat_stream.go:104:2: naked return in func `CreateChatCompletionStream` with 33 lines of code (nakedret)
return
^
client.go:147:3: naked return in func `sendRequestRaw` with 14 lines of code (nakedret)
return
^
client.go:152:3: naked return in func `sendRequestRaw` with 14 lines of code (nakedret)
return
^
client.go:157:2: naked return in func `sendRequestRaw` with 14 lines of code (nakedret)
return
^
completion.go:315:3: naked return in func `CreateCompletion` with 32 lines of code (nakedret)
return
^
completion.go:321:3: naked return in func `CreateCompletion` with 32 lines of code (nakedret)
return
^
completion.go:326:3: naked return in func `CreateCompletion` with 32 lines of code (nakedret)
return
^
completion.go:336:3: naked return in func `CreateCompletion` with 32 lines of code (nakedret)
return
^
completion.go:340:2: naked return in func `CreateCompletion` with 32 lines of code (nakedret)
return
^
edits.go:48:3: naked return in func `Edits` with 13 lines of code (nakedret)
return
^
edits.go:52:2: naked return in func `Edits` with 13 lines of code (nakedret)
return
^
embeddings.go:251:3: naked return in func `CreateEmbeddings` with 28 lines of code (nakedret)
return
^
embeddings.go:256:3: naked return in func `CreateEmbeddings` with 28 lines of code (nakedret)
return
^
embeddings.go:262:3: naked return in func `CreateEmbeddings` with 28 lines of code (nakedret)
return
^
assistant.go:208:26: fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)
urlValues.Add("limit", fmt.Sprintf("%d", *limit))
^
assistant.go:299:26: fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)
urlValues.Add("limit", fmt.Sprintf("%d", *limit))
^
audio.go:124:15: fmt.Sprintf can be replaced with string concatenation (perfsprint)
urlSuffix := fmt.Sprintf("/audio/%s", endpointSuffix)
^
batch.go:253:26: fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)
urlValues.Add("limit", fmt.Sprintf("%d", *limit))
^
client.go:190:35: fmt.Sprintf can be replaced with string concatenation (perfsprint)
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", c.config.authToken))
^
engines.go:44:15: fmt.Sprintf can be replaced with string concatenation (perfsprint)
urlSuffix := fmt.Sprintf("/engines/%s", engineID)
^
files.go:153:15: fmt.Sprintf can be replaced with string concatenation (perfsprint)
urlSuffix := fmt.Sprintf("/files/%s", fileID)
^
fine_tunes.go:144:15: fmt.Sprintf can be replaced with string concatenation (perfsprint)
urlSuffix := fmt.Sprintf("/fine-tunes/%s", fineTuneID)
^
fine_tuning_job.go:91:15: fmt.Sprintf can be replaced with string concatenation (perfsprint)
urlSuffix := fmt.Sprintf("/fine_tuning/jobs/%s", fineTuningJobID)
^
fine_tuning_job.go:140:26: fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)
urlValues.Add("limit", fmt.Sprintf("%d", *parameters.limit))
^
messages.go:108:26: fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)
urlValues.Add("limit", fmt.Sprintf("%d", *limit))
^
models.go:69:15: fmt.Sprintf can be replaced with string concatenation (perfsprint)
urlSuffix := fmt.Sprintf("/models/%s", modelID)
^
run.go:304:26: fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)
urlValues.Add("limit", fmt.Sprintf("%d", *pagination.Limit))
^
run.go:424:26: fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)
urlValues.Add("limit", fmt.Sprintf("%d", *pagination.Limit))
^
vector_store.go:176:26: fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)
urlValues.Add("limit", fmt.Sprintf("%d", *pagination.Limit))
^
vector_store.go:249:26: fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)
urlValues.Add("limit", fmt.Sprintf("%d", *pagination.Limit))
^
vector_store.go:327:26: fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)
urlValues.Add("limit", fmt.Sprintf("%d", *pagination.Limit))
^
audio_test.go:33:19: fmt.Errorf can be replaced with errors.New (perfsprint)
mockFailedErr := fmt.Errorf("mock form builder fail")
^
audio_test.go:75:20: fmt.Errorf can be replaced with errors.New (perfsprint)
mockFailedErr := fmt.Errorf("mock form builder fail")
^
audio_test.go:92:20: fmt.Errorf can be replaced with errors.New (perfsprint)
mockFailedErr := fmt.Errorf("mock form builder fail")
^
files_test.go:30:15: fmt.Errorf can be replaced with errors.New (perfsprint)
mockError := fmt.Errorf("mockWriteField error")
^
files_test.go:37:14: fmt.Errorf can be replaced with errors.New (perfsprint)
mockError = fmt.Errorf("mockCreateFormFile error")
^
files_test.go:47:14: fmt.Errorf can be replaced with errors.New (perfsprint)
mockError = fmt.Errorf("mockClose error")
^
files_test.go:77:15: fmt.Errorf can be replaced with errors.New (perfsprint)
mockError := fmt.Errorf("mockWriteField error")
^
files_test.go:84:14: fmt.Errorf can be replaced with errors.New (perfsprint)
mockError = fmt.Errorf("mockCreateFormFile error")
^
files_test.go:94:14: fmt.Errorf can be replaced with errors.New (perfsprint)
mockError = fmt.Errorf("mockClose error")
^
image_test.go:56:19: fmt.Errorf can be replaced with errors.New (perfsprint)
mockFailedErr := fmt.Errorf("mock form builder fail")
^
image_test.go:121:19: fmt.Errorf can be replaced with errors.New (perfsprint)
mockFailedErr := fmt.Errorf("mock form builder fail")
^
chat.go:94:6: the methods of "ChatCompletionMessage" use pointer receiver and non-pointer receiver. (recvcheck)
type ChatCompletionMessage struct {
^
audio_api_test.go:62:15: avoid allocations with bytes.NewBufferString (mirror)
Reader: bytes.NewBuffer([]byte(`some webm binary data`)),
^
chat_test.go:25:5: rateLimitHeaders is a global variable (gochecknoglobals)
var rateLimitHeaders = map[string]any{
^
messages_test.go:15:5: emptyStr is a global variable (gochecknoglobals)
var emptyStr = ""
^
example_test.go:251:29: fmt.Sprintf can be replaced with string concatenation (perfsprint)
proxyURL, err := url.Parse(fmt.Sprintf("http://localhost:%s", port))
^
example_test.go:17:16: missing output for example, go test can't validate it (testableexamples)
func Example() {
^
example_test.go:332:24: missing output for example, go test can't validate it (testableexamples)
func ExampleAPIError() {
^
example_test.go:248:44: missing output for example, go test can't validate it (testableexamples)
func ExampleClientConfig_clientWithProxy() {
^
example_test.go:39:49: missing output for example, go test can't validate it (testableexamples)
func ExampleClient_CreateChatCompletionStream() {
^
example_test.go:80:39: missing output for example, go test can't validate it (testableexamples)
func ExampleClient_CreateCompletion() {
^
example_test.go:97:45: missing output for example, go test can't validate it (testableexamples)
func ExampleClient_CreateCompletionStream() {
^
example_test.go:190:34: missing output for example, go test can't validate it (testableexamples)
func ExampleClient_CreateImage() {
^
example_test.go:209:41: missing output for example, go test can't validate it (testableexamples)
func ExampleClient_CreateImage_base64() {
^
example_test.go:131:42: missing output for example, go test can't validate it (testableexamples)
func ExampleClient_CreateTranscription() {
^
example_test.go:147:51: missing output for example, go test can't validate it (testableexamples)
func ExampleClient_CreateTranscription_captions() {
^
example_test.go:174:40: missing output for example, go test can't validate it (testableexamples)
func ExampleClient_CreateTranslation() {
^
example_test.go:304:34: missing output for example, go test can't validate it (testableexamples)
func ExampleDefaultAzureConfig() {
^
example_test.go:272:24: missing output for example, go test can't validate it (testableexamples)
func Example_chatbot() {
^
audio_api_test.go:124:17: "POST" can be replaced by http.MethodPost (usestdlibvars)
if r.Method != "POST" {
^
chat_stream_test.go:331:17: "429" can be replaced by http.StatusTooManyRequests (usestdlibvars)
w.WriteHeader(429)
^
chat_test.go:645:17: "POST" can be replaced by http.MethodPost (usestdlibvars)
if r.Method != "POST" {
^
completion_test.go:100:17: "POST" can be replaced by http.MethodPost (usestdlibvars)
if r.Method != "POST" {
^
edits_test.go:45:17: "POST" can be replaced by http.MethodPost (usestdlibvars)
if r.Method != "POST" {
^
files_api_test.go:51:17: "POST" can be replaced by http.MethodPost (usestdlibvars)
if r.Method != "POST" {
^
image_api_test.go:40:17: "POST" can be replaced by http.MethodPost (usestdlibvars)
if r.Method != "POST" {
^
image_api_test.go:150:17: "POST" can be replaced by http.MethodPost (usestdlibvars)
if r.Method != "POST" {
^
image_api_test.go:206:17: "POST" can be replaced by http.MethodPost (usestdlibvars)
if r.Method != "POST" {
^
moderation_test.go:73:17: "POST" can be replaced by http.MethodPost (usestdlibvars)
if r.Method != "POST" {
^
speech_test.go:30:18: "POST" can be replaced by http.MethodPost (usestdlibvars)
if r.Method != "POST" {
^
stream_test.go:156:17: "429" can be replaced by http.StatusTooManyRequests (usestdlibvars)
w.WriteHeader(429)
^
internal/form_builder.go:39:10: fmt.Errorf can be replaced with errors.New (perfsprint)
return fmt.Errorf("filename cannot be empty")
^
internal/test/server.go:39:80: non-canonical header "api-key", instead use: "Api-Key" (canonicalheader)
if r.Header.Get("Authorization") != "Bearer "+GetTestToken() && r.Header.Get("api-key") != GetTestToken() {
^
The text was updated successfully, but these errors were encountered:
Our current .golangci.yml is outdated. Originally it is based on golden gist which has multiple of new rules added.
I've tried updating rules from the new one and got the following log of possible improvements (note:
nonamedreturns
rule is disabled):The text was updated successfully, but these errors were encountered: