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

[Bug] Empty Pattern in `nixosModule` #31

Closed maydayv7 closed 2 years ago

maydayv7 commented 2 years ago

Original File:

{ ... }: rec { imports = [ ./console.nix ./firmware.nix ]; }

Lint:

$ statix check
[W10] Warning: Found empty pattern in function argument
   ╭─[./modules/base/default.nix:1:1]
   │
 1 │ { ... }: rec { imports = [ ./console.nix ./firmware.nix ]; }
   · ───┬───  
   ·    ╰───── This pattern is empty, use _ instead
───╯

File after using statix fix:

_: rec { imports = [ ./console.nix ./firmware.nix ]; }

Error:

$ nix flake check
error: module must match an open attribute set ('{ config, ... }')
 … while checking the NixOS module 'nixosModules.base'

Using statix 0.4.0 on NixOS 21.11 with Nix 2.5

maydayv7 commented 2 years ago

Just got to know that imports is smart enough to handle removing all parameters in a module, so closing this issue

oppiliappan commented 2 years ago

The suggestion by statix for modules should probably be { }: and not _:. I do think this is still a valid bug.

maydayv7 commented 2 years ago

The suggestion by statix for modules should probably be { }: and not _:. I do think this is still a valid bug.

Actually even { }: instead of { ... }: produces an error anonymous function called with unexpected argument

oppiliappan commented 2 years ago

Understood, in that case not raising this issue on modules is the best idea.

oppiliappan commented 2 years ago

Should be fixed on latest master, thanks for the report!