astro / deadnix

Scan Nix files for dead code
GNU General Public License v3.0
512 stars 13 forks source link

Support for line-based exclusion of certain checks #56

Closed kaldonir closed 1 year ago

kaldonir commented 1 year ago

I've got a nix file, which includes a false positive[1] that could be worked around with the -L flag. I want contents of argument-sets to be checked by deadnix, even in this file, so I'd rather not use -L.

I currently have to resort to tricking deadnix into believing that this is not an unused binding, e.g., by including if false then unusedBinding else somewhere, but this feels like a very dirty workaround.

Many other linters or style checkers support some kind of comment that disables certain checks on a function or line. Is this a feature that would make sense for deadnix as well?


[1] My function's parameters need to include pkgs so that the NixOS module system actually feeds it into this function, but pkgs isn't needed in that function itself at all, since the argument set as a whole is handed over to another imported module.