Skip to content

updated gomodguard for new features and fixes #1567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ linters-settings:
# - github.com/mitchellh/go-homedir: # Blocked module with version constraint
# 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)
local_replace_directives: false # Set to true to raise lint issues for packages that are loaded from a local path via replace directive
govet:
# report about shadowed variables
check-shadowing: true
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
github.com/nishanths/exhaustive v0.1.0
github.com/pkg/errors v0.9.1
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/securego/gosec/v2 v2.5.0
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c
Expand Down
4 changes: 4 additions & 0 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ type LintersSettings struct {
Version string `mapstructure:"version"`
Reason string `mapstructure:"reason"`
} `mapstructure:"versions"`
LocalReplaceDirectives bool `mapstructure:"local_replace_directives"`
} `mapstructure:"blocked"`
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/golinters/gomodguard.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package golinters

import (
"log"
"os"
"sync"

"github.com/ryancurrah/gomodguard"
Expand Down Expand Up @@ -40,7 +38,7 @@ func NewGomodguard() *goanalysis.Linter {
var (
files = []string{}
linterCfg = lintCtx.Cfg.LintersSettings.Gomodguard
processorCfg = gomodguard.Configuration{}
processorCfg = &gomodguard.Configuration{}
)
processorCfg.Allowed.Modules = linterCfg.Allowed.Modules
processorCfg.Allowed.Domains = linterCfg.Allowed.Domains
Expand Down Expand Up @@ -70,7 +68,9 @@ func NewGomodguard() *goanalysis.Linter {
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 {
lintCtx.Log.Warnf("running gomodguard failed: %s: if you are not using go modules "+
"it is suggested to disable this linter", err)
Expand Down