PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: bombsimon/wsl (go)

Issue:
False-positive "if statements should only be cuddled with assignments used in the if statement itself"
What exactly does this check want me to change, or is this a false-positive?

Repro:
```go
foo := bar.Baz(foobar)
if t, ok := data[foo]; ok {
  data["hello."+foo] = t
  delete(data, foo)
}
```

Pull request:
Allow cuddle with variables used as index
This fixes #26 

Patch:
diff --git a/wsl.go b/wsl.go
index 3dcc32b..ba6119e 100644
--- a/wsl.go
+++ b/wsl.go
@@ -113,6 +113,7 @@ func NewProcessor() *Processor {
 
 // ProcessFiles takes a string slice with file names (full paths) and lints
 // them.
+// nolint: gocritic
 func (p *Processor) ProcessFiles(filenames []string) ([]Result, []string) {
 	for _, filename := range filenames {
 		data, err := ioutil.ReadFile(filename)
@@ -244,14 +245,6 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
 			calledOrAssignedOnLineAbove = append(calledOnLineAbove, assignedOnLineAbove...)
 		)
 
-		/*
-			DEBUG:
-			fmt.Println("LHS: ", leftHandSide)
-			fmt.Println("RHS: ", rightHandSide)
-			fmt.Println("Assigned above: ", assignedOnLineAbove)
-			fmt.Println("Assigned first: ", assignedFirstInBlock)
-		*/
-
 		// If we called some kind of lock on the line above we allow cuddling
 		// anything.
 		if atLeastOneInListsMatch(calledOnLineAbove, p.config.AllowCuddleWithCalls) {
@@ -282,6 +275,7 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
 			//     t.X = true
 			//     return t
 			// }
+			// nolint: gocritic
 			if i == len(statements)-1 && i == 1 {
 				if p.nodeEnd(stmt)-p.nodeStart(previousStatement) <= 2 {
 					return true
@@ -664,6 +658,9 @@ func (p *Processor) findRHS(node ast.Node) []string {
 		return p.findRHS(t.Call)
 	case *ast.SendStmt:
 		return p.findLHS(t.Value)
+	case *ast.IndexExpr:
+		rhs = append(rhs, p.findRHS(t.Index)...)
+		rhs = append(rhs, p.findRHS(t.X)...)
 	default:
 		if x, ok := maybeX(t); ok {
 			return p.findRHS(x)
@@ -726,6 +723,7 @@ func atLeastOneInListsMatch(listOne, listTwo []string) bool {
 // findLeadingAndTrailingWhitespaces will find leading and trailing whitespaces
 // in a node. The method takes comments in consideration which will make the
 // parser more gentle.
+// nolint: gocognit
 func (p *Processor) findLeadingAndTrailingWhitespaces(stmt, nextStatement ast.Node) {
 	var (
 		allowedLinesBeforeFirstStatement = 1


Test patch:
diff --git a/wsl_test.go b/wsl_test.go
index c37b903..7616393 100644
--- a/wsl_test.go
+++ b/wsl_test.go
@@ -961,6 +961,29 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				"expressions should not be cuddled with blocks",
 			},
 		},
+		{
+			description: "indexes in maps and arrays",
+			code: []byte(`package main
+
+			func main() {
+				for i := range make([]int, 10) {
+					key := GetKey()
+					if val, ok := someMap[key]; ok {
+						fmt.Println("ok!")
+					}
+
+					someOtherMap := GetMap()
+					if val, ok := someOtherMap[key]; ok {
+						fmt.Println("ok")
+					}
+
+					someIndex := 3
+					if val := someSlice[someIndex]; val != nil {
+						retunr
+					}
+				}
+			}`),
+		},
 	}
 
 	for _, tc := range cases {