Use upstream gocyclo. (#1739)
Some checks failed
Extra / Vulnerability scanner (push) Failing after 19s
CI / golangci-lint (push) Failing after 2m53s
CI / tests-on-windows (push) Has been skipped
CI / tests-on-macos (push) Has been skipped
CI / tests-on-unix (1.14) (push) Has been skipped
CI / tests-on-unix (1.15) (push) Has been skipped
CI / tests-on-unix (1.16) (push) Has been skipped
CI / check_generated (push) Has been skipped
CI / go-mod (push) Failing after 15m20s
Release a tag / release (push) Failing after 15m3s
Release a tag / docker-release (map[Dockerfile:build/Dockerfile.alpine]) (push) Has been cancelled
Release a tag / docker-release (map[Dockerfile:build/Dockerfile]) (push) Has been cancelled
Some checks failed
Extra / Vulnerability scanner (push) Failing after 19s
CI / golangci-lint (push) Failing after 2m53s
CI / tests-on-windows (push) Has been skipped
CI / tests-on-macos (push) Has been skipped
CI / tests-on-unix (1.14) (push) Has been skipped
CI / tests-on-unix (1.15) (push) Has been skipped
CI / tests-on-unix (1.16) (push) Has been skipped
CI / check_generated (push) Has been skipped
CI / go-mod (push) Failing after 15m20s
Release a tag / release (push) Failing after 15m3s
Release a tag / docker-release (map[Dockerfile:build/Dockerfile.alpine]) (push) Has been cancelled
Release a tag / docker-release (map[Dockerfile:build/Dockerfile]) (push) Has been cancelled
This commit is contained in:
parent
2121370f81
commit
34e5fc6396
2
go.mod
2
go.mod
@ -16,6 +16,7 @@ require (
|
||||
github.com/denis-tingajkin/go-header v0.4.2
|
||||
github.com/esimonov/ifshort v1.0.1
|
||||
github.com/fatih/color v1.10.0
|
||||
github.com/fzipp/gocyclo v0.3.1
|
||||
github.com/go-critic/go-critic v0.5.4
|
||||
github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b
|
||||
github.com/gofrs/flock v0.8.0
|
||||
@ -23,7 +24,6 @@ require (
|
||||
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a
|
||||
github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6
|
||||
github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613
|
||||
github.com/golangci/gocyclo v0.0.0-20180528144436-0a533e8fa43d
|
||||
github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a
|
||||
github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc
|
||||
github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0
|
||||
|
4
go.sum
generated
4
go.sum
generated
@ -76,6 +76,8 @@ github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fzipp/gocyclo v0.3.1 h1:A9UeX3HJSXTBzvHzhqoYVuE0eAhe+aM8XBCCwsPMZOc=
|
||||
github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASxc7x3E=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-critic/go-critic v0.5.4 h1:fPNMqImVjELN6Du7NVVuvKA4cgASNmc7e4zSYQCOnv8=
|
||||
github.com/go-critic/go-critic v0.5.4/go.mod h1:cjB4YGw+n/+X8gREApej7150Uyy1Tg8If6F2XOAUXNE=
|
||||
@ -136,8 +138,6 @@ github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6 h1:YYWNAGTKWhKpc
|
||||
github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6/go.mod h1:DbHgvLiFKX1Sh2T1w8Q/h4NAI8MHIpzCdnBUDTXU3I0=
|
||||
github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613 h1:9kfjN3AdxcbsZBf8NjltjWihK2QfBBBZuv91cMFfDHw=
|
||||
github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613/go.mod h1:SyvUF2NxV+sN8upjjeVYr5W7tyxaT1JVtvhKhOn2ii8=
|
||||
github.com/golangci/gocyclo v0.0.0-20180528144436-0a533e8fa43d h1:pXTK/gkVNs7Zyy7WKgLXmpQ5bHTrq5GDsp8R9Qs67g0=
|
||||
github.com/golangci/gocyclo v0.0.0-20180528144436-0a533e8fa43d/go.mod h1:ozx7R9SIwqmqf5pRP90DhR2Oay2UIjGuKheCBCNwAYU=
|
||||
github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a h1:iR3fYXUjHCR97qWS8ch1y9zPNsgXThGwjKPrYfqMPks=
|
||||
github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a/go.mod h1:9qCChq59u/eW8im404Q2WWTrnBUQKjpNYKMbU4M7EFU=
|
||||
github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc h1:gLLhTLMk2/SutryVJ6D4VZCU3CUqr8YloG7FPIBWFpI=
|
||||
|
@ -1,4 +1,3 @@
|
||||
// nolint:dupl
|
||||
package golinters
|
||||
|
||||
import (
|
||||
|
@ -1,12 +1,10 @@
|
||||
// nolint:dupl
|
||||
package golinters
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
gocycloAPI "github.com/golangci/gocyclo/pkg/gocyclo"
|
||||
"github.com/fzipp/gocyclo"
|
||||
"golang.org/x/tools/go/analysis"
|
||||
|
||||
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
|
||||
@ -31,24 +29,18 @@ func NewGocyclo() *goanalysis.Linter {
|
||||
nil,
|
||||
).WithContextSetter(func(lintCtx *linter.Context) {
|
||||
analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
|
||||
var stats []gocycloAPI.Stat
|
||||
var stats gocyclo.Stats
|
||||
for _, f := range pass.Files {
|
||||
stats = gocycloAPI.BuildStats(f, pass.Fset, stats)
|
||||
stats = gocyclo.AnalyzeASTFile(f, pass.Fset, stats)
|
||||
}
|
||||
if len(stats) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
sort.SliceStable(stats, func(i, j int) bool {
|
||||
return stats[i].Complexity > stats[j].Complexity
|
||||
})
|
||||
stats = stats.SortAndFilter(-1, lintCtx.Settings().Gocyclo.MinComplexity)
|
||||
|
||||
res := make([]goanalysis.Issue, 0, len(stats))
|
||||
for _, s := range stats {
|
||||
if s.Complexity <= lintCtx.Settings().Gocyclo.MinComplexity {
|
||||
break // Break as the stats is already sorted from greatest to least
|
||||
}
|
||||
|
||||
res = append(res, goanalysis.NewIssue(&result.Issue{
|
||||
Pos: s.Pos,
|
||||
Text: fmt.Sprintf("cyclomatic complexity %d of func %s is high (> %d)",
|
||||
|
Loading…
x
Reference in New Issue
Block a user