Skip to content

Commit

Permalink
#14 Added more static checks
Browse files Browse the repository at this point in the history
  • Loading branch information
roma-glushko committed Dec 23, 2023
1 parent c524b4e commit 8a1bd91
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
24 changes: 24 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@ linters:
- nolintlint
- revive
- staticcheck
- asasalint
- bodyclose
- contextcheck
- cyclop
- dupword
- errname
- exhaustive
- loggercheck
- misspell
- nestif
- perfsprint
- prealloc
- predeclared
- testifylint
- testpackage
- unconvert
- usestdlibvars
- wsl

linters-settings:
govet:
Expand All @@ -17,3 +35,9 @@ linters-settings:
- reflectvaluecompare
- sortslice
- unusedwrite
- defers
- atomic
- nilfunc
- printf
- sortslice
- tests
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ lint: install-checkers ## Lint the source code
static-checks: install-checkers ## Static Analysis
@echo "🧹 GoCI Lint.."
@golangci-lint run ./...
@echo "🧹 Nilaway.."

vuln: install-checkers ## Check for vulnerabilities
@echo "🔍 Checking for vulnerabilities"
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ func (srv *Server) Shutdown(_ context.Context) error {
ctx, cancel := context.WithTimeout(context.Background(), exitWaitTime)
defer cancel()

return srv.server.Shutdown(ctx)
return srv.server.Shutdown(ctx) //nolint:contextcheck
}
2 changes: 1 addition & 1 deletion pkg/buildAPIRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ var validate *validator.Validate = validator.New()
func BuildAPIRequest(provider string, params map[string]string, mode string) (interface{}, error) {
// provider is the name of the provider, e.g. "openai", params is the map of parameters from the client,
// mode is the mode of the provider, e.g. "chat", configList is the list of provider configurations

var providerConfig map[string]interface{}

if config, ok := configList[provider].(ProviderConfigs); ok {
if modeConfig, ok := config[mode].(map[string]interface{}); ok {
providerConfig = modeConfig
Expand Down
2 changes: 1 addition & 1 deletion pkg/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ LOOP:
case <-ctx.Done():
gw.telemetry.Logger.Info("context done, terminating process")
// Call shutdown with background context as the passed in context has been canceled
return gw.shutdown(context.Background())
return gw.shutdown(context.Background()) //nolint:contextcheck
}
}

Expand Down
10 changes: 6 additions & 4 deletions pkg/telemetry/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ type LogConfig struct {

func NewLogConfig() *LogConfig {
return &LogConfig{
Level: zap.NewAtomicLevelAt(zap.InfoLevel),
Encoding: "json",
OutputPaths: []string{"stdout"},
Level: zap.NewAtomicLevelAt(zap.InfoLevel),
Encoding: "json",
DisableCaller: false,
DisableStacktrace: false,
OutputPaths: []string{"stdout"},
InitialFields: make(map[string]interface{}),
}
}

Expand Down Expand Up @@ -63,7 +66,6 @@ func NewHertzLogger(zapConfig *zap.Config) (*hertzzap.Logger, error) {
// Both hertzzap and zap have a set of private methods that prevents from leveraging
// their native encoder & sink building functionality
// We had to copy & paste some of those to get it working

var encoder zapcore.Encoder

if zapConfig.Encoding == "console" {
Expand Down

0 comments on commit 8a1bd91

Please sign in to comment.