Don't suggest removing $ in (( 10#$n ))
This commit is contained in:
parent
ca5af5c55a
commit
4f1fd43360
|
@ -998,9 +998,14 @@ prop_checkArithmeticDeref3 = verifyNot checkArithmeticDeref "cow=1/40; (( s+= ${
|
||||||
prop_checkArithmeticDeref4 = verifyNot checkArithmeticDeref "(( ! $? ))"
|
prop_checkArithmeticDeref4 = verifyNot checkArithmeticDeref "(( ! $? ))"
|
||||||
prop_checkArithmeticDeref5 = verifyNot checkArithmeticDeref "(($1))"
|
prop_checkArithmeticDeref5 = verifyNot checkArithmeticDeref "(($1))"
|
||||||
prop_checkArithmeticDeref6 = verifyNot checkArithmeticDeref "(( ${a[$i]} ))"
|
prop_checkArithmeticDeref6 = verifyNot checkArithmeticDeref "(( ${a[$i]} ))"
|
||||||
checkArithmeticDeref _ (TA_Expansion _ (T_DollarBraced id l)) | not . excepting $ bracedString l =
|
prop_checkArithmeticDeref7 = verifyNot checkArithmeticDeref "(( 10#$n ))"
|
||||||
style id 2004 $ "Don't use $ on variables in (( ))."
|
checkArithmeticDeref params t@(TA_Expansion _ (T_DollarBraced id l)) =
|
||||||
|
when (not $ (excepting $ bracedString l) || inBaseExpression) $
|
||||||
|
style id 2004 $ "$ on variables in (( )) is unnecessary."
|
||||||
where
|
where
|
||||||
|
inBaseExpression = any isBase $ parents params t
|
||||||
|
isBase (TA_Base {}) = True
|
||||||
|
isBase _ = False
|
||||||
excepting [] = True
|
excepting [] = True
|
||||||
excepting s = (any (`elem` "/.:#%?*@[]") s) || (isDigit $ head s)
|
excepting s = (any (`elem` "/.:#%?*@[]") s) || (isDigit $ head s)
|
||||||
checkArithmeticDeref _ _ = return ()
|
checkArithmeticDeref _ _ = return ()
|
||||||
|
@ -1139,6 +1144,8 @@ getPath tree t = t :
|
||||||
Nothing -> []
|
Nothing -> []
|
||||||
Just parent -> getPath tree parent
|
Just parent -> getPath tree parent
|
||||||
|
|
||||||
|
parents params t = getPath (parentMap params) t
|
||||||
|
|
||||||
--- Command specific checks
|
--- Command specific checks
|
||||||
|
|
||||||
checkCommand str f t@(T_SimpleCommand id _ (cmd:rest)) =
|
checkCommand str f t@(T_SimpleCommand id _ (cmd:rest)) =
|
||||||
|
|
Loading…
Reference in New Issue