From 8ab500bd6ce2c69c0899fa67207532a47f6aa8a3 Mon Sep 17 00:00:00 2001 From: Shubhendra Singh Chauhan Date: Tue, 22 Dec 2020 09:49:40 +0000 Subject: [PATCH] fixed code quality issues using DeepSource * Combine multiple `append`s into a single call * Remove unnecessary use of slice * Replace `strings.Index` with `strings.Contains` * Added .deepsource.toml config file for DeepSource integration --- .deepsource.toml | 17 +++++++++++++++++ context/accept_header.go | 4 ++-- core/errgroup/errgroup.go | 2 +- i18n/internal/var.go | 3 +-- 4 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 .deepsource.toml diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 00000000..b767baab --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,17 @@ +version = 1 + +test_patterns = ["**/*_test.go"] + +exclude_patterns = [ + "_examples/**", + "_benchmarks/**", + ".github/**" +] + +[[analyzers]] +name = "go" +enabled = true + + [analyzers.meta] + import_paths = ["github.com/kataras/iris"] + diff --git a/context/accept_header.go b/context/accept_header.go index 56febdcd..aa8e78aa 100644 --- a/context/accept_header.go +++ b/context/accept_header.go @@ -194,8 +194,8 @@ func init() { var t octetType isCtl := c <= 31 || c == 127 isChar := 0 <= c && c <= 127 - isSeparator := strings.IndexRune(" \t\"(),/:;<=>?@[]\\{}", rune(c)) >= 0 - if strings.IndexRune(" \t\r\n", rune(c)) >= 0 { + isSeparator := strings.ContainsRune(" \t\"(),/:;<=>?@[]\\{}", rune(c)) + if strings.ContainsRune(" \t\r\n", rune(c)) { t |= isSpace } if isChar && !isCtl && !isSeparator { diff --git a/core/errgroup/errgroup.go b/core/errgroup/errgroup.go index 31974483..0da190cb 100644 --- a/core/errgroup/errgroup.go +++ b/core/errgroup/errgroup.go @@ -210,7 +210,7 @@ func (g *Group) Error() (s string) { } func (g *Group) getAllErrors() []error { - list := g.Errors[:] + list := g.Errors if len(g.children) > 0 { // return with order of definition. diff --git a/i18n/internal/var.go b/i18n/internal/var.go index 83543a25..eb3bdae8 100644 --- a/i18n/internal/var.go +++ b/i18n/internal/var.go @@ -174,8 +174,7 @@ func getCases(loc *Locale, src map[string]interface{}) []interface{} { cases := make([]interface{}, 0, len(pluralCases)*2) for _, pluralCase := range pluralCases { // fmt.Printf("%s=%v\n", pluralCase.Form, pluralCase.Value) - cases = append(cases, pluralCase.Form.String()) - cases = append(cases, pluralCase.Value) + cases = append(cases, pluralCase.Form.String(), pluralCase.Value) } return cases