Skip to content

Commit 66adcf6

Browse files
author
Sergey Vilgelm
committed
Deprecate Interfacer linter
Add `Deprecated` function to config that accepts a message as a deprecation reason. Print a warning if a deprecated linter is enabled. Deprecate the Interfacer linter due to archived repository.
1 parent eace6a1 commit 66adcf6

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

pkg/lint/linter/config.go

+14-4
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

+2-1
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

+7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ func NewRunner(cfg *config.Config, log logutils.Log, goenv *goutil.Env, es *lint
5050
return nil, errors.Wrap(err, "failed to get enabled linters")
5151
}
5252

53+
// print deprecated messages
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+
5360
return &Runner{
5461
Processors: []processors.Processor{
5562
processors.NewCgo(goenv),

0 commit comments

Comments
 (0)