From 3a3c1eb4dc10a093c380dd5e6627c600a2c6b0e7 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 14 Oct 2009 16:02:53 +0200 Subject: [PATCH] More hlint fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes (for now) the code hlint-clean. This is per se not a huge gain, but it allows easier tracking of regressions in style later (one-two new violations are easier to diagnose when not hidden among 20 βknownβ ones). --- Ganeti/HTools/Container.hs | 2 +- Ganeti/HTools/QC.hs | 10 +++++----- Ganeti/Luxi.hs | 4 +--- test.hs | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Ganeti/HTools/Container.hs b/Ganeti/HTools/Container.hs index 0313cb40f..937676ca9 100644 --- a/Ganeti/HTools/Container.hs +++ b/Ganeti/HTools/Container.hs @@ -69,7 +69,7 @@ size = IntMap.size -- | Locate a key in the map (must exist). find :: Key -> Container a -> a -find k c = c IntMap.! k +find k = (IntMap.! k) -- | Add or update one element to the map. add :: Key -> a -> Container a -> Container a diff --git a/Ganeti/HTools/QC.hs b/Ganeti/HTools/QC.hs index 429edd11b..1d831425a 100644 --- a/Ganeti/HTools/QC.hs +++ b/Ganeti/HTools/QC.hs @@ -170,13 +170,13 @@ prop_Instance_runStatus_True inst = let run_st = Instance.running inst run_tx = Instance.runSt inst in - run_tx == "running" || run_tx == "ERROR_up" ==> run_st == True + run_tx == "running" || run_tx == "ERROR_up" ==> run_st prop_Instance_runStatus_False inst = let run_st = Instance.running inst run_tx = Instance.runSt inst in - run_tx /= "running" && run_tx /= "ERROR_up" ==> run_st == False + run_tx /= "running" && run_tx /= "ERROR_up" ==> not run_st testInstance = [ run prop_Instance_setIdx @@ -200,7 +200,7 @@ prop_Text_Load_Instance name mem dsk vcpus status pnode snode pdx sdx = else sdx ndx = [(pnode, pdx), (rsnode, rsdx)] inst = Text.loadInst ndx - (name:mem_s:dsk_s:vcpus_s:status:pnode:rsnode:[]):: + [name, mem_s, dsk_s, vcpus_s, status, pnode, rsnode]:: Maybe (String, Instance.Instance) _types = ( name::String, mem::Int, dsk::Int , vcpus::Int, status::String @@ -249,10 +249,10 @@ testNode = -- | Check that the cluster score is close to zero for a homogeneous cluster prop_Score_Zero node count = - ((not $ Node.offline node) && (not $ Node.failN1 node) && (count > 0) && + (not (Node.offline node) && not (Node.failN1 node) && (count > 0) && (Node.tDsk node > 0) && (Node.tMem node > 0)) ==> let fn = Node.buildPeers node Container.empty - nlst = (zip [1..] $ replicate count fn)::[(Types.Ndx, Node.Node)] + nlst = zip [1..] $ replicate count fn::[(Types.Ndx, Node.Node)] nl = Container.fromAssocList nlst score = Cluster.compCV nl -- we can't say == 0 here as the floating point errors accumulate; diff --git a/Ganeti/Luxi.hs b/Ganeti/Luxi.hs index 41d38e9df..7b7265ef2 100644 --- a/Ganeti/Luxi.hs +++ b/Ganeti/Luxi.hs @@ -114,9 +114,7 @@ sendMsg s buf = sbytes <- withTimeout queryTimeout "sending luxi message" $ S.send (socket s) obuf - (if sbytes == length obuf - then return () - else _send (drop sbytes obuf)) + unless (sbytes == length obuf) $ _send (drop sbytes obuf) in _send (buf ++ [eOM]) -- | Waits for a message over a luxi transport. diff --git a/test.hs b/test.hs index 85470e6ae..421b30056 100644 --- a/test.hs +++ b/test.hs @@ -58,7 +58,7 @@ wrapTest ir t to = do main :: IO () main = do errs <- newIORef 0 - let wrap lst = map (wrapTest errs) lst + let wrap = map (wrapTest errs) runTests "PeerMap" options $ wrap testPeerMap runTests "Container" options $ wrap testContainer runTests "Instance" options $ wrap testInstance @@ -66,7 +66,7 @@ main = do runTests "Text" options $ wrap testText runTests "Cluster" options $ wrap testCluster terr <- readIORef errs - (if (terr > 0) + (if terr > 0 then do hPutStrLn stderr $ "A total of " ++ show terr ++ " tests failed." exitWith $ ExitFailure 1 -- GitLab