Skip to content

Commit 9724af7

Browse files
committed
allow underscore assignments in node containers
1 parent 97de4a9 commit 9724af7

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

linter/ginkgo_linter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func checkAssignments(pass *analysis.Pass, list []ast.Stmt) bool {
239239
case *ast.AssignStmt:
240240
for i, val := range st.Rhs {
241241
if _, isFunc := val.(*ast.FuncLit); !isFunc {
242-
if id, isIdent := st.Lhs[i].(*ast.Ident); isIdent {
242+
if id, isIdent := st.Lhs[i].(*ast.Ident); isIdent && id.Name != "_" {
243243
reportNoFix(pass, id.Pos(), useBeforeEachTemplate, id.Name)
244244
foundSomething = true
245245
}

testdata/src/a/vars-in-containers/all_containers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ var _ = Describe("When's", func() {
1111
shouldNotTriggerWarningEither = 2
1212
)
1313

14+
_ = getValue()
15+
1416
When("test When", func() {
1517
const shouldNotTriggerWarning = 3
1618
const (

testdata/src/a/vars-in-containers/vars.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ type Human struct {
1010
ID string `json:"id"`
1111
}
1212

13+
func getValue() int {
14+
return 42
15+
}
16+
1317
var _ = Describe("vars in Describe", func() {
1418
var a = 1 // want `use BeforeEach\(\) to assign variable a`
1519
var (
@@ -27,6 +31,8 @@ var _ = Describe("vars in Describe", func() {
2731
g, h, valid2 int
2832
)
2933

34+
_ = getValue()
35+
3036
if b == "testing" {
3137
d = b // want `use BeforeEach\(\) to assign variable d`
3238
} else {

0 commit comments

Comments
 (0)