-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add param ignoreUsed to ignore redundant aliases but used in code (us…
…eful for sdk packages)
- Loading branch information
1 parent
90b2112
commit 03826dd
Showing
5 changed files
with
153 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
package fixtures | ||
|
||
import( | ||
import ( | ||
runpb "cloud.google.com/go/run/apiv2/runpb" // MATCH /Import alias "runpb" is redundant/ | ||
|
||
md5 "crypto/md5" // MATCH /Import alias "md5" is redundant/ | ||
|
||
strings "strings" // MATCH /Import alias "strings" is redundant/ | ||
|
||
"crypto/md5" | ||
"strings" | ||
_ "crypto/md5" | ||
str "strings" | ||
strings "strings" // MATCH /Import alias "strings" is redundant/ | ||
crypto "crypto/md5" | ||
md5 "crypto/md5" // MATCH /Import alias "md5" is redundant/ | ||
_ "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) | ||
} |