aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAkshay <[email protected]>2022-01-30 06:40:21 +0000
committerAkshay <[email protected]>2022-01-30 06:40:21 +0000
commita254edfcd27f1bba5eb7eacb11bfcd077bd1af16 (patch)
tree6cf3eb3df65952b49f6539607741eca2e65ba149 /bin
parenteffe06e2f16f5b6faab258ff2b031dd5f14d59ec (diff)
new lint: faster_zipattrswith
Diffstat (limited to 'bin')
-rw-r--r--bin/tests/data/faster_zipattrswith.nix13
-rw-r--r--bin/tests/main.rs5
-rw-r--r--bin/tests/snapshots/main__faster_zipattrswith.snap20
3 files changed, 36 insertions, 2 deletions
diff --git a/bin/tests/data/faster_zipattrswith.nix b/bin/tests/data/faster_zipattrswith.nix
new file mode 100644
index 0000000..2612995
--- /dev/null
+++ b/bin/tests/data/faster_zipattrswith.nix
@@ -0,0 +1,13 @@
1{
2 # trivial case
3 _ = lib.zipAttrsWith (name: values: values) [{ a = 1; } { a = 2; b = 3; }];
4
5 # offer lint heuristically on this too
6 _ = nixpkgs.lib.zipAttrsWith (name: values: values) [{ a = 1; } { a = 2; b = 3; }];
7
8 # do not lint on `builtins`
9 _ = builtins.zipAttrsWith (name: values: values) [
10 { a = 1; }
11 { a = 2; b = 3; }
12 ];
13}
diff --git a/bin/tests/main.rs b/bin/tests/main.rs
index 89d58e7..2c4b521 100644
--- a/bin/tests/main.rs
+++ b/bin/tests/main.rs
@@ -19,7 +19,7 @@ mod util {
19 test_lint!($($tail)*); 19 test_lint!($($tail)*);
20 }; 20 };
21 ($tname:ident) => { 21 ($tname:ident) => {
22 test_lint!($tname => session_info!("2.5")); 22 test_lint!($tname => session_info!("2.6"));
23 }; 23 };
24 ($tname:ident => $sess:expr) => { 24 ($tname:ident => $sess:expr) => {
25 #[test] 25 #[test]
@@ -61,5 +61,6 @@ test_lint! {
61 unquoted_uri, 61 unquoted_uri,
62 deprecated_is_null, 62 deprecated_is_null,
63 empty_inherit, 63 empty_inherit,
64 faster_groupby => session_info!("2.5") 64 faster_groupby => session_info!("2.5"),
65 faster_zipattrswith => session_info!("2.6")
65} 66}
diff --git a/bin/tests/snapshots/main__faster_zipattrswith.snap b/bin/tests/snapshots/main__faster_zipattrswith.snap
new file mode 100644
index 0000000..6b21322
--- /dev/null
+++ b/bin/tests/snapshots/main__faster_zipattrswith.snap
@@ -0,0 +1,20 @@
1---
2source: bin/tests/main.rs
3expression: "&out"
4
5---
6[W16] Warning: Found lib.zipAttrsWith
7 ╭─[data/faster_zipattrswith.nix:3:7]
8
9 3 │ _ = lib.zipAttrsWith (name: values: values) [{ a = 1; } { a = 2; b = 3; }];
10 · ────────┬───────
11 · ╰───────── Prefer builtins.zipAttrsWith over lib.zipAttrsWith
12───╯
13[W16] Warning: Found lib.zipAttrsWith
14 ╭─[data/faster_zipattrswith.nix:6:7]
15
16 6 │ _ = nixpkgs.lib.zipAttrsWith (name: values: values) [{ a = 1; } { a = 2; b = 3; }];
17 · ────────────┬───────────
18 · ╰───────────── Prefer builtins.zipAttrsWith over nixpkgs.lib.zipAttrsWith
19───╯
20