oppiliappan / statix

lints and suggestions for the nix programming language
https://git.peppe.rs/languages/statix/about
MIT License
574 stars 21 forks source link

Extra parenthesis are not removed when used with lib.optionals #14

Open SuperSandro2000 opened 3 years ago

SuperSandro2000 commented 3 years ago

The following snippet

  [ ]
  ++ (lib.optionals (cyrus_sasl != null) [ "--enable-cyrus-sasl=yes" ])
  ++ (lib.optionals (gnutls != null) ["--enable-gnutls=yes" "--enable-nss=no"])
  ++ (lib.optionals stdenv.isDarwin ["--disable-gtkspell" "--disable-vv"]);

should be converted to

  [ ]
  ++ lib.optionals (cyrus_sasl != null) [ "--enable-cyrus-sasl=yes" ]
  ++ lib.optionals (gnutls != null) ["--enable-gnutls=yes" "--enable-nss=no"]
  ++ lib.optionals stdenv.isDarwin ["--disable-gtkspell" "--disable-vv"];
oppiliappan commented 3 years ago

Thanks for the report! Currently statix does not remove useless parentheses in binary expressions, like x ++ (y), I am waiting for some parsing changes around operator precedence to land before implementing this.