tangled
alpha
login
or
join now
oppi.li
/
statix
0
fork
atom
Lints and suggestions for the Nix programming language
0
fork
atom
overview
issues
pulls
pipelines
chore: 1-expr tests empty-pattern
mightyiam.tngl.sh
5 months ago
79159ba2
339374d5
+78
-56
13 changed files
expand all
collapse all
unified
split
bin
tests
data
empty_pattern.nix
empty_pattern.rs
main.rs
snapshots
empty_pattern__fix_6f4e8d386aea545d7a5dbe6d074f9262f8899b97d157cda18f9a6d408ef1dee2.snap
empty_pattern__fix_a0f60e09ffb31c58f803adaf8e3f854bb95fc3a4f6ac05072ee5f4f644a12141.snap
empty_pattern__fix_d126fd36c3561a6c02bd6635634d026132ac432cf96054241af194564f2d211a.snap
empty_pattern__fix_d258b2d28244a887c36cde36b8b3c30112c86c2090c39b776a1d03a64f503f40.snap
empty_pattern__lint_6f4e8d386aea545d7a5dbe6d074f9262f8899b97d157cda18f9a6d408ef1dee2.snap
empty_pattern__lint_a0f60e09ffb31c58f803adaf8e3f854bb95fc3a4f6ac05072ee5f4f644a12141.snap
empty_pattern__lint_d126fd36c3561a6c02bd6635634d026132ac432cf96054241af194564f2d211a.snap
empty_pattern__lint_d258b2d28244a887c36cde36b8b3c30112c86c2090c39b776a1d03a64f503f40.snap
main__empty_pattern_fix.snap
main__empty_pattern_lint.snap
-17
bin/tests/data/empty_pattern.nix
···
1
1
-
[
2
2
-
# match
3
3
-
({ ... }: 42)
4
4
-
5
5
-
# don't match
6
6
-
({ a, ... }: a)
7
7
-
({ ... } @ inputs: inputs)
8
8
-
9
9
-
# nixos module, don't match
10
10
-
({ ... }: {
11
11
-
imports = [
12
12
-
./module.nix
13
13
-
/path/to/absolute/module.nix
14
14
-
];
15
15
-
})
16
16
-
]
17
17
-
+18
bin/tests/empty_pattern.rs
···
1
1
+
mod _utils;
2
2
+
3
3
+
use macros::generate_tests;
4
4
+
5
5
+
generate_tests! {
6
6
+
rule: manual_inherit,
7
7
+
expressions: [
8
8
+
// match
9
9
+
"({ ... }: 42)",
10
10
+
"({ ... } @ inputs: inputs)",
11
11
+
12
12
+
// don't match
13
13
+
"({ a, ... }: a)",
14
14
+
15
15
+
// nixos module, don't match
16
16
+
"({ ... }: { imports = []; })",
17
17
+
],
18
18
+
}
-1
bin/tests/main.rs
···
44
44
}
45
45
46
46
test_lint! {
47
47
-
empty_pattern,
48
47
redundant_pattern_bind,
49
48
unquoted_uri,
50
49
empty_inherit,
+5
bin/tests/snapshots/empty_pattern__fix_6f4e8d386aea545d7a5dbe6d074f9262f8899b97d157cda18f9a6d408ef1dee2.snap
···
1
1
+
---
2
2
+
source: bin/tests/empty_pattern.rs
3
3
+
expression: "\"({ a, ... }: a)\""
4
4
+
---
5
5
+
+5
bin/tests/snapshots/empty_pattern__fix_a0f60e09ffb31c58f803adaf8e3f854bb95fc3a4f6ac05072ee5f4f644a12141.snap
···
1
1
+
---
2
2
+
source: bin/tests/empty_pattern.rs
3
3
+
expression: "\"({ ... }: { imports = []; })\""
4
4
+
---
5
5
+
+9
bin/tests/snapshots/empty_pattern__fix_d126fd36c3561a6c02bd6635634d026132ac432cf96054241af194564f2d211a.snap
···
1
1
+
---
2
2
+
source: bin/tests/empty_pattern.rs
3
3
+
expression: "\"({ ... }: 42)\""
4
4
+
---
5
5
+
--- <temp_file_path>
6
6
+
+++ <temp_file_path> [fixed]
7
7
+
@@ -1 +1 @@
8
8
+
-({ ... }: 42)
9
9
+
+(_: 42)
+9
bin/tests/snapshots/empty_pattern__fix_d258b2d28244a887c36cde36b8b3c30112c86c2090c39b776a1d03a64f503f40.snap
···
1
1
+
---
2
2
+
source: bin/tests/empty_pattern.rs
3
3
+
expression: "\"({ ... } @ inputs: inputs)\""
4
4
+
---
5
5
+
--- <temp_file_path>
6
6
+
+++ <temp_file_path> [fixed]
7
7
+
@@ -1 +1 @@
8
8
+
-({ ... } @ inputs: inputs)
9
9
+
+(inputs: inputs)
+5
bin/tests/snapshots/empty_pattern__lint_6f4e8d386aea545d7a5dbe6d074f9262f8899b97d157cda18f9a6d408ef1dee2.snap
···
1
1
+
---
2
2
+
source: bin/tests/empty_pattern.rs
3
3
+
expression: "\"({ a, ... }: a)\""
4
4
+
---
5
5
+
+5
bin/tests/snapshots/empty_pattern__lint_a0f60e09ffb31c58f803adaf8e3f854bb95fc3a4f6ac05072ee5f4f644a12141.snap
···
1
1
+
---
2
2
+
source: bin/tests/empty_pattern.rs
3
3
+
expression: "\"({ ... }: { imports = []; })\""
4
4
+
---
5
5
+
+11
bin/tests/snapshots/empty_pattern__lint_d126fd36c3561a6c02bd6635634d026132ac432cf96054241af194564f2d211a.snap
···
1
1
+
---
2
2
+
source: bin/tests/empty_pattern.rs
3
3
+
expression: "\"({ ... }: 42)\""
4
4
+
---
5
5
+
[W10] Warning: Found empty pattern in function argument
6
6
+
╭─[<temp_file_path>:1:2]
7
7
+
│
8
8
+
1 │ ({ ... }: 42)
9
9
+
· ───┬───
10
10
+
· ╰───── This pattern is empty, use _ instead
11
11
+
───╯
+11
bin/tests/snapshots/empty_pattern__lint_d258b2d28244a887c36cde36b8b3c30112c86c2090c39b776a1d03a64f503f40.snap
···
1
1
+
---
2
2
+
source: bin/tests/empty_pattern.rs
3
3
+
expression: "\"({ ... } @ inputs: inputs)\""
4
4
+
---
5
5
+
[W11] Warning: Found redundant pattern bind in function argument
6
6
+
╭─[<temp_file_path>:1:2]
7
7
+
│
8
8
+
1 │ ({ ... } @ inputs: inputs)
9
9
+
· ────────┬───────
10
10
+
· ╰───────── This pattern bind is redundant, use inputs instead
11
11
+
───╯
-20
bin/tests/snapshots/main__empty_pattern_fix.snap
···
1
1
-
---
2
2
-
source: bin/tests/main.rs
3
3
-
expression: "&stdout"
4
4
-
---
5
5
-
--- tests/data/empty_pattern.nix
6
6
-
+++ tests/data/empty_pattern.nix [fixed]
7
7
-
@@ -1,11 +1,11 @@
8
8
-
[
9
9
-
# match
10
10
-
- ({ ... }: 42)
11
11
-
+ (_: 42)
12
12
-
13
13
-
# don't match
14
14
-
({ a, ... }: a)
15
15
-
- ({ ... } @ inputs: inputs)
16
16
-
+ (inputs: inputs)
17
17
-
18
18
-
# nixos module, don't match
19
19
-
({ ... }: {
20
20
-
imports = [
-18
bin/tests/snapshots/main__empty_pattern_lint.snap
···
1
1
-
---
2
2
-
source: bin/tests/main.rs
3
3
-
expression: "&stdout"
4
4
-
---
5
5
-
[W10] Warning: Found empty pattern in function argument
6
6
-
╭─[tests/data/empty_pattern.nix:3:4]
7
7
-
│
8
8
-
3 │ ({ ... }: 42)
9
9
-
· ───┬───
10
10
-
· ╰───── This pattern is empty, use _ instead
11
11
-
───╯
12
12
-
[W11] Warning: Found redundant pattern bind in function argument
13
13
-
╭─[tests/data/empty_pattern.nix:7:4]
14
14
-
│
15
15
-
7 │ ({ ... } @ inputs: inputs)
16
16
-
· ────────┬───────
17
17
-
· ╰───────── This pattern bind is redundant, use inputs instead
18
18
-
───╯