oppiliappan / statix

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

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

Open SuperSandro2000 opened 2 years ago

SuperSandro2000 commented 2 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 2 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.