mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-08 18:52:52 +08:00
Suggest (( expr )) over let expr (#813)
This commit is contained in:
@@ -87,6 +87,7 @@ commandChecks = [
|
|||||||
,checkDeprecatedFgrep
|
,checkDeprecatedFgrep
|
||||||
,checkWhileGetoptsCase
|
,checkWhileGetoptsCase
|
||||||
,checkCatastrophicRm
|
,checkCatastrophicRm
|
||||||
|
,checkLetUsage
|
||||||
]
|
]
|
||||||
|
|
||||||
buildCommandMap :: [CommandCheck] -> Map.Map CommandName (Token -> Analysis)
|
buildCommandMap :: [CommandCheck] -> Map.Map CommandName (Token -> Analysis)
|
||||||
@@ -824,5 +825,13 @@ checkCatastrophicRm = CommandCheck (Basename "rm") $ \t ->
|
|||||||
importantPaths = filter (not . null) $
|
importantPaths = filter (not . null) $
|
||||||
["", "/", "/*", "/*/*"] >>= (\x -> map (++x) paths)
|
["", "/", "/*", "/*/*"] >>= (\x -> map (++x) paths)
|
||||||
|
|
||||||
|
|
||||||
|
prop_checkLetUsage1 = verify checkLetUsage "let a=1"
|
||||||
|
prop_checkLetUsage2 = verifyNot checkLetUsage "(( a=1 ))"
|
||||||
|
checkLetUsage = CommandCheck (Exactly "let") f
|
||||||
|
where
|
||||||
|
f t = whenShell [Bash,Ksh] $ do
|
||||||
|
style (getId t) 2219 $ "Instead of 'let expr', prefer (( expr )) ."
|
||||||
|
|
||||||
return []
|
return []
|
||||||
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
||||||
|
Reference in New Issue
Block a user