Skip to content

Commit

Permalink
Merge pull request #42 from toastal/read
Browse files Browse the repository at this point in the history
README fixups
  • Loading branch information
astro authored Nov 5, 2022
2 parents e351b88 + d545db1 commit 42f1a0b
Showing 1 changed file with 46 additions and 70 deletions.
116 changes: 46 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,93 +11,69 @@ See [deadnix-action](https://github.com/astro/deadnix-action)

### Help

```
```console
$ nix run github:astro/deadnix -- --help
```

```
USAGE:
deadnix [OPTIONS] [FILE_PATHS]...
ARGS:
<FILE_PATHS>... .nix files, or directories with .nix files inside [default: .]
OPTIONS:
-_, --no-underscore
Don't check any bindings that start with a _
-e, --edit
Remove unused code and write to source file
-f, --fail
Exit with 1 if unused code has been found
-h, --hidden
Recurse into hidden subdirectories and process hidden .*.nix files
--help
Print help information
-l, --no-lambda-arg
Don't check lambda parameter arguments
-L, --no-lambda-pattern-names
Don't check lambda attrset pattern names (don't break nixpkgs callPackage)
-o, --output-format <OUTPUT_FORMAT>
Output format to use [default: human-readable] [possible values: human-readable, json]
-q, --quiet
Don't print dead code report
-V, --version
Print version information
Find dead code in .nix files

Usage: deadnix [OPTIONS] [FILE_PATHS]...

Arguments:
[FILE_PATHS]... .nix files, or directories with .nix files inside [default: .]

Options:
-l, --no-lambda-arg
Don't check lambda parameter arguments
-L, --no-lambda-pattern-names
Don't check lambda attrset pattern names (don't break nixpkgs callPackage)
-_, --no-underscore
Don't check any bindings that start with a _
-q, --quiet
Don't print dead code report
-e, --edit
Remove unused code and write to source file
-h, --hidden
Recurse into hidden subdirectories and process hidden .*.nix files
--help
-f, --fail
Exit with 1 if unused code has been found
-o, --output-format <OUTPUT_FORMAT>
Output format to use [default: human-readable] [possible values: human-readable, json]
-V, --version
Print version information
```

Reports contain ANSI color escape codes unless the
[`$NO_COLOR`](https://no-color.org/) environment variable is set.

### Scan for unused code

```
$ nix run github:astro/deadnix test.nix
```

```
```console
$ nix run github:astro/deadnix example.nix
Warning: Unused declarations were found.
╭─[example.nix:1:1]
1 │ unusedArgs@{ unusedArg, usedArg, ... }:
· ─────┬──── ────┬────
· │ ╰────── Unused lambda pattern: unusedArg
· │
· ╰────────────────── Unused lambda pattern: unusedArgs
3 │ inherit (builtins) unused_inherit;
· ───────┬──────
· ╰──────── Unused let binding: unused_inherit
5 │ unused = "fnord";
· ───┬──
· ╰──── Unused let binding: unused
10 │ shadowed = 42;
· ────┬───
· ╰───── Unused let binding: shadowed
11 │ _unused = unused: false;
· ───┬─── ───┬──
· │ ╰──── Unused lambda argument: unused
· │
· ╰────────────── Unused let binding: _unused
13 │ x = { unusedArg2, x ? args.y, ... }@args: used1 + x;
· ─────┬────
· ╰────── Unused lambda pattern: unusedArg2
────╯
1 │unusedArgs@{ unusedArg, usedArg, ... }:
· │ ╰───── Unused lambda pattern: unusedArg
· ╰───────────────── Unused lambda pattern: unusedArgs
3 │ inherit (builtins) unused_inherit;
· ╰─────── Unused let binding: unused_inherit
5 │ unused = "fnord";
· ╰─── Unused let binding: unused
10 │ shadowed = 42;
· ╰──── Unused let binding: shadowed
11 │ _unused = unused: false;
· │ ╰─── Unused lambda argument: unused
· ╰───────────── Unused let binding: _unused
13 │ x = { unusedArg2, x ? args.y, ... }@args: used1 + x;
· ╰───── Unused lambda pattern: unusedArg2
```


### Remove unused code automatically

**Do commit** your changes into version control **before!**

```
```console
$ nix run github:astro/deadnix -- -eq test.nix
```

Expand Down

0 comments on commit 42f1a0b

Please sign in to comment.