-
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.
chore: add missing tests for var-declarations, fix any/interface{} ty…
…pe issue
- Loading branch information
1 parent
b532dc8
commit 52534df
Showing
4 changed files
with
40 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/mgechev/revive/lint" | ||
"github.com/mgechev/revive/rule" | ||
) | ||
|
||
func TestVarDeclarations(t *testing.T) { | ||
testRule(t, "var_declarations_type_inference", &rule.VarDeclarationsRule{}, &lint.RuleConfig{}) | ||
testRule(t, "var_declarations_zero_value", &rule.VarDeclarationsRule{}, &lint.RuleConfig{}) | ||
} |
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,6 @@ | ||
package fixtures | ||
|
||
func typeInferenceExample() { | ||
var x int = 42 // MATCH /should omit type int from declaration of var x; it will be inferred from the right-hand side/ | ||
var y = 42 // No warning, type is inferred | ||
} |
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,9 @@ | ||
package fixtures | ||
|
||
func zeroValueExample() { | ||
var y int // No warning, zero value is implicit | ||
var z1 any = 0 // No warning, zero value for any is nil | ||
var z2 any = nil // MATCH /should drop = nil from declaration of var z2; it is the zero value/ | ||
var z3 interface{} = 0 // No warning, zero value for any is nil | ||
var z4 interface{} = nil // MATCH /should drop = nil from declaration of var z4; it is the zero value/ | ||
} |