From fed4a048bccb7eccf30b5a18cab8e567114c8672 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Fri, 13 Aug 2021 23:11:20 -0700 Subject: [PATCH] Suppress SC2167 when name is "_" (fixes #2298) --- src/ShellCheck/Analytics.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index a415ca2..a45b2eb 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -3069,6 +3069,7 @@ checkUncheckedCdPushdPopd params root = prop_checkLoopVariableReassignment1 = verify checkLoopVariableReassignment "for i in *; do for i in *.bar; do true; done; done" prop_checkLoopVariableReassignment2 = verify checkLoopVariableReassignment "for i in *; do for((i=0; i<3; i++)); do true; done; done" prop_checkLoopVariableReassignment3 = verifyNot checkLoopVariableReassignment "for i in *; do for j in *.bar; do true; done; done" +prop_checkLoopVariableReassignment4 = verifyNot checkLoopVariableReassignment "for _ in *; do for _ in *.bar; do true; done; done" checkLoopVariableReassignment params token = sequence_ $ case token of T_ForIn {} -> check @@ -3077,6 +3078,7 @@ checkLoopVariableReassignment params token = where check = do str <- loopVariable token + guard $ str /= "_" next <- find (\x -> loopVariable x == Just str) path return $ do warn (getId token) 2165 "This nested loop overrides the index variable of its parent."