扫描 Nix 文件以查找死代码
Scan .nix files for dead code (unused variable bindings).
See deadnix-action
…
Reports contain ANSI color escape codes unless the
$NO_COLOR environment variable is set.
The --exclude parameter accepts multiple paths. Separate them with
-- to pass [FILE_PATHS]....
…
Do commit your changes into version control before!
nix run github:astro/deadnix -- -eq test.nix
Add the following to your project's .pre-commit-config.yaml:
repos:
- repo: https://github.com/astro/deadnix
rev: ID # frozen: VERSION
hooks:
- id: deadnix
#args: [--edit] # Uncomment to automatically modify files
stages: [commit]
Replace ID and VERSION above with the relevant version tag and
commit ID for reference, for example:
rev: da39a3ee5e6b4b0d3255bfef95601890afd80709 # frozen: v1.2.3
_If you disfavor marking them as unused, use option
-l/--no-lambda-arg.
callPackages with multiple importscallPackages guesses the packages to inject by the names of a
packages' lambda attrset pattern names. Some packages alias these with
@args to pass them to another import ...nix args.
As the used args are only named in the imported file they will be
recognized as dead in the package source file that is imported by
callPackage, rendering it unable to guess the dependencies to call
the packages with.
Use option -L/--no-lambda-pattern-names in this case.
As of 1.1.0 deadnix supports the following pragma to skip check of bindings in the following line:
# deadnix: skip
Please open an issue. Do not forget to include the .nix code that
produces incorrect results.
The author can be hired to implement the features that you wish, or to integrate this tool into your toolchain.
暂无开放 Issues,或尚未同步最近议题。