gomodguard: updated for new features and fixes (#1567)
This commit is contained in:
parent
87cdb2ddf9
commit
a893212f02
@ -263,6 +263,7 @@ linters-settings:
|
|||||||
# - github.com/mitchellh/go-homedir: # Blocked module with version constraint
|
# - github.com/mitchellh/go-homedir: # Blocked module with version constraint
|
||||||
# version: "< 1.1.0" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
|
# version: "< 1.1.0" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
|
||||||
# reason: "testing if blocked version constraint works." # Reason why the version constraint exists. (Optional)
|
# reason: "testing if blocked version constraint works." # Reason why the version constraint exists. (Optional)
|
||||||
|
local_replace_directives: false # Set to true to raise lint issues for packages that are loaded from a local path via replace directive
|
||||||
govet:
|
govet:
|
||||||
# report about shadowed variables
|
# report about shadowed variables
|
||||||
check-shadowing: true
|
check-shadowing: true
|
||||||
|
2
go.mod
2
go.mod
@ -44,7 +44,7 @@ require (
|
|||||||
github.com/nishanths/exhaustive v0.1.0
|
github.com/nishanths/exhaustive v0.1.0
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/polyfloyd/go-errorlint v0.0.0-20201127212506-19bd8db6546f
|
github.com/polyfloyd/go-errorlint v0.0.0-20201127212506-19bd8db6546f
|
||||||
github.com/ryancurrah/gomodguard v1.1.0
|
github.com/ryancurrah/gomodguard v1.2.0
|
||||||
github.com/ryanrolds/sqlclosecheck v0.3.0
|
github.com/ryanrolds/sqlclosecheck v0.3.0
|
||||||
github.com/securego/gosec/v2 v2.5.0
|
github.com/securego/gosec/v2 v2.5.0
|
||||||
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c
|
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c
|
||||||
|
4
go.sum
generated
4
go.sum
generated
@ -334,6 +334,8 @@ github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE
|
|||||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/ryancurrah/gomodguard v1.1.0 h1:DWbye9KyMgytn8uYpuHkwf0RHqAYO6Ay/D0TbCpPtVU=
|
github.com/ryancurrah/gomodguard v1.1.0 h1:DWbye9KyMgytn8uYpuHkwf0RHqAYO6Ay/D0TbCpPtVU=
|
||||||
github.com/ryancurrah/gomodguard v1.1.0/go.mod h1:4O8tr7hBODaGE6VIhfJDHcwzh5GUccKSJBU0UMXJFVM=
|
github.com/ryancurrah/gomodguard v1.1.0/go.mod h1:4O8tr7hBODaGE6VIhfJDHcwzh5GUccKSJBU0UMXJFVM=
|
||||||
|
github.com/ryancurrah/gomodguard v1.2.0 h1:YWfhGOrXwLGiqcC/u5EqG6YeS8nh+1fw0HEc85CVZro=
|
||||||
|
github.com/ryancurrah/gomodguard v1.2.0/go.mod h1:rNqbC4TOIdUDcVMSIpNNAzTbzXAZa6W5lnUepvuMMgQ=
|
||||||
github.com/ryanrolds/sqlclosecheck v0.3.0 h1:AZx+Bixh8zdUBxUA1NxbxVAS78vTPq4rCb8OUZI9xFw=
|
github.com/ryanrolds/sqlclosecheck v0.3.0 h1:AZx+Bixh8zdUBxUA1NxbxVAS78vTPq4rCb8OUZI9xFw=
|
||||||
github.com/ryanrolds/sqlclosecheck v0.3.0/go.mod h1:1gREqxyTGR3lVtpngyFo3hZAgk0KCtEdgEkHwDbigdA=
|
github.com/ryanrolds/sqlclosecheck v0.3.0/go.mod h1:1gREqxyTGR3lVtpngyFo3hZAgk0KCtEdgEkHwDbigdA=
|
||||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||||
@ -453,6 +455,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
|
|||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
|
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
|
golang.org/x/mod v0.4.0 h1:8pl+sMODzuvGJkmj2W4kZihvVb5mKm8pB/X44PIQHv8=
|
||||||
|
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
@ -245,6 +245,7 @@ type LintersSettings struct {
|
|||||||
Version string `mapstructure:"version"`
|
Version string `mapstructure:"version"`
|
||||||
Reason string `mapstructure:"reason"`
|
Reason string `mapstructure:"reason"`
|
||||||
} `mapstructure:"versions"`
|
} `mapstructure:"versions"`
|
||||||
|
LocalReplaceDirectives bool `mapstructure:"local_replace_directives"`
|
||||||
} `mapstructure:"blocked"`
|
} `mapstructure:"blocked"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package golinters
|
package golinters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/ryancurrah/gomodguard"
|
"github.com/ryancurrah/gomodguard"
|
||||||
@ -40,7 +38,7 @@ func NewGomodguard() *goanalysis.Linter {
|
|||||||
var (
|
var (
|
||||||
files = []string{}
|
files = []string{}
|
||||||
linterCfg = lintCtx.Cfg.LintersSettings.Gomodguard
|
linterCfg = lintCtx.Cfg.LintersSettings.Gomodguard
|
||||||
processorCfg = gomodguard.Configuration{}
|
processorCfg = &gomodguard.Configuration{}
|
||||||
)
|
)
|
||||||
processorCfg.Allowed.Modules = linterCfg.Allowed.Modules
|
processorCfg.Allowed.Modules = linterCfg.Allowed.Modules
|
||||||
processorCfg.Allowed.Domains = linterCfg.Allowed.Domains
|
processorCfg.Allowed.Domains = linterCfg.Allowed.Domains
|
||||||
@ -70,7 +68,9 @@ func NewGomodguard() *goanalysis.Linter {
|
|||||||
files = append(files, pass.Fset.PositionFor(file.Pos(), false).Filename)
|
files = append(files, pass.Fset.PositionFor(file.Pos(), false).Filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
processor, err := gomodguard.NewProcessor(processorCfg, log.New(os.Stderr, "", 0))
|
processorCfg.Blocked.LocalReplaceDirectives = linterCfg.Blocked.LocalReplaceDirectives
|
||||||
|
|
||||||
|
processor, err := gomodguard.NewProcessor(processorCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lintCtx.Log.Warnf("running gomodguard failed: %s: if you are not using go modules "+
|
lintCtx.Log.Warnf("running gomodguard failed: %s: if you are not using go modules "+
|
||||||
"it is suggested to disable this linter", err)
|
"it is suggested to disable this linter", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user