Skip to content

Commit

Permalink
style: refactor codebase and update linting rules (#169)
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
appleboy committed May 13, 2024
1 parent 3197819 commit 66d623d
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ linters:
- errcheck
- exportloopref
- exhaustive
- gochecknoinits
- goconst
- gocritic
- gocyclo
Expand All @@ -20,7 +19,6 @@ linters:
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- noctx
Expand Down
2 changes: 1 addition & 1 deletion cmd/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewOpenAI() (*openai.Client, error) {
openai.WithProvider(viper.GetString("openai.provider")),
openai.WithSkipVerify(viper.GetBool("openai.skip_verify")),
openai.WithHeaders(viper.GetStringSlice("openai.headers")),
openai.WithApiVersion(viper.GetString("openai.api_version")),
openai.WithAPIVersion(viper.GetString("openai.api_version")),
openai.WithTopP(float32(viper.GetFloat64("openai.top_p"))),
openai.WithFrequencyPenalty(float32(viper.GetFloat64("openai.frequency_penalty"))),
openai.WithPresencePenalty(float32(viper.GetFloat64("openai.presence_penalty"))),
Expand Down
2 changes: 1 addition & 1 deletion git/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (
CommitMessageTemplate = "commit-msg.tmpl"
)

func init() {
func init() { //nolint:gochecknoinits
if err := util.LoadTemplates(files); err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion openai/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func New(opts ...Option) (*Client, error) {
// Create a new HTTP transport.
tr := &http.Transport{}
if cfg.skipVerify {
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} //nolint:gosec
}

// Create a new HTTP client with the specified timeout and proxy, if any.
Expand Down
4 changes: 2 additions & 2 deletions openai/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ func WithHeaders(headers []string) Option {
})
}

// WithApiVersion returns a new Option that sets the apiVersion for OpenAI Model.
func WithApiVersion(apiVersion string) Option {
// WithAPIVersion returns a new Option that sets the apiVersion for OpenAI Model.
func WithAPIVersion(apiVersion string) Option {
return optionFunc(func(c *config) {
c.apiVersion = apiVersion
})
Expand Down
2 changes: 1 addition & 1 deletion prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
)

// Initializes the prompt package by loading the templates from the embedded file system.
func init() {
func init() { //nolint:gochecknoinits
if err := util.LoadTemplates(templatesFS); err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 66d623d

Please sign in to comment.