Make SC2164 recommend die when running in portage

Ebuilds should use "die" for errors instead of "exit" to integrate
cleanly with the rest of the build system.
This commit is contained in:
Benjamin Gordon 2019-07-17 17:42:40 -06:00
commit 8111406f38

View file

@ -2815,14 +2815,15 @@ checkUncheckedCdPushdPopd params root =
&& not (name `elem` ["pushd", "popd"] && ("n" `elem` map snd (getAllFlags t))) && not (name `elem` ["pushd", "popd"] && ("n" `elem` map snd (getAllFlags t)))
&& not (isCondition $ getPath (parentMap params) t)) $ && not (isCondition $ getPath (parentMap params) t)) $
warnWithFix (getId t) 2164 warnWithFix (getId t) 2164
("Use '" ++ name ++ " ... || exit' or '" ++ name ++ " ... || return' in case " ++ name ++ " fails.") ("Use '" ++ name ++ " ... || " ++ exit ++ "' or '" ++ name ++ " ... || return' in case " ++ name ++ " fails.")
(fixWith [replaceEnd (getId t) params 0 " || exit"]) (fixWith [replaceEnd (getId t) params 0 (" || " ++ exit)])
checkElement _ = return () checkElement _ = return ()
getName t = fromMaybe "" $ getCommandName t getName t = fromMaybe "" $ getCommandName t
isSafeDir t = case oversimplify t of isSafeDir t = case oversimplify t of
[_, str] -> str `matches` regex [_, str] -> str `matches` regex
_ -> False _ -> False
regex = mkRegex "^/*((\\.|\\.\\.)/+)*(\\.|\\.\\.)?$" regex = mkRegex "^/*((\\.|\\.\\.)/+)*(\\.|\\.\\.)?$"
exit = if isPortageBuild params then "die" else "exit"
prop_checkLoopVariableReassignment1 = verify checkLoopVariableReassignment "for i in *; do for i in *.bar; do true; done; done" prop_checkLoopVariableReassignment1 = verify checkLoopVariableReassignment "for i in *; do for i in *.bar; do true; done; done"
prop_checkLoopVariableReassignment2 = verify checkLoopVariableReassignment "for i in *; do for((i=0; i<3; i++)); do true; done; done" prop_checkLoopVariableReassignment2 = verify checkLoopVariableReassignment "for i in *; do for((i=0; i<3; i++)); do true; done; done"