Merge pull request #1100 from mkhl/SC2029

SC2029: Skip when there are options to ssh
This commit is contained in:
koalaman 2018-01-24 19:38:38 -08:00 committed by GitHub
commit a840f4e464
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -482,13 +482,13 @@ checkInteractiveSu = CommandCheck (Basename "su") f
prop_checkSshCmdStr1 = verify checkSshCommandString "ssh host \"echo $PS1\""
prop_checkSshCmdStr2 = verifyNot checkSshCommandString "ssh host \"ls foo\""
prop_checkSshCmdStr3 = verifyNot checkSshCommandString "ssh \"$host\""
prop_checkSshCmdStr4 = verifyNot checkSshCommandString "ssh -i key \"$host\""
checkSshCommandString = CommandCheck (Basename "ssh") (f . arguments)
where
nonOptions =
filter (\x -> not $ "-" `isPrefixOf` concat (oversimplify x))
isOption x = "-" `isPrefixOf` (concat $ oversimplify x)
f args =
case nonOptions args of
(hostport:r@(_:_)) -> checkArg $ last r
case partition isOption args of
([], hostport:r@(_:_)) -> checkArg $ last r
_ -> return ()
checkArg (T_NormalWord _ [T_DoubleQuoted id parts]) =
case filter (not . isConstant) parts of