From 1d733c6dc2d9872951fa9fbd3c91537da5666f42 Mon Sep 17 00:00:00 2001 From: Marcin Federowicz Date: Thu, 30 Nov 2023 01:50:04 +0100 Subject: [PATCH] add deprecatedRules list --- config/config.go | 10 ++++++++++ rule/imports-blacklist.go | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 rule/imports-blacklist.go diff --git a/config/config.go b/config/config.go index 06d673f8a..785d0cc45 100644 --- a/config/config.go +++ b/config/config.go @@ -95,6 +95,11 @@ var allRules = append([]lint.Rule{ &rule.EnforceSliceStyleRule{}, }, defaultRules...) +var deprecatedRules = []lint.Rule{ + + &rule.ImportsBlacklistRule{}, +} + var allFormatters = []lint.Formatter{ &formatter.Stylish{}, &formatter.Friendly{}, @@ -154,6 +159,11 @@ func parseConfig(path string, config *lint.Config) error { if err != nil { return fmt.Errorf("cannot parse the config file: %v", err) } + + for _, r := range deprecatedRules { + delete(config.Rules, r.Name()) + } + for k, r := range config.Rules { err := r.Initialize() if err != nil { diff --git a/rule/imports-blacklist.go b/rule/imports-blacklist.go new file mode 100644 index 000000000..9eae8658c --- /dev/null +++ b/rule/imports-blacklist.go @@ -0,0 +1,25 @@ +package rule + +import ( + "regexp" + "sync" + + "github.com/mgechev/revive/lint" +) + +// Deprecated: use ImportsBlocklistRule instead +type ImportsBlacklistRule struct { + blocklist []*regexp.Regexp + sync.Mutex +} + +func (r *ImportsBlacklistRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { + + var failures []lint.Failure + + return failures +} + +func (*ImportsBlacklistRule) Name() string { + return "imports-blacklist" +}