git-hooks.nix icon indicating copy to clipboard operation
git-hooks.nix copied to clipboard

Statix runs on `excludes` files.

Open zmrocze opened this issue 2 years ago • 0 comments

Hey, I exclude a generated .nix file from the pre-commit checks, but nevertheless statix fails on that file. That's my simplified flakeParts module:

{ inputs, ... }: {
  imports = [
    inputs.pre-commit-hooks.flakeModule # Adds perSystem.pre-commit options
  ];
  perSystem = { ... }:
    {
      pre-commit = {
        settings = {
          excludes = [
            "spago-packages.nix"
          ];
          hooks = {
            statix.enable = true;
          };
          # this workaround works
          # settings.statix.ignore = [ "spago-packages.nix" ];
        };
      };
    };
}

As said - statix runs and fails on file ./bla/spago-packages.nix, eventhough it's excluded.

pass_filenames

Statix has the option pass_filenames set to false. Though to my understanding ignoring excludes is not the expected behaviour for any formatter. I've checked with some other formatter with pass_filenames=false (with rustfmt), and the excludes field had an effect.

Maybe spago-packages.nix is an import of some other not-excluded file?

No, not directly and statix doesn't analize imports for its contents.

Workaround

If you have this issue check the commented workaround in the nix snippet.

zmrocze avatar Apr 25 '23 11:04 zmrocze