Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--exclude option has no effect #77

Open
montchr opened this issue Mar 14, 2024 · 3 comments
Open

--exclude option has no effect #77

montchr opened this issue Mar 14, 2024 · 3 comments

Comments

@montchr
Copy link

montchr commented Mar 14, 2024

As titled:

$ deadnix --exclude packages/shells/cod/default.nix -- \
| grep packages --context=3

 70 │                  (final: prev: {
    │                     ╰─── Unused lambda argument: final
Warning: Unused declarations were found.
   ╭─[./packages/shells/cod/default.nix:2:3]
 2 │  stdenv,
   │     ╰─── Unused lambda pattern: stdenv
Warning: Unused declarations were found.
$ deadnix --exclude packages/shells/cod/default.nix -- packages/shells/cod/default.nix \
| grep packages --context=3

Warning: Unused declarations were found.
   ╭─[packages/shells/cod/default.nix:2:3]
 2 │  stdenv,
   │     ╰─── Unused lambda pattern: stdenv

Edit: This is v1.2.0 from nixos-unstable. I figured that'd be the most recent, but it looks like there's also v1.2.1. However, it makes no difference:

$ nix run github:astro/deadnix -- --exclude packages/shells/cod/default.nix -- packages/shells/cod/default.nix
Warning: Unused declarations were found.
   ╭─[packages/shells/cod/default.nix:2:3]
 2 │  stdenv,
   │     ╰─── Unused lambda pattern: stdenv
@astro
Copy link
Owner

astro commented Mar 14, 2024

Reason: packages/shells/cod/default.nix != ./packages/shells/cod/default.nix. You could run with explicit path rather than the default ..

Should we canonicalize more paths?

@montchr
Copy link
Author

montchr commented Mar 14, 2024

Aha, you're right -- I included the leading ./ and that worked.

You could run with explicit path rather than the default ..

True, though the example I provided was limited to provide a demonstration. Basically my goal was to use --no-lambda-pattern-names for everything under ./packages, but omit that flag everywhere else. Here's what I ended up with in my project's Justfile:

https://codeberg.org/montchr/dotfield/src/commit/f295a2f295e571588b4b64c692a4ec6503e59b39/Justfile#L80-L84

deadnix-params := '--no-underscore'

# <- Lint files
lint: (deadnix '--fail')
  statix check

# <- Write linter fixes to files
fix: (deadnix "--edit")
  statix fix

[private]
deadnix ARGS='--fail':
  fd -t f -e nix --exclude='packages/**/*.nix' --exec-batch \
    deadnix {{ARGS}} {{deadnix-params}}
  fd -t f -e nix . packages --exec-batch \
    deadnix {{ARGS}} --no-lambda-pattern-names {{deadnix-params}}

Should we canonicalize more paths?

Could you clarify what you mean by "canonicalize" in this context?

@astro
Copy link
Owner

astro commented Mar 14, 2024

Could you clarify what you mean by "canonicalize" in this context?

I mean adding more Path::canonicalize() than we already have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants