aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAkshay <[email protected]>2022-02-20 04:07:32 +0000
committerAkshay <[email protected]>2022-02-20 04:07:32 +0000
commite8130a90dca048d195603281f72e1af0b4f7ccc6 (patch)
tree7b722cfc3dcf16417f73ba1577f824782903ad2e /bin
parenta80e252193096f22ae79fa03e66a0853ddae050e (diff)
new lint: bool_simplification
TODO: add more patterns to this
Diffstat (limited to 'bin')
-rw-r--r--bin/tests/data/bool_simplification.nix7
-rw-r--r--bin/tests/main.rs3
-rw-r--r--bin/tests/snapshots/main__bool_simplification.snap13
3 files changed, 22 insertions, 1 deletions
diff --git a/bin/tests/data/bool_simplification.nix b/bin/tests/data/bool_simplification.nix
new file mode 100644
index 0000000..64c2c7a
--- /dev/null
+++ b/bin/tests/data/bool_simplification.nix
@@ -0,0 +1,7 @@
1let
2 _ = !(a == b);
3 # do not match here
4 _ = !(a != b);
5 _ = a != b;
6in
7 null
diff --git a/bin/tests/main.rs b/bin/tests/main.rs
index bec64d2..3403f65 100644
--- a/bin/tests/main.rs
+++ b/bin/tests/main.rs
@@ -63,5 +63,6 @@ test_lint! {
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 faster_zipattrswith => session_info!("2.6"),
66 deprecated_to_path => session_info!("2.4") 66 deprecated_to_path => session_info!("2.4"),
67 bool_simplification
67} 68}
diff --git a/bin/tests/snapshots/main__bool_simplification.snap b/bin/tests/snapshots/main__bool_simplification.snap
new file mode 100644
index 0000000..9e3c991
--- /dev/null
+++ b/bin/tests/snapshots/main__bool_simplification.snap
@@ -0,0 +1,13 @@
1---
2source: bin/tests/main.rs
3expression: "&out"
4
5---
6[W18] Warning: This boolean expression can be simplified
7 ╭─[data/bool_simplification.nix:2:7]
8
9 2 │ _ = !(a == b);
10 · ────┬────
11 · ╰────── Try != instead of !(... == ...)
12───╯
13