Commit cc532bdd authored by Iustin Pop's avatar Iustin Pop
Browse files

htools: some lint fixes



Removal of duplicate parantheses, removal of extra 'do', conversion from
nested if to guards, use hierarchical imports. All per hlint.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 88253d03
......@@ -74,9 +74,9 @@ module Ganeti.HTools.CLI
, oVerbose
) where
import Control.Monad
import Data.Maybe (fromMaybe)
import qualified Data.Version
import Monad
import System.Console.GetOpt
import System.IO
import System.Info
......
......@@ -33,8 +33,8 @@ module Ganeti.HTools.ExtLoader
, maybeSaveData
) where
import Control.Monad
import Data.Maybe (isJust, fromJust)
import Monad
import System.FilePath
import System.IO
import System
......
......@@ -181,7 +181,7 @@ parseData body = do
rl_names <- extrReq "instances"
rl_insts <- mapM (Container.findByName map_i) rl_names
let rl_idx = map Instance.idx rl_insts
rl_mode <- do
rl_mode <-
case extrReq "reloc_mode" of
Ok s | s == C.iallocatorMrelocKeep -> return KeepGroup
| s == C.iallocatorMrelocChange ->
......
......@@ -478,8 +478,10 @@ showField t field =
"idx" -> printf "%4d" $ idx t
"name" -> alias t
"fqdn" -> name t
"status" -> if offline t then "-"
else if failN1 t then "*" else " "
"status" -> case () of
_ | offline t -> "-"
| failN1 t -> "*"
| otherwise -> " "
"tmem" -> printf "%5.0f" $ tMem t
"nmem" -> printf "%5d" $ nMem t
"xmem" -> printf "%5d" $ xMem t
......
......@@ -260,7 +260,7 @@ prop_Utils_fromObjWithDefault def_value random_key =
-- a found key will be returned as is, not with default
Utils.fromObjWithDefault [(random_key, J.showJSON def_value)]
random_key (def_value+1) == Just def_value
where _types = (def_value :: Integer)
where _types = def_value :: Integer
testUtils =
[ run prop_Utils_commaJoinSplit
......@@ -487,15 +487,15 @@ prop_Text_Load_Instance name mem dsk vcpus status pnode snode pdx sdx autobal =
case inst of
Nothing -> False
Just (_, i) ->
(Instance.name i == name &&
Instance.vcpus i == vcpus &&
Instance.mem i == mem &&
Instance.pNode i == pdx &&
Instance.sNode i == (if null snode
then Node.noSecondary
else rsdx) &&
Instance.auto_balance i == autobal &&
isNothing fail1)
Instance.name i == name &&
Instance.vcpus i == vcpus &&
Instance.mem i == mem &&
Instance.pNode i == pdx &&
Instance.sNode i == (if null snode
then Node.noSecondary
else rsdx) &&
Instance.auto_balance i == autobal &&
isNothing fail1
prop_Text_Load_InstanceFail ktn fields =
length fields /= 9 ==>
......@@ -615,7 +615,7 @@ prop_Node_addSec node inst pdx =
prop_Node_rMem node inst =
-- ab = auto_balance, nb = non-auto_balance
-- we use -1 as the primary node of the instance
let inst' = inst { Instance.pNode = (-1), Instance.auto_balance = True}
let inst' = inst { Instance.pNode = -1, Instance.auto_balance = True }
inst_ab = setInstanceSmallerThanNode node inst'
inst_nb = inst_ab { Instance.auto_balance = False }
-- now we have the two instances, identical except the
......@@ -680,7 +680,7 @@ prop_Node_computeGroups nodes =
in length nodes == sum (map (length . snd) ng) &&
all (\(guuid, ns) -> all ((== guuid) . Node.group) ns) ng &&
length (nub onlyuuid) == length onlyuuid &&
if null nodes then True else not (null ng)
(null nodes || not (null ng))
testNode =
[ run prop_Node_setAlias
......
......@@ -25,9 +25,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
module Main (main) where
import Control.Monad
import Data.List
import Data.Maybe (isJust, fromJust)
import Monad
import System (exitWith, ExitCode(..))
import System.IO
import qualified System
......@@ -85,7 +85,7 @@ readRequest opts args = do
exitWith $ ExitFailure 1
input_data <- readFile (head args)
r1 <- case (parseData input_data) of
r1 <- case parseData input_data of
Bad err -> do
hPutStrLn stderr $ "Error: " ++ err
exitWith $ ExitFailure 1
......
......@@ -27,10 +27,10 @@ module Main (main) where
import Control.Concurrent (threadDelay)
import Control.Exception (bracket)
import Control.Monad
import Data.List
import Data.Maybe (isJust, isNothing, fromJust)
import Data.IORef
import Monad
import System (exitWith, ExitCode(..))
import System.IO
import System.Posix.Process
......@@ -366,14 +366,14 @@ main = do
(optEvacMode opts)
let (Cluster.Table fin_nl fin_il fin_cv fin_plc) = fin_tbl
ord_plc = reverse fin_plc
sol_msg = if null fin_plc
then printf "No solution found\n"
else if verbose > 2
then printf "Final coefficients: overall %.8f, %s\n"
fin_cv (Cluster.printStats fin_nl)
else printf "Cluster score improved from %.8f to %.8f\n"
ini_cv fin_cv
::String
sol_msg = case () of
_ | null fin_plc -> printf "No solution found\n"
| verbose > 2 ->
printf "Final coefficients: overall %.8f, %s\n"
fin_cv (Cluster.printStats fin_nl)
| otherwise ->
printf "Cluster score improved from %.8f to %.8f\n"
ini_cv fin_cv ::String
unless oneline $ putStr sol_msg
......
......@@ -25,8 +25,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
module Main (main) where
import Control.Monad
import Data.Maybe (isJust, fromJust, fromMaybe)
import Monad
import System (exitWith, ExitCode(..))
import System.IO
import System.FilePath
......
......@@ -25,11 +25,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
module Main (main) where
import Control.Monad
import Data.Char (toUpper, isAlphaNum)
import Data.List
import Data.Maybe (isJust, fromJust)
import Data.Ord (comparing)
import Monad
import System (exitWith, ExitCode(..))
import System.IO
import qualified System
......@@ -171,7 +171,7 @@ printAllocationStats m_cpu ini_nl fin_nl = do
-- | Ensure a value is quoted if needed
ensureQuoted :: String -> String
ensureQuoted v = if not (all (\c -> (isAlphaNum c || c == '.')) v)
ensureQuoted v = if not (all (\c -> isAlphaNum c || c == '.') v)
then '\'':v ++ "'"
else v
......
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