Skip to content

Commit 251b205

Browse files
author
Sergey Vilgelm
authored
Deprecate Interfacer linter (#1755)
1 parent eace6a1 commit 251b205

File tree

8 files changed

+38
-11
lines changed

8 files changed

+38
-11
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ linters:
8888
- gosimple
8989
- govet
9090
- ineffassign
91-
- interfacer
9291
- lll
9392
- misspell
9493
- nakedret
@@ -113,6 +112,7 @@ linters:
113112
# - godot
114113
# - godox
115114
# - goerr113
115+
# - interfacer
116116
# - maligned
117117
# - nestif
118118
# - prealloc

pkg/commands/run.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ func initFlagSet(fs *pflag.FlagSet, cfg *config.Config, m *lintersdb.Manager, is
8282
fs.StringVar(&oc.PathPrefix, "path-prefix", "", wh("Path prefix to add to output"))
8383
hideFlag("print-welcome") // no longer used
8484

85+
fs.BoolVar(&cfg.InternalCmdTest, "internal-cmd-test", false, wh("Option is used only for testing golangci-lint command, don't use it"))
86+
if err := fs.MarkHidden("internal-cmd-test"); err != nil {
87+
panic(err)
88+
}
89+
8590
// Run config
8691
rc := &cfg.Run
8792
fs.StringVar(&rc.ModulesDownloadMode, "modules-download-mode", "",

pkg/config/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,8 @@ type Config struct {
663663
Severity Severity
664664
Version Version
665665

666-
InternalTest bool // Option is used only for testing golangci-lint code, don't use it
666+
InternalCmdTest bool `mapstructure:"internal-cmd-test"` // Option is used only for testing golangci-lint command, don't use it
667+
InternalTest bool // Option is used only for testing golangci-lint code, don't use it
667668
}
668669

669670
func NewDefault() *Config {

pkg/lint/linter/config.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ type Config struct {
2222
InPresets []string
2323
AlternativeNames []string
2424

25-
OriginalURL string // URL of original (not forked) repo, needed for autogenerated README
26-
CanAutoFix bool
27-
IsSlow bool
28-
DoesChangeTypes bool
25+
OriginalURL string // URL of original (not forked) repo, needed for autogenerated README
26+
CanAutoFix bool
27+
IsSlow bool
28+
DoesChangeTypes bool
29+
DeprecatedMessage string
2930
}
3031

3132
func (lc *Config) ConsiderSlow() *Config {
@@ -73,6 +74,15 @@ func (lc *Config) WithChangeTypes() *Config {
7374
return lc
7475
}
7576

77+
func (lc *Config) Deprecated(message string) *Config {
78+
lc.DeprecatedMessage = message
79+
return lc
80+
}
81+
82+
func (lc *Config) IsDeprecated() bool {
83+
return lc.DeprecatedMessage != ""
84+
}
85+
7686
func (lc *Config) AllNames() []string {
7787
return append([]string{lc.Name()}, lc.AlternativeNames...)
7888
}

pkg/lint/lintersdb/manager.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
177177
linter.NewConfig(golinters.NewInterfacer()).
178178
WithLoadForGoAnalysis().
179179
WithPresets(linter.PresetStyle).
180-
WithURL("https://github.com/mvdan/interfacer"),
180+
WithURL("https://github.com/mvdan/interfacer").
181+
Deprecated("The repository of the linter has been archived by the owner."),
181182
linter.NewConfig(golinters.NewUnconvert()).
182183
WithLoadForGoAnalysis().
183184
WithPresets(linter.PresetStyle).

pkg/lint/runner.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99

1010
"github.com/pkg/errors"
11+
gopackages "golang.org/x/tools/go/packages"
1112

1213
"github.com/golangci/golangci-lint/internal/errorutil"
1314
"github.com/golangci/golangci-lint/pkg/config"
@@ -20,8 +21,6 @@ import (
2021
"github.com/golangci/golangci-lint/pkg/result"
2122
"github.com/golangci/golangci-lint/pkg/result/processors"
2223
"github.com/golangci/golangci-lint/pkg/timeutils"
23-
24-
gopackages "golang.org/x/tools/go/packages"
2524
)
2625

2726
type Runner struct {
@@ -50,6 +49,15 @@ func NewRunner(cfg *config.Config, log logutils.Log, goenv *goutil.Env, es *lint
5049
return nil, errors.Wrap(err, "failed to get enabled linters")
5150
}
5251

52+
// print deprecated messages
53+
if !cfg.InternalCmdTest {
54+
for name, lc := range enabledLinters {
55+
if lc.IsDeprecated() {
56+
log.Warnf("The linter '%s' is deprecated due to: %s", name, lc.DeprecatedMessage)
57+
}
58+
}
59+
}
60+
5361
return &Runner{
5462
Processors: []processors.Processor{
5563
processors.NewCgo(goenv),

test/testdata/interfacer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//args: -Einterfacer
1+
//args: -Einterfacer --internal-cmd-test
22
package testdata
33

44
import "io"

test/testshared/testshared.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ func (r *LintRunner) Run(args ...string) *RunResult {
9494
func (r *LintRunner) RunCommand(command string, args ...string) *RunResult {
9595
r.Install()
9696

97-
runArgs := append([]string{command}, args...)
97+
runArgs := append([]string{command}, "--internal-cmd-test")
98+
runArgs = append(runArgs, args...)
99+
98100
defer func(startedAt time.Time) {
99101
r.log.Infof("ran [../golangci-lint %s] in %s", strings.Join(runArgs, " "), time.Since(startedAt))
100102
}(time.Now())

0 commit comments

Comments
 (0)