aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.nix22
-rw-r--r--notes.txt3
-rw-r--r--readme.md86
3 files changed, 77 insertions, 34 deletions
diff --git a/flake.nix b/flake.nix
index a319266..2c1db03 100644
--- a/flake.nix
+++ b/flake.nix
@@ -60,8 +60,10 @@
60 cargo 60 cargo
61 ]; 61 ];
62 buildPhase = '' 62 buildPhase = ''
63 cargo build -p statix --release --offline 63 cargo build -p statix --all-features --release --offline
64 ''; 64 '';
65 # statix does not have any tests currently
66 doCheck = false;
65 installPhase = '' 67 installPhase = ''
66 install -Dm775 ./target/release/statix $out/bin/statix 68 install -Dm775 ./target/release/statix $out/bin/statix
67 ''; 69 '';
@@ -85,19 +87,17 @@
85 devShell = forAllSystems (system: 87 devShell = forAllSystems (system:
86 let 88 let
87 pkgs = nixpkgsFor.${system}; 89 pkgs = nixpkgsFor.${system};
88 inherit (rustChannel pkgs) rust rust-src; 90 inherit (rustChannel pkgs) rust rust-src rust-analysis;
89 in 91 in
90 with pkgs; 92 with pkgs;
91 mkShell rec { 93 mkShell rec {
92 buildInputs = 94 buildInputs = [
93 [ 95 rustfmt
94 rust-analyzer 96 cargo
95 rustfmt 97 cargo-watch
96 cargo 98 rust
97 cargo-watch 99 rust-src
98 rust 100 ];
99 rust-src
100 ];
101 RUST_SRC_PATH = "${rust-src}/lib/rustlib/src/rust/library"; 101 RUST_SRC_PATH = "${rust-src}/lib/rustlib/src/rust/library";
102 RUST_LOG = "info"; 102 RUST_LOG = "info";
103 RUST_BACKTRACE = 1; 103 RUST_BACKTRACE = 1;
diff --git a/notes.txt b/notes.txt
index 73d9439..071e502 100644
--- a/notes.txt
+++ b/notes.txt
@@ -37,6 +37,9 @@ Lint ideas
37- invalid or potentially risky string interpolations 37- invalid or potentially risky string interpolations
38- useless parens in infix exprs 38- useless parens in infix exprs
39- unused function params 39- unused function params
40- manual map over list
41- merge inherit
42- merge inherit-from
40 43
41Extensions 44Extensions
42---------- 45----------
diff --git a/readme.md b/readme.md
index 68265cc..293b72e 100644
--- a/readme.md
+++ b/readme.md
@@ -2,50 +2,82 @@
2 2
3> Lints and suggestions for the Nix programming language. 3> Lints and suggestions for the Nix programming language.
4 4
5`statix` highlights antipatterns in Nix code. `statix fix` 5`statix` highlights antipatterns in Nix code. `statix --fix`
6can fix several such occurrences. 6can fix several such occurrences.
7 7
8For the time-being, `statix` works only with ASTs 8For the time-being, `statix` works only with ASTs
9produced by the `rnix-parser` crate and does not evaluate 9produced by the `rnix-parser` crate and does not evaluate
10any nix code (imports, attr sets etc.). 10any nix code (imports, attr sets etc.).
11 11
12## Examples
13
14```shell
15$ statix tests/c.nix
16[W04] Warning: Assignment instead of inherit from
17 ╭─[tests/c.nix:2:3]
18
19 2 │ mtl = pkgs.haskellPackages.mtl;
20 · ───────────────┬───────────────
21 · ╰───────────────── This assignment is better written with inherit
22───╯
23
24$ statix --fix --dry-run tests/c.nix
25--- tests/c.nix
26+++ tests/c.nix [fixed]
27@@ -1,6 +1,6 @@
28 let
29- mtl = pkgs.haskellPackages.mtl;
30+ inherit (pkgs.haskellPackages) mtl;
31 in
32 null
33```
34
12## Installation 35## Installation
13 36
14`statix` is available via a nix flake: 37`statix` is available via a nix flake:
15 38
16``` 39```shell
17nix run git+https://git.peppe.rs/languages/statix 40# build from source
18
19# or
20
21nix build git+https://git.peppe.rs/languages/statix 41nix build git+https://git.peppe.rs/languages/statix
22./result/bin/statix --help 42./result/bin/statix --help
43
44# statix also provides a flake app
45nix run git+https://git.peppe.rs/languages/statix -- --help
46
47# save time on builds using cachix
48cachix use statix
23``` 49```
24 50
25## Usage 51## Usage
26 52
27``` 53Basic usage is as simple as:
28statix 0.1.0
29 54
30Akshay <[email protected]> 55```shell
56# recursively finds nix files and raises lints
57statix /path/to/dir
31 58
32Lints and suggestions for the Nix programming language 59# ignore generated files, such as Cargo.nix
60statix /path/to/dir -i '*Cargo.nix'
33 61
34USAGE: 62# see `statix -h` for a full list of options
35 statix [FLAGS] [OPTIONS] [--] [TARGET] 63```
36 64
37ARGS: 65Certain lints have suggestions. Apply suggestions back to
38 <TARGET> File or directory to run statix on [default: .] 66the source with:
39 67
40FLAGS: 68```shell
41 -d, --dry-run Do not fix files in place, display a diff instead 69statix --fix /path/to/file
42 -f, --fix Find and fix issues raised by statix
43 -h, --help Print help information
44 -V, --version Print version information
45 70
46OPTIONS: 71# show diff, do not write to file
47 -i, --ignore <IGNORE>... Globs of file patterns to skip 72statix --fix --dry-run /path/to/file
48 -o, --format <FORMAT> Output format. Supported values: errfmt, json (on feature flag only) 73```
74
75`statix` supports a variety of output formats; standard,
76json and errfmt:
77
78```shell
79statix /path/to/dir -o json
80statix /path/to/dir -o errfmt # singleline, easy to integrate with vim
49``` 81```
50 82
51## Architecture 83## Architecture
@@ -55,6 +87,7 @@ OPTIONS:
55- `bin`: the CLI/entrypoint 87- `bin`: the CLI/entrypoint
56- `lib`: library of lints and utilities to define these 88- `lib`: library of lints and utilities to define these
57 lints 89 lints
90- `vfs`: virtual filesystem
58- `macros`: procedural macros to help define a lint 91- `macros`: procedural macros to help define a lint
59 92
60### `bin` 93### `bin`
@@ -70,6 +103,11 @@ A library of AST-based lints and utilities to help write
70those lints. It should be easy for newcomers to write lints 103those lints. It should be easy for newcomers to write lints
71without being familiar with the rest of the codebase. 104without being familiar with the rest of the codebase.
72 105
106### `vfs`
107
108VFS is an in-memory filesystem. It provides cheap-to-copy
109handles (`FileId`s) to access paths and file contents.
110
73### `macros` 111### `macros`
74 112
75This crate intends to be a helper layer to declare lints and 113This crate intends to be a helper layer to declare lints and
@@ -79,4 +117,6 @@ their metadata.
79 117
80- Offline documentation for each lint 118- Offline documentation for each lint
81- Test suite for lints and suggestions 119- Test suite for lints and suggestions
82- Output singleline/errfmt + vim plugin 120- Vim plugin (qf list population, apply suggestions)
121- Resolve imports and scopes for better lints
122- Add silent flag that exits with status