Skip to content

Commit 66d623d

Browse files
authored
style: refactor codebase and update linting rules (#169)
- Remove linters `gochecknoinits` and `lll` from the `.golangci.yml` configuration - Correct the case of the `WithApiVersion` function to `WithAPIVersion` in `openai.go` and `options.go` - Suppress the `gochecknoinits` lint warning in `init` functions in `hook.go` and `prompt.go` - Suppress the `gosec` lint warning for `InsecureSkipVerify` in `openai.go` Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
1 parent 3197819 commit 66d623d

File tree

6 files changed

+6
-8
lines changed

6 files changed

+6
-8
lines changed

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ linters:
99
- errcheck
1010
- exportloopref
1111
- exhaustive
12-
- gochecknoinits
1312
- goconst
1413
- gocritic
1514
- gocyclo
@@ -20,7 +19,6 @@ linters:
2019
- gosimple
2120
- govet
2221
- ineffassign
23-
- lll
2422
- misspell
2523
- nakedret
2624
- noctx

cmd/openai.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func NewOpenAI() (*openai.Client, error) {
2020
openai.WithProvider(viper.GetString("openai.provider")),
2121
openai.WithSkipVerify(viper.GetBool("openai.skip_verify")),
2222
openai.WithHeaders(viper.GetStringSlice("openai.headers")),
23-
openai.WithApiVersion(viper.GetString("openai.api_version")),
23+
openai.WithAPIVersion(viper.GetString("openai.api_version")),
2424
openai.WithTopP(float32(viper.GetFloat64("openai.top_p"))),
2525
openai.WithFrequencyPenalty(float32(viper.GetFloat64("openai.frequency_penalty"))),
2626
openai.WithPresencePenalty(float32(viper.GetFloat64("openai.presence_penalty"))),

git/hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const (
1515
CommitMessageTemplate = "commit-msg.tmpl"
1616
)
1717

18-
func init() {
18+
func init() { //nolint:gochecknoinits
1919
if err := util.LoadTemplates(files); err != nil {
2020
log.Fatal(err)
2121
}

openai/openai.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func New(opts ...Option) (*Client, error) {
152152
// Create a new HTTP transport.
153153
tr := &http.Transport{}
154154
if cfg.skipVerify {
155-
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
155+
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} //nolint:gosec
156156
}
157157

158158
// Create a new HTTP client with the specified timeout and proxy, if any.

openai/options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ func WithHeaders(headers []string) Option {
160160
})
161161
}
162162

163-
// WithApiVersion returns a new Option that sets the apiVersion for OpenAI Model.
164-
func WithApiVersion(apiVersion string) Option {
163+
// WithAPIVersion returns a new Option that sets the apiVersion for OpenAI Model.
164+
func WithAPIVersion(apiVersion string) Option {
165165
return optionFunc(func(c *config) {
166166
c.apiVersion = apiVersion
167167
})

prompt/prompt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323
)
2424

2525
// Initializes the prompt package by loading the templates from the embedded file system.
26-
func init() {
26+
func init() { //nolint:gochecknoinits
2727
if err := util.LoadTemplates(templatesFS); err != nil {
2828
log.Fatal(err)
2929
}

0 commit comments

Comments
 (0)