Skip to content

Commit

Permalink
fix: rename rule
Browse files Browse the repository at this point in the history
  • Loading branch information
damif94 committed Jul 30, 2023
1 parent 2e3d53a commit d6a9894
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ List of all available rules. The rules ported from `golint` are left unchanged a
| [`use-any`](./RULES_DESCRIPTIONS.md#use-any) | n/a | Proposes to replace `interface{}` with its alias `any` | no | no |
| [`datarace`](./RULES_DESCRIPTIONS.md#datarace) | n/a | Spots potential dataraces | no | no |
| [`comment-spacings`](./RULES_DESCRIPTIONS.md#comment-spacings) | []string | Warns on malformed comments | no | no |
| [`unused-import-alias`](./RULES_DESCRIPTIONS.md#unused-import-alias) | []string | Warns on import aliases matching the imported package name | no | no |
| [`redundant-import-alias`](./RULES_DESCRIPTIONS.md#redundant-import-alias) | []string | Warns on import aliases matching the imported package name | no | no |


## Configurable rules
Expand Down
4 changes: 2 additions & 2 deletions RULES_DESCRIPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ List of all available rules.
- [use-any](#use-any)
- [useless-break](#useless-break)
- [waitgroup-by-value](#waitgroup-by-value)
- [unused-import-alias](#unused-import-alias)
- [redundant-import-alias](#redundant-import-alias)

## add-constant

Expand Down Expand Up @@ -762,7 +762,7 @@ This rule warns when a `sync.WaitGroup` expected as a by-value parameter in a fu

_Configuration_: N/A

## unused-import-alias
## redundant-import-alias

_Description_: This rule warns on redundant import aliases. This happens when the alias used on the import statement matches the imported package name.

Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var allRules = append([]lint.Rule{
&rule.DataRaceRule{},
&rule.CommentSpacingsRule{},
&rule.IfReturnRule{},
&rule.UnusedImportAlias{},
&rule.RedundantImportAlias{},
}, defaultRules...)

var allFormatters = []lint.Formatter{
Expand Down
10 changes: 5 additions & 5 deletions rule/unused-import-alias.go → rule/redundant-import-alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"github.com/mgechev/revive/lint"
)

// UnusedImportAlias lints given else constructs.
type UnusedImportAlias struct{}
// RedundantImportAlias lints given else constructs.
type RedundantImportAlias struct{}

// Apply applies the rule to given file.
func (*UnusedImportAlias) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (*RedundantImportAlias) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

for _, imp := range file.AST.Imports {
Expand All @@ -34,8 +34,8 @@ func (*UnusedImportAlias) Apply(file *lint.File, _ lint.Arguments) []lint.Failur
}

// Name returns the rule name.
func (*UnusedImportAlias) Name() string {
return "unused-import-alias"
func (*RedundantImportAlias) Name() string {
return "redundant-import-alias"
}

func getImportPackageName(imp *ast.ImportSpec) string {
Expand Down
11 changes: 11 additions & 0 deletions test/redundant-import-alias_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package test

import (
"github.com/mgechev/revive/rule"
"testing"
)

// TestRedundantImportAlias rule.
func TestRedundantImportAlias(t *testing.T) {
testRule(t, "redundant-import-alias", &rule.RedundantImportAlias{})
}
11 changes: 0 additions & 11 deletions test/unused-import-alias_test.go

This file was deleted.

File renamed without changes.

0 comments on commit d6a9894

Please sign in to comment.