Skip to content

Commit

Permalink
Merge pull request #747 from luraproject/deepsource-autofix-a11cfc7f
Browse files Browse the repository at this point in the history
refactor: replace empty slice literal with `var`
  • Loading branch information
kpacha authored Jan 15, 2025
2 parents 9e5f48c + ec700cf commit fff63b0
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 11 deletions.
5 changes: 3 additions & 2 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0

/*
Package plugin provides tools for loading and registering plugins
Package plugin provides tools for loading and registering plugins
*/
package plugin

Expand All @@ -18,7 +18,8 @@ func Scan(folder, pattern string) ([]string, error) {
return []string{}, err
}

plugins := []string{}
var plugins []string

for _, file := range files {
if !file.IsDir() && strings.Contains(file.Name(), pattern) {
plugins = append(plugins, filepath.Join(folder, file.Name()))
Expand Down
9 changes: 6 additions & 3 deletions proxy/formatter_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,14 @@ func BenchmarkEntityFormatter_flatmapAlt(b *testing.B) {
},
IsComplete: true,
}
subCol := []interface{}{}
var subCol []interface{}

for i := 0; i < size; i++ {
subCol = append(subCol, i)
}
sub["e"] = subCol
sampleSubCol := []interface{}{}
var sampleSubCol []interface{}

for i := 0; i < size; i++ {
sampleSubCol = append(sampleSubCol, sub)
}
Expand Down Expand Up @@ -285,7 +287,8 @@ func BenchmarkEntityFormatter_flatmap(b *testing.B) {
IsComplete: true,
}

cmds := []interface{}{}
var cmds []interface{}

for _, path := range blacklist {
cmds = append(cmds, map[string]interface{}{
"type": "del",
Expand Down
3 changes: 2 additions & 1 deletion proxy/merging_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ func BenchmarkNewMergeDataMiddleware(b *testing.B) {
func BenchmarkNewMergeDataMiddleware_sequential(b *testing.B) {
backends := make([]*config.Backend, 10)
pattern := "/some"
keys := []string{}
var keys []string

for i := range backends {
b := &config.Backend{
URLKeys: make([]string, 4*i),
Expand Down
3 changes: 2 additions & 1 deletion proxy/plugin/modifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ func LoadWithLoggerAndContext(ctx context.Context, path, pattern string, rmf Reg
}

func load(ctx context.Context, plugins []string, rmf RegisterModifierFunc, logger logging.Logger) (int, error) {
errors := []error{}
var errors []error

loadedPlugins := 0
for k, pluginName := range plugins {
if err := open(ctx, pluginName, rmf, logger); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion proxy/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func (r *Request) GeneratePath(URLPattern string) {
}
buff := []byte(URLPattern)
for k, v := range r.Params {
key := []byte{}
var key []byte

key = append(key, "{{."...)
key = append(key, k...)
key = append(key, "}}"...)
Expand Down
2 changes: 1 addition & 1 deletion router/gin/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewEngine(cfg config.ServiceConfig, opt EngineOptions) *gin.Engine {
engine.HandleMethodNotAllowed = true
engine.ContextWithFallback = true

paths := []string{}
var paths []string

ginOptions := engineConfiguration{}
if v, ok := cfg.ExtraConfig[Namespace]; ok {
Expand Down
3 changes: 2 additions & 1 deletion transport/http/client/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func LoadWithLogger(path, pattern string, rcf RegisterClientFunc, logger logging
}

func load(plugins []string, rcf RegisterClientFunc, logger logging.Logger) (int, error) {
errors := []error{}
var errors []error

loadedPlugins := 0
for k, pluginName := range plugins {
if err := open(pluginName, rcf, logger); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion transport/http/server/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func LoadWithLogger(path, pattern string, rcf RegisterHandlerFunc, logger loggin
}

func load(plugins []string, rcf RegisterHandlerFunc, logger logging.Logger) (int, error) {
errors := []error{}
var errors []error

loadedPlugins := 0
for k, pluginName := range plugins {
if err := open(pluginName, rcf, logger); err != nil {
Expand Down

0 comments on commit fff63b0

Please sign in to comment.