Commit 66ad857a authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix a few issues found by newer hlint



Testing with a newer hlint found a few minor issues; but all are real,
valid recommendations:

- don't use "if cond then f x else f y", but "f (if cond then x else y)"
- "if a then b else True" is equivalent to the simpler "not a || b"
- and as usual, one more ignore to our "testing basic properties"
  module
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent f51eacf3
......@@ -45,6 +45,7 @@ import Ganeti.BasicTypes
{-# ANN module "HLint: ignore Monad law, left identity" #-}
{-# ANN module "HLint: ignore Monad law, right identity" #-}
{-# ANN module "HLint: ignore Use >=>" #-}
{-# ANN module "HLint: ignore Use ." #-}
-- * Arbitrary instances
......
......@@ -64,9 +64,7 @@ prop_assignIndices =
Loader.assignIndices (map (\n -> (Node.name n, n)) nodes)
in Map.size nassoc == length nodes &&
Container.size kt == length nodes &&
if not (null nodes)
then maximum (IntMap.keys kt) == length nodes - 1
else True
(null nodes || maximum (IntMap.keys kt) == length nodes - 1)
-- | Checks that the number of primary instances recorded on the nodes
-- is zero.
......
......@@ -828,11 +828,11 @@ findBestAllocGroup mggl mgnl mgil allowed_gdxs inst cnt =
goodSols = filterMGResults mggl sols
sortedSols = sortMGResults mggl goodSols
in if null sortedSols
then if null groups'
then Bad $ "no groups for evacuation: allowed groups was" ++
show allowed_gdxs ++ ", all groups: " ++
show (map fst groups)
else Bad $ intercalate ", " all_msgs
then Bad $ if null groups'
then "no groups for evacuation: allowed groups was" ++
show allowed_gdxs ++ ", all groups: " ++
show (map fst groups)
else intercalate ", " all_msgs
else let (final_group, final_sol) = head sortedSols
in return (final_group, final_sol, all_msgs)
......
......@@ -312,12 +312,12 @@ main opts args = do
clusterstats = map sum . transpose . map snd $ groupsstats
needrebalance = clusterNeedsRebalance clusterstats
unless (verbose == 0 || machineread) $
if nosimulation
then putStrLn "Running in no-simulation mode."
else if needrebalance
then putStrLn "Cluster needs rebalancing."
else putStrLn "No need to rebalance cluster, no problems found."
unless (verbose == 0 || machineread) .
putStrLn $ if nosimulation
then "Running in no-simulation mode."
else if needrebalance
then "Cluster needs rebalancing."
else "No need to rebalance cluster, no problems found."
mapM_ (printGroupStats verbose machineread Initial) groupsstats
......
......@@ -287,9 +287,9 @@ recvMsg s = do
recvMsgExt :: Client -> IO RecvResult
recvMsgExt s =
catch (liftM RecvOk (recvMsg s)) $ \e ->
if isEOFError e
then return RecvConnClosed
else return $ RecvError (show e)
return $ if isEOFError e
then RecvConnClosed
else RecvError (show e)
-- | Serialize a request to String.
buildCall :: LuxiOp -- ^ The method
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment