Added checks for tr a-z A-Z and [asdf]
This commit is contained in:
parent
ba5bb488d1
commit
131b9f0517
|
@ -63,6 +63,7 @@ basicChecks = [
|
||||||
,checkOrNeq
|
,checkOrNeq
|
||||||
,checkEcho
|
,checkEcho
|
||||||
,checkConstantIfs
|
,checkConstantIfs
|
||||||
|
,checkTrAZ
|
||||||
]
|
]
|
||||||
|
|
||||||
modifyMap = modify
|
modifyMap = modify
|
||||||
|
@ -447,6 +448,22 @@ checkPrintfVar = checkCommand "printf" f where
|
||||||
else return ()
|
else return ()
|
||||||
|
|
||||||
|
|
||||||
|
prop_checkTrAZ1 = verify checkTrAZ "tr [a-f] [A-F]"
|
||||||
|
prop_checkTrAZ2 = verify checkTrAZ "tr 'a-z' 'A-Z'"
|
||||||
|
prop_checkTrAZ3 = verifyNot checkTrAZ "tr -d '[:lower:]'"
|
||||||
|
prop_checkTrAZ4 = verifyNot checkTrAZ "ls [a-z]"
|
||||||
|
checkTrAZ = checkCommand "tr" (mapM_ f)
|
||||||
|
where
|
||||||
|
f word = case getLiteralString word of
|
||||||
|
Just "a-z" -> info (getId word) "Use '[:lower:]' to support accents and foreign alphabets."
|
||||||
|
Just "A-Z" -> info (getId word) "Use '[:upper:]' to support accents and foreign alphabets."
|
||||||
|
Just s -> unless ("[:" `isPrefixOf` s) $
|
||||||
|
when ("[" `isPrefixOf` s && "]" `isSuffixOf` s && (length s > 2)) $
|
||||||
|
info (getId word) "Don't use [] around ranges in tr, it replaces literal square brackets."
|
||||||
|
Nothing -> return ()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Subshell detection
|
--- Subshell detection
|
||||||
|
|
||||||
prop_subshellAssignmentCheck = verifyFull subshellAssignmentCheck "cat foo | while read bar; do a=$bar; done; echo \"$a\""
|
prop_subshellAssignmentCheck = verifyFull subshellAssignmentCheck "cat foo | while read bar; do a=$bar; done; echo \"$a\""
|
||||||
|
|
Loading…
Reference in New Issue