Switch getLiteralStringExt to Identity where it can never be Nothing
This commit is contained in:
parent
aaffe38198
commit
f8648e5465
|
@ -1066,9 +1066,7 @@ checkNumberComparisons params (TC_Binary id typ op lhs rhs) = do
|
||||||
checkStrings =
|
checkStrings =
|
||||||
mapM_ stringError . take 1 . filter isNonNum
|
mapM_ stringError . take 1 . filter isNonNum
|
||||||
|
|
||||||
isNonNum t = fromMaybe False $ do
|
isNonNum t = not . all numChar . runIdentity $ getLiteralStringExt (const $ return "") t
|
||||||
s <- getLiteralStringExt (const $ return "") t
|
|
||||||
return . not . all numChar $ s
|
|
||||||
numChar x = isDigit x || x `elem` "+-. "
|
numChar x = isDigit x || x `elem` "+-. "
|
||||||
|
|
||||||
stringError t = err (getId t) 2170 $
|
stringError t = err (getId t) 2170 $
|
||||||
|
@ -2595,7 +2593,7 @@ checkTildeInPath _ (T_SimpleCommand _ vars _) =
|
||||||
warn id 2147 "Literal tilde in PATH works poorly across programs."
|
warn id 2147 "Literal tilde in PATH works poorly across programs."
|
||||||
checkVar _ = return ()
|
checkVar _ = return ()
|
||||||
|
|
||||||
hasTilde t = fromMaybe False (liftM2 elem (return '~') (getLiteralStringExt (const $ return "") t))
|
hasTilde t = '~' `elem` runIdentity (getLiteralStringExt (const $ return "") t)
|
||||||
isQuoted T_DoubleQuoted {} = True
|
isQuoted T_DoubleQuoted {} = True
|
||||||
isQuoted T_SingleQuoted {} = True
|
isQuoted T_SingleQuoted {} = True
|
||||||
isQuoted _ = False
|
isQuoted _ = False
|
||||||
|
|
|
@ -249,13 +249,12 @@ prop_checkGrepRe23= verifyNot checkGrepRe "grep '.*' file"
|
||||||
checkGrepRe = CommandCheck (Basename "grep") check where
|
checkGrepRe = CommandCheck (Basename "grep") check where
|
||||||
check cmd = f cmd (arguments cmd)
|
check cmd = f cmd (arguments cmd)
|
||||||
-- --regex=*(extglob) doesn't work. Fixme?
|
-- --regex=*(extglob) doesn't work. Fixme?
|
||||||
skippable (Just s) = not ("--regex=" `isPrefixOf` s) && "-" `isPrefixOf` s
|
skippable s = not ("--regex=" `isPrefixOf` s) && "-" `isPrefixOf` s
|
||||||
skippable _ = False
|
|
||||||
f _ [] = return ()
|
f _ [] = return ()
|
||||||
f cmd (x:r) =
|
f cmd (x:r) =
|
||||||
let str = getLiteralStringExt (const $ return "_") x
|
let str = runIdentity $ getLiteralStringExt (const $ return "_") x
|
||||||
in
|
in
|
||||||
if str `elem` [Just "--", Just "-e", Just "--regex"]
|
if str `elem` ["--", "-e", "--regex"]
|
||||||
then checkRE cmd r -- Regex is *after* this
|
then checkRE cmd r -- Regex is *after* this
|
||||||
else
|
else
|
||||||
if skippable str
|
if skippable str
|
||||||
|
@ -366,7 +365,7 @@ checkFindExecWithSingleArgument = CommandCheck (Basename "find") (f . arguments)
|
||||||
check (exec:arg:term:_) = do
|
check (exec:arg:term:_) = do
|
||||||
execS <- getLiteralString exec
|
execS <- getLiteralString exec
|
||||||
termS <- getLiteralString term
|
termS <- getLiteralString term
|
||||||
cmdS <- getLiteralStringExt (const $ return " ") arg
|
let cmdS = runIdentity $ getLiteralStringExt (const $ return " ") arg
|
||||||
|
|
||||||
guard $ execS `elem` ["-exec", "-execdir"] && termS `elem` [";", "+"]
|
guard $ execS `elem` ["-exec", "-execdir"] && termS `elem` [";", "+"]
|
||||||
guard $ cmdS `matches` commandRegex
|
guard $ cmdS `matches` commandRegex
|
||||||
|
|
Loading…
Reference in New Issue