Skip to content

Commit

Permalink
Deprecate Interfacer linter (#1755)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Vilgelm authored Feb 21, 2021
1 parent eace6a1 commit 251b205
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ linters:
- gosimple
- govet
- ineffassign
- interfacer
- lll
- misspell
- nakedret
Expand All @@ -113,6 +112,7 @@ linters:
# - godot
# - godox
# - goerr113
# - interfacer
# - maligned
# - nestif
# - prealloc
Expand Down
5 changes: 5 additions & 0 deletions pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
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
rc := &cfg.Run
fs.StringVar(&rc.ModulesDownloadMode, "modules-download-mode", "",
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,8 @@ type Config struct {
Severity Severity
Version Version

InternalTest bool // Option is used only for testing golangci-lint code, don't use it
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
}

func NewDefault() *Config {
Expand Down
18 changes: 14 additions & 4 deletions pkg/lint/linter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ type Config struct {
InPresets []string
AlternativeNames []string

OriginalURL string // URL of original (not forked) repo, needed for autogenerated README
CanAutoFix bool
IsSlow bool
DoesChangeTypes bool
OriginalURL string // URL of original (not forked) repo, needed for autogenerated README
CanAutoFix bool
IsSlow bool
DoesChangeTypes bool
DeprecatedMessage string
}

func (lc *Config) ConsiderSlow() *Config {
Expand Down Expand Up @@ -73,6 +74,15 @@ func (lc *Config) WithChangeTypes() *Config {
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 {
return append([]string{lc.Name()}, lc.AlternativeNames...)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/lint/lintersdb/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
linter.NewConfig(golinters.NewInterfacer()).
WithLoadForGoAnalysis().
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()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
Expand Down
12 changes: 10 additions & 2 deletions pkg/lint/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"

"github.com/pkg/errors"
gopackages "golang.org/x/tools/go/packages"

"github.com/golangci/golangci-lint/internal/errorutil"
"github.com/golangci/golangci-lint/pkg/config"
Expand All @@ -20,8 +21,6 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
"github.com/golangci/golangci-lint/pkg/result/processors"
"github.com/golangci/golangci-lint/pkg/timeutils"

gopackages "golang.org/x/tools/go/packages"
)

type Runner struct {
Expand Down Expand Up @@ -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")
}

// 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{
Processors: []processors.Processor{
processors.NewCgo(goenv),
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/interfacer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//args: -Einterfacer
//args: -Einterfacer --internal-cmd-test
package testdata

import "io"
Expand Down
4 changes: 3 additions & 1 deletion test/testshared/testshared.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ func (r *LintRunner) Run(args ...string) *RunResult {
func (r *LintRunner) RunCommand(command string, args ...string) *RunResult {
r.Install()

runArgs := append([]string{command}, args...)
runArgs := append([]string{command}, "--internal-cmd-test")
runArgs = append(runArgs, args...)

defer func(startedAt time.Time) {
r.log.Infof("ran [../golangci-lint %s] in %s", strings.Join(runArgs, " "), time.Since(startedAt))
}(time.Now())
Expand Down

0 comments on commit 251b205

Please sign in to comment.