Commit 0c76f280 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add hlint warning for wrong use of 'length'

While removing split instances check from hcheck, I saw a wrong use of
'length': this should only be used when one needs the actual length of
the list, and not when one wants to check whether the list is empty or
not (in that case, 'null' should be used).

To prevent this in the future, let's add a hlint hint for it, and fix
the warning it generates in hbal.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarAgata Murawska <>
parent b1a9d630
......@@ -328,7 +328,7 @@ checkGroup verbose gname nl il = do
"Initial check done: %d bad nodes, %d bad instances.\n"
(length bad_nodes) (length bad_instances)
when (length bad_nodes > 0) $
when (not (null bad_nodes)) $
putStrLn "Cluster is not N+1 happy, continuing but no guarantee \
\that the cluster will end N+1 happy."
......@@ -4,3 +4,8 @@ warn = map (\v -> (v, x)) y ==> zip y (repeat x)
where _ = notIn v x
warn = map (\v -> (x, v)) ==> zip (repeat x)
where _ = notIn v x
-- The following warn on use of length instead of null
warn = length x > 0 ==> not (null x)
warn = length x /= 0 ==> not (null x)
warn = length x == 0 ==> null x
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