Skip to content

Commit

Permalink
Deprecate Interfacer linter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sergey Vilgelm committed Feb 20, 2021
1 parent eace6a1 commit 66adcf6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
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
7 changes: 7 additions & 0 deletions pkg/lint/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ 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
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

0 comments on commit 66adcf6

Please sign in to comment.