-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
redundant-import-alias: add param ignoreUsed to ignore redundant alia…
…ses but used in code (useful for sdk packages)
- Loading branch information
1 parent
bf0ff67
commit 8825aa7
Showing
5 changed files
with
119 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,33 @@ | ||
package test | ||
|
||
import ( | ||
"github.com/mgechev/revive/rule" | ||
"testing" | ||
|
||
"github.com/mgechev/revive/lint" | ||
"github.com/mgechev/revive/rule" | ||
) | ||
|
||
// TestRedundantImportAlias rule. | ||
func TestRedundantImportIgnoredAliases(t *testing.T) { | ||
|
||
args := []any{map[string]any{ | ||
"ignoreUsed": true, | ||
}} | ||
|
||
testRule(t, "redundant-import-alias-ignored", &rule.RedundantImportAlias{}, &lint.RuleConfig{ | ||
Arguments: args, | ||
}) | ||
|
||
} | ||
|
||
func TestRedundantImportAlias(t *testing.T) { | ||
testRule(t, "redundant-import-alias", &rule.RedundantImportAlias{}) | ||
|
||
args := []any{map[string]any{ | ||
"ignoreUsed": false, | ||
}} | ||
|
||
testRule(t, "redundant-import-alias", &rule.RedundantImportAlias{}, &lint.RuleConfig{ | ||
Arguments: args, | ||
}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package fixtures | ||
|
||
import ( | ||
runpb "cloud.google.com/go/run/apiv2/runpb" | ||
md5 "crypto/md5" | ||
strings "strings" // MATCH /Import alias "strings" is redundant/ | ||
|
||
"crypto/md5" | ||
_ "crypto/md5" // MATCH /Import alias "_" is redundant/ | ||
|
||
"strings" | ||
str "strings" // MATCH /Import alias "str" is redundant/ | ||
|
||
) | ||
|
||
func UseRunpb() { | ||
runpb.RegisterTasksServer() | ||
} | ||
|
||
func UseMd5() { | ||
fmt.PrintLn(md5.Size) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters