Merge pull request #1222 from ngzhian/196

Suppress SC2016 for git filter-branch (fixes #196)
This commit is contained in:
Vidar Holen 2018-05-13 15:45:20 -07:00 committed by GitHub
commit 48ebd41e22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -788,6 +788,8 @@ prop_checkSingleQuotedVariables11= verifyNot checkSingleQuotedVariables "sed '${
prop_checkSingleQuotedVariables12= verifyNot checkSingleQuotedVariables "eval 'echo $1'" prop_checkSingleQuotedVariables12= verifyNot checkSingleQuotedVariables "eval 'echo $1'"
prop_checkSingleQuotedVariables13= verifyNot checkSingleQuotedVariables "busybox awk '{print $1}'" prop_checkSingleQuotedVariables13= verifyNot checkSingleQuotedVariables "busybox awk '{print $1}'"
prop_checkSingleQuotedVariables14= verifyNot checkSingleQuotedVariables "[ -v 'bar[$foo]' ]" prop_checkSingleQuotedVariables14= verifyNot checkSingleQuotedVariables "[ -v 'bar[$foo]' ]"
prop_checkSingleQuotedVariables15= verifyNot checkSingleQuotedVariables "git filter-branch 'test $GIT_COMMIT'"
prop_checkSingleQuotedVariables16= verify checkSingleQuotedVariables "git '$a'"
checkSingleQuotedVariables params t@(T_SingleQuoted id s) = checkSingleQuotedVariables params t@(T_SingleQuoted id s) =
when (s `matches` re) $ when (s `matches` re) $
if "sed" == commandName if "sed" == commandName
@ -800,7 +802,7 @@ checkSingleQuotedVariables params t@(T_SingleQuoted id s) =
commandName = fromMaybe "" $ do commandName = fromMaybe "" $ do
cmd <- getClosestCommand parents t cmd <- getClosestCommand parents t
name <- getCommandBasename cmd name <- getCommandBasename cmd
return $ if name == "find" then getFindCommand cmd else name return $ if name == "find" then getFindCommand cmd else if name == "git" then getGitCommand cmd else name
isProbablyOk = isProbablyOk =
any isOkAssignment (take 3 $ getPath parents t) any isOkAssignment (take 3 $ getPath parents t)
@ -818,6 +820,7 @@ checkSingleQuotedVariables params t@(T_SingleQuoted id s) =
,"docker" -- like above ,"docker" -- like above
,"dpkg-query" ,"dpkg-query"
,"jq" -- could also check that user provides --arg ,"jq" -- could also check that user provides --arg
,"git filter-branch"
] ]
|| "awk" `isSuffixOf` commandName || "awk" `isSuffixOf` commandName
|| "perl" `isPrefixOf` commandName || "perl" `isPrefixOf` commandName
@ -841,6 +844,12 @@ checkSingleQuotedVariables params t@(T_SingleQuoted id s) =
_ -> "find" _ -> "find"
getFindCommand (T_Redirecting _ _ cmd) = getFindCommand cmd getFindCommand (T_Redirecting _ _ cmd) = getFindCommand cmd
getFindCommand _ = "find" getFindCommand _ = "find"
getGitCommand (T_SimpleCommand _ _ words) =
case map getLiteralString words of
Just "git":Just "filter-branch":_ -> "git filter-branch"
_ -> "git"
getGitCommand (T_Redirecting _ _ cmd) = getGitCommand cmd
getGitCommand _ = "git"
checkSingleQuotedVariables _ _ = return () checkSingleQuotedVariables _ _ = return ()