From 84779a6f7da93bd6325f478c62c82cc0a1a2e341 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 28 Dec 2012 19:54:15 +0100 Subject: Remove unnecessary parentheses around if conditions Pet peeve... --- pkgs/lib/misc.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'pkgs/lib/misc.nix') diff --git a/pkgs/lib/misc.nix b/pkgs/lib/misc.nix index b6f86d45dd8..79504f7d886 100644 --- a/pkgs/lib/misc.nix +++ b/pkgs/lib/misc.nix @@ -53,7 +53,7 @@ rec { f : # the function applied to the arguments initial : # you pass attrs, the functions below are passing a function taking the fix argument let - takeFixed = if (isFunction initial) then initial else (fixed : initial); # transform initial to an expression always taking the fixed argument + takeFixed = if isFunction initial then initial else (fixed : initial); # transform initial to an expression always taking the fixed argument tidy = args : let # apply all functions given in "applyPreTidy" in sequence applyPreTidyFun = fold ( n : a : x : n ( a x ) ) lib.id (maybeAttr "applyPreTidy" [] args); @@ -106,11 +106,11 @@ rec { # shortcut for attrByPath ["name"] default attrs maybeAttrNullable = name: default: attrs: if attrs == null then default else - if (__hasAttr name attrs) then (__getAttr name attrs) else default; + if __hasAttr name attrs then (__getAttr name attrs) else default; # shortcut for attrByPath ["name"] default attrs maybeAttr = name: default: attrs: - if (__hasAttr name attrs) then (__getAttr name attrs) else default; + if __hasAttr name attrs then (__getAttr name attrs) else default; # Return the second argument if the first one is true or the empty version @@ -120,14 +120,14 @@ rec { else if builtins.isList val then [] else if builtins.isAttrs val then {} # else if builtins.isString val then "" - else if (val == true || val == false) then false + else if val == true || val == false then false else null; # Return true only if there is an attribute and it is true. checkFlag = attrSet: name: - if (name == "true") then true else - if (name == "false") then false else + if name == "true" then true else + if name == "false" then false else if (elem name (attrByPath ["flags"] [] attrSet)) then true else attrByPath [name] false attrSet ; @@ -170,7 +170,7 @@ rec { uniqListExt = {inputList, outputList ? [], getter ? (x : x), compare ? (x: y: x==y)}: - if (inputList == []) then outputList else + if inputList == [] then outputList else let x=head inputList; isX = y: (compare (getter y) (getter x)); newOutputList = outputList ++ @@ -362,7 +362,7 @@ rec { cfgWithDefaults = (listToAttrs (map (n : nameValuePair (flagName n) false) (attrNames args2.flags))) // args2.cfg; opts = attrValues (mapAttrs (a : v : - let v2 = if (v ? set || v ? unset) then v else { set = v; }; + let v2 = if v ? set || v ? unset then v else { set = v; }; n = if (getAttr (flagName a) cfgWithDefaults) then "set" else "unset"; attr = maybeAttr n {} v2; in if (maybeAttr "assertion" true attr) -- cgit 1.4.1