Skip to content

Commit

Permalink
add deprecatedRules list
Browse files Browse the repository at this point in the history
  • Loading branch information
mfederowicz committed Nov 30, 2023
1 parent 3facb4d commit 1d733c6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand Down Expand Up @@ -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 {
Expand Down
25 changes: 25 additions & 0 deletions rule/imports-blacklist.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package rule

import (
"regexp"
"sync"

"github.com/mgechev/revive/lint"
)

// Deprecated: use ImportsBlocklistRule instead

Check warning on line 10 in rule/imports-blacklist.go

View workflow job for this annotation

GitHub Actions / Lint

comment on exported type ImportsBlacklistRule should be of the form "ImportsBlacklistRule ..." (with optional leading article)
type ImportsBlacklistRule struct {
blocklist []*regexp.Regexp
sync.Mutex
}

func (r *ImportsBlacklistRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure {

Check warning on line 16 in rule/imports-blacklist.go

View workflow job for this annotation

GitHub Actions / Lint

exported method ImportsBlacklistRule.Apply should have comment or be unexported

Check warning on line 16 in rule/imports-blacklist.go

View workflow job for this annotation

GitHub Actions / Lint

parameter 'file' seems to be unused, consider removing or renaming it as _

Check warning on line 16 in rule/imports-blacklist.go

View workflow job for this annotation

GitHub Actions / Lint

parameter 'arguments' seems to be unused, consider removing or renaming it as _

var failures []lint.Failure

return failures
}

func (*ImportsBlacklistRule) Name() string {

Check warning on line 23 in rule/imports-blacklist.go

View workflow job for this annotation

GitHub Actions / Lint

exported method ImportsBlacklistRule.Name should have comment or be unexported
return "imports-blacklist"
}

0 comments on commit 1d733c6

Please sign in to comment.