aboutsummaryrefslogtreecommitdiff
path: root/readme.md
blob: 68265cc5d880666149bcb59fff31c3a2c498df1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# statix

> Lints and suggestions for the Nix programming language.

`statix` highlights antipatterns in Nix code. `statix fix`
can fix several such occurrences.

For the time-being, `statix` works only with ASTs
produced by the `rnix-parser` crate and does not evaluate
any nix code (imports, attr sets etc.). 

## Installation

`statix` is available via a nix flake:

```
nix run git+https://git.peppe.rs/languages/statix

# or

nix build git+https://git.peppe.rs/languages/statix
./result/bin/statix --help
```

## Usage

```
statix 0.1.0

Akshay <[email protected]>

Lints and suggestions for the Nix programming language

USAGE:
    statix [FLAGS] [OPTIONS] [--] [TARGET]

ARGS:
    <TARGET>    File or directory to run statix on [default: .]

FLAGS:
    -d, --dry-run    Do not fix files in place, display a diff instead
    -f, --fix        Find and fix issues raised by statix
    -h, --help       Print help information
    -V, --version    Print version information

OPTIONS:
    -i, --ignore <IGNORE>...    Globs of file patterns to skip
    -o, --format <FORMAT>       Output format. Supported values: errfmt, json (on feature flag only)
```

## Architecture

`statix` has the following components:

- `bin`: the CLI/entrypoint
- `lib`: library of lints and utilities to define these
  lints
- `macros`: procedural macros to help define a lint

### `bin`

This is the main point of interaction between `statix`
and the end user. It's output is human-readable and should
also support JSON/errorfmt outputs for external tools to
use.

### `lib`

A library of AST-based lints and utilities to help write
those lints. It should be easy for newcomers to write lints
without being familiar with the rest of the codebase.

### `macros`

This crate intends to be a helper layer to declare lints and
their metadata.

## TODO

- Offline documentation for each lint
- Test suite for lints and suggestions
- Output singleline/errfmt + vim plugin