From 9fd3138fd53baaf41356fad23a71ad18e6460897 Mon Sep 17 00:00:00 2001 From: Nuruddin Ashr Date: Wed, 18 Dec 2019 15:33:25 +0700 Subject: [PATCH 1/3] Update the gocognit linter --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 5f4a994e..5fc93182 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/tommy-muehle/go-mnd v1.1.1 github.com/ultraware/funlen v0.0.2 github.com/ultraware/whitespace v0.0.4 - github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517 + github.com/uudashr/gocognit v1.0.1 github.com/valyala/quicktemplate v1.2.0 golang.org/x/tools v0.0.0-20191113232020-e2727e816f5a gopkg.in/yaml.v2 v2.2.5 diff --git a/go.sum b/go.sum index c340c7f9..83c94056 100644 --- a/go.sum +++ b/go.sum @@ -242,6 +242,8 @@ github.com/ultraware/whitespace v0.0.4 h1:If7Va4cM03mpgrNH9k49/VOicWpGoG70XPBFFO github.com/ultraware/whitespace v0.0.4/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA= github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517 h1:ChMKTho2hWKpks/nD/FL2KqM1wuVt62oJeiE8+eFpGs= github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517/go.mod h1:j44Ayx2KW4+oB6SWMv8KsmHzZrOInQav7D3cQMJ5JUM= +github.com/uudashr/gocognit v1.0.1 h1:MoG2fZ0b/Eo7NXoIwCVFLG5JED3qgQz5/NEE+rOsjPs= +github.com/uudashr/gocognit v1.0.1/go.mod h1:j44Ayx2KW4+oB6SWMv8KsmHzZrOInQav7D3cQMJ5JUM= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s= From 70abc4a01ca4fdb3a37d6c2a25b22a9199a9bf27 Mon Sep 17 00:00:00 2001 From: Nuruddin Ashr Date: Thu, 19 Dec 2019 11:06:03 +0700 Subject: [PATCH 2/3] Added the updated vendor --- vendor/github.com/uudashr/gocognit/go.sum | 0 .../github.com/uudashr/gocognit/gocognit.go | 27 ++++++++++++++----- vendor/modules.txt | 4 +-- 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 vendor/github.com/uudashr/gocognit/go.sum diff --git a/vendor/github.com/uudashr/gocognit/go.sum b/vendor/github.com/uudashr/gocognit/go.sum new file mode 100644 index 00000000..e69de29b diff --git a/vendor/github.com/uudashr/gocognit/gocognit.go b/vendor/github.com/uudashr/gocognit/gocognit.go index 71cafd4f..11d5ee52 100644 --- a/vendor/github.com/uudashr/gocognit/gocognit.go +++ b/vendor/github.com/uudashr/gocognit/gocognit.go @@ -133,6 +133,8 @@ func (v *complexityVisitor) Visit(n ast.Node) ast.Visitor { return v.visitSelectStmt(n) case *ast.ForStmt: return v.visitForStmt(n) + case *ast.RangeStmt: + return v.visitRangeStmt(n) case *ast.FuncLit: return v.visitFuncLit(n) case *ast.BranchStmt: @@ -218,6 +220,25 @@ func (v *complexityVisitor) visitForStmt(n *ast.ForStmt) ast.Visitor { return nil } +func (v *complexityVisitor) visitRangeStmt(n *ast.RangeStmt) ast.Visitor { + v.nestIncComplexity() + + if n.Key != nil { + ast.Walk(v, n.Key) + } + + if n.Value != nil { + ast.Walk(v, n.Value) + } + + ast.Walk(v, n.X) + + v.incNesting() + ast.Walk(v, n.Body) + v.decNesting() + return nil +} + func (v *complexityVisitor) visitFuncLit(n *ast.FuncLit) ast.Visitor { ast.Walk(v, n.Type) @@ -290,9 +311,3 @@ func mergeBinaryOps(x []token.Token, op token.Token, y []token.Token) []token.To } return out } - -func walkExprList(v ast.Visitor, list []ast.Expr) { - for _, x := range list { - ast.Walk(v, x) - } -} diff --git a/vendor/modules.txt b/vendor/modules.txt index cfeb4376..05317b03 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -170,14 +170,14 @@ github.com/stretchr/testify/mock github.com/stretchr/testify/require # github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e github.com/timakin/bodyclose/passes/bodyclose -# github.com/tommy-muehle/go-mnd v0.0.0-20190903201840-c93e405da530 +# github.com/tommy-muehle/go-mnd v1.1.1 github.com/tommy-muehle/go-mnd github.com/tommy-muehle/go-mnd/checks # github.com/ultraware/funlen v0.0.2 github.com/ultraware/funlen # github.com/ultraware/whitespace v0.0.4 github.com/ultraware/whitespace -# github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517 +# github.com/uudashr/gocognit v1.0.1 github.com/uudashr/gocognit # github.com/valyala/bytebufferpool v1.0.0 github.com/valyala/bytebufferpool From 641cca8ed7d27465300edff0d53c5e4f2b56ed1f Mon Sep 17 00:00:00 2001 From: Nuruddin Ashr Date: Thu, 19 Dec 2019 13:45:26 +0700 Subject: [PATCH 3/3] Update go.sum --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index 83c94056..95dd6134 100644 --- a/go.sum +++ b/go.sum @@ -240,8 +240,6 @@ github.com/ultraware/funlen v0.0.2 h1:Av96YVBwwNSe4MLR7iI/BIa3VyI7/djnto/pK3Uxbd github.com/ultraware/funlen v0.0.2/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA= github.com/ultraware/whitespace v0.0.4 h1:If7Va4cM03mpgrNH9k49/VOicWpGoG70XPBFFODYDsg= github.com/ultraware/whitespace v0.0.4/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA= -github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517 h1:ChMKTho2hWKpks/nD/FL2KqM1wuVt62oJeiE8+eFpGs= -github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517/go.mod h1:j44Ayx2KW4+oB6SWMv8KsmHzZrOInQav7D3cQMJ5JUM= github.com/uudashr/gocognit v1.0.1 h1:MoG2fZ0b/Eo7NXoIwCVFLG5JED3qgQz5/NEE+rOsjPs= github.com/uudashr/gocognit v1.0.1/go.mod h1:j44Ayx2KW4+oB6SWMv8KsmHzZrOInQav7D3cQMJ5JUM= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=