Skip to content

Commit a893212

Browse files
authored
gomodguard: updated for new features and fixes (#1567)
1 parent 87cdb2d commit a893212

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

.golangci.example.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ linters-settings:
263263
# - github.com/mitchellh/go-homedir: # Blocked module with version constraint
264264
# version: "< 1.1.0" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
265265
# reason: "testing if blocked version constraint works." # Reason why the version constraint exists. (Optional)
266+
local_replace_directives: false # Set to true to raise lint issues for packages that are loaded from a local path via replace directive
266267
govet:
267268
# report about shadowed variables
268269
check-shadowing: true

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ require (
4444
github.com/nishanths/exhaustive v0.1.0
4545
github.com/pkg/errors v0.9.1
4646
github.com/polyfloyd/go-errorlint v0.0.0-20201127212506-19bd8db6546f
47-
github.com/ryancurrah/gomodguard v1.1.0
47+
github.com/ryancurrah/gomodguard v1.2.0
4848
github.com/ryanrolds/sqlclosecheck v0.3.0
4949
github.com/securego/gosec/v2 v2.5.0
5050
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c

go.sum

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ type LintersSettings struct {
245245
Version string `mapstructure:"version"`
246246
Reason string `mapstructure:"reason"`
247247
} `mapstructure:"versions"`
248+
LocalReplaceDirectives bool `mapstructure:"local_replace_directives"`
248249
} `mapstructure:"blocked"`
249250
}
250251

pkg/golinters/gomodguard.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package golinters
22

33
import (
4-
"log"
5-
"os"
64
"sync"
75

86
"github.com/ryancurrah/gomodguard"
@@ -40,7 +38,7 @@ func NewGomodguard() *goanalysis.Linter {
4038
var (
4139
files = []string{}
4240
linterCfg = lintCtx.Cfg.LintersSettings.Gomodguard
43-
processorCfg = gomodguard.Configuration{}
41+
processorCfg = &gomodguard.Configuration{}
4442
)
4543
processorCfg.Allowed.Modules = linterCfg.Allowed.Modules
4644
processorCfg.Allowed.Domains = linterCfg.Allowed.Domains
@@ -70,7 +68,9 @@ func NewGomodguard() *goanalysis.Linter {
7068
files = append(files, pass.Fset.PositionFor(file.Pos(), false).Filename)
7169
}
7270

73-
processor, err := gomodguard.NewProcessor(processorCfg, log.New(os.Stderr, "", 0))
71+
processorCfg.Blocked.LocalReplaceDirectives = linterCfg.Blocked.LocalReplaceDirectives
72+
73+
processor, err := gomodguard.NewProcessor(processorCfg)
7474
if err != nil {
7575
lintCtx.Log.Warnf("running gomodguard failed: %s: if you are not using go modules "+
7676
"it is suggested to disable this linter", err)

0 commit comments

Comments
 (0)