Deprecate Interfacer
linter (#1755)
This commit is contained in:
parent
eace6a11a9
commit
251b205f54
@ -88,7 +88,6 @@ linters:
|
|||||||
- gosimple
|
- gosimple
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- interfacer
|
|
||||||
- lll
|
- lll
|
||||||
- misspell
|
- misspell
|
||||||
- nakedret
|
- nakedret
|
||||||
@ -113,6 +112,7 @@ linters:
|
|||||||
# - godot
|
# - godot
|
||||||
# - godox
|
# - godox
|
||||||
# - goerr113
|
# - goerr113
|
||||||
|
# - interfacer
|
||||||
# - maligned
|
# - maligned
|
||||||
# - nestif
|
# - nestif
|
||||||
# - prealloc
|
# - prealloc
|
||||||
|
@ -82,6 +82,11 @@ func initFlagSet(fs *pflag.FlagSet, cfg *config.Config, m *lintersdb.Manager, is
|
|||||||
fs.StringVar(&oc.PathPrefix, "path-prefix", "", wh("Path prefix to add to output"))
|
fs.StringVar(&oc.PathPrefix, "path-prefix", "", wh("Path prefix to add to output"))
|
||||||
hideFlag("print-welcome") // no longer used
|
hideFlag("print-welcome") // no longer used
|
||||||
|
|
||||||
|
fs.BoolVar(&cfg.InternalCmdTest, "internal-cmd-test", false, wh("Option is used only for testing golangci-lint command, don't use it"))
|
||||||
|
if err := fs.MarkHidden("internal-cmd-test"); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Run config
|
// Run config
|
||||||
rc := &cfg.Run
|
rc := &cfg.Run
|
||||||
fs.StringVar(&rc.ModulesDownloadMode, "modules-download-mode", "",
|
fs.StringVar(&rc.ModulesDownloadMode, "modules-download-mode", "",
|
||||||
|
@ -663,6 +663,7 @@ type Config struct {
|
|||||||
Severity Severity
|
Severity Severity
|
||||||
Version Version
|
Version Version
|
||||||
|
|
||||||
|
InternalCmdTest bool `mapstructure:"internal-cmd-test"` // Option is used only for testing golangci-lint command, don't use it
|
||||||
InternalTest bool // Option is used only for testing golangci-lint code, don't use it
|
InternalTest bool // Option is used only for testing golangci-lint code, don't use it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ type Config struct {
|
|||||||
CanAutoFix bool
|
CanAutoFix bool
|
||||||
IsSlow bool
|
IsSlow bool
|
||||||
DoesChangeTypes bool
|
DoesChangeTypes bool
|
||||||
|
DeprecatedMessage string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lc *Config) ConsiderSlow() *Config {
|
func (lc *Config) ConsiderSlow() *Config {
|
||||||
@ -73,6 +74,15 @@ func (lc *Config) WithChangeTypes() *Config {
|
|||||||
return lc
|
return lc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (lc *Config) Deprecated(message string) *Config {
|
||||||
|
lc.DeprecatedMessage = message
|
||||||
|
return lc
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lc *Config) IsDeprecated() bool {
|
||||||
|
return lc.DeprecatedMessage != ""
|
||||||
|
}
|
||||||
|
|
||||||
func (lc *Config) AllNames() []string {
|
func (lc *Config) AllNames() []string {
|
||||||
return append([]string{lc.Name()}, lc.AlternativeNames...)
|
return append([]string{lc.Name()}, lc.AlternativeNames...)
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,8 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
|
|||||||
linter.NewConfig(golinters.NewInterfacer()).
|
linter.NewConfig(golinters.NewInterfacer()).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/mvdan/interfacer"),
|
WithURL("https://github.com/mvdan/interfacer").
|
||||||
|
Deprecated("The repository of the linter has been archived by the owner."),
|
||||||
linter.NewConfig(golinters.NewUnconvert()).
|
linter.NewConfig(golinters.NewUnconvert()).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
gopackages "golang.org/x/tools/go/packages"
|
||||||
|
|
||||||
"github.com/golangci/golangci-lint/internal/errorutil"
|
"github.com/golangci/golangci-lint/internal/errorutil"
|
||||||
"github.com/golangci/golangci-lint/pkg/config"
|
"github.com/golangci/golangci-lint/pkg/config"
|
||||||
@ -20,8 +21,6 @@ import (
|
|||||||
"github.com/golangci/golangci-lint/pkg/result"
|
"github.com/golangci/golangci-lint/pkg/result"
|
||||||
"github.com/golangci/golangci-lint/pkg/result/processors"
|
"github.com/golangci/golangci-lint/pkg/result/processors"
|
||||||
"github.com/golangci/golangci-lint/pkg/timeutils"
|
"github.com/golangci/golangci-lint/pkg/timeutils"
|
||||||
|
|
||||||
gopackages "golang.org/x/tools/go/packages"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Runner struct {
|
type Runner struct {
|
||||||
@ -50,6 +49,15 @@ func NewRunner(cfg *config.Config, log logutils.Log, goenv *goutil.Env, es *lint
|
|||||||
return nil, errors.Wrap(err, "failed to get enabled linters")
|
return nil, errors.Wrap(err, "failed to get enabled linters")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print deprecated messages
|
||||||
|
if !cfg.InternalCmdTest {
|
||||||
|
for name, lc := range enabledLinters {
|
||||||
|
if lc.IsDeprecated() {
|
||||||
|
log.Warnf("The linter '%s' is deprecated due to: %s", name, lc.DeprecatedMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &Runner{
|
return &Runner{
|
||||||
Processors: []processors.Processor{
|
Processors: []processors.Processor{
|
||||||
processors.NewCgo(goenv),
|
processors.NewCgo(goenv),
|
||||||
|
2
test/testdata/interfacer.go
vendored
2
test/testdata/interfacer.go
vendored
@ -1,4 +1,4 @@
|
|||||||
//args: -Einterfacer
|
//args: -Einterfacer --internal-cmd-test
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import "io"
|
import "io"
|
||||||
|
@ -94,7 +94,9 @@ func (r *LintRunner) Run(args ...string) *RunResult {
|
|||||||
func (r *LintRunner) RunCommand(command string, args ...string) *RunResult {
|
func (r *LintRunner) RunCommand(command string, args ...string) *RunResult {
|
||||||
r.Install()
|
r.Install()
|
||||||
|
|
||||||
runArgs := append([]string{command}, args...)
|
runArgs := append([]string{command}, "--internal-cmd-test")
|
||||||
|
runArgs = append(runArgs, args...)
|
||||||
|
|
||||||
defer func(startedAt time.Time) {
|
defer func(startedAt time.Time) {
|
||||||
r.log.Infof("ran [../golangci-lint %s] in %s", strings.Join(runArgs, " "), time.Since(startedAt))
|
r.log.Infof("ran [../golangci-lint %s] in %s", strings.Join(runArgs, " "), time.Since(startedAt))
|
||||||
}(time.Now())
|
}(time.Now())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user