From bd2facb24512fd6c5787f4641e8f437f65692063 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 9 Sep 2017 16:07:38 -0700 Subject: [PATCH] Suggest (( expr )) over let expr (#813) --- ShellCheck/Checks/Commands.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ShellCheck/Checks/Commands.hs b/ShellCheck/Checks/Commands.hs index 3523a0c..cae11fe 100644 --- a/ShellCheck/Checks/Commands.hs +++ b/ShellCheck/Checks/Commands.hs @@ -87,6 +87,7 @@ commandChecks = [ ,checkDeprecatedFgrep ,checkWhileGetoptsCase ,checkCatastrophicRm + ,checkLetUsage ] buildCommandMap :: [CommandCheck] -> Map.Map CommandName (Token -> Analysis) @@ -824,5 +825,13 @@ checkCatastrophicRm = CommandCheck (Basename "rm") $ \t -> importantPaths = filter (not . null) $ ["", "/", "/*", "/*/*"] >>= (\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 [] runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])