lint: swap IfStmt tests to not skip every other IfStmt in a chain

Fixes golang/lint#382

The fix works by moving the test for ignored nodes after the else-node check.

Change-Id: I508c65ec0b49409a5a7340b5fa5ccc1ccd4a4b05
GitHub-Last-Rev: 738b20a6ab33ac6bc03664eb6887f4951ed3d067
GitHub-Pull-Request: golang/lint#383
Reviewed-on: https://go-review.googlesource.com/97256
Reviewed-by: Alan Donovan <adonovan@google.com>
diff --git a/lint.go b/lint.go
index bb71cc2..46bd45f 100644
--- a/lint.go
+++ b/lint.go
@@ -1045,13 +1045,13 @@
 		if !ok || ifStmt.Else == nil {
 			return true
 		}
-		if ignore[ifStmt] {
-			return true
-		}
 		if elseif, ok := ifStmt.Else.(*ast.IfStmt); ok {
 			ignore[elseif] = true
 			return true
 		}
+		if ignore[ifStmt] {
+			return true
+		}
 		if _, ok := ifStmt.Else.(*ast.BlockStmt); !ok {
 			// only care about elses without conditions
 			return true
diff --git a/testdata/else-multi.go b/testdata/else-multi.go
index 98f39a3..bd68daa 100644
--- a/testdata/else-multi.go
+++ b/testdata/else-multi.go
@@ -16,3 +16,31 @@
 	}
 	return false
 }
+
+func g(x int) int {
+	if x == 0 {
+		log.Print("x is zero")
+	} else if x > 9 {
+		return 2
+	} else if x > 0 {
+		return 1
+	} else {
+		log.Printf("non-positive x: %d", x)
+	}
+	return 0
+}
+
+func h(x int) int {
+	if x == 0 {
+		log.Print("x is zero")
+	} else if x > 99 {
+		return 3
+	} else if x > 9 {
+		return 2
+	} else if x > 0 {
+		return 1
+	} else {
+		log.Printf("non-positive x: %d", x)
+	}
+	return 0
+}