From c917670c9193d080fba7e8f5167f0f29752154fa Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 20 Feb 2022 11:29:59 +0530 Subject: useless_has_attr: do not parenthesize select expressions in fixes `select` expresisons are more tightly binding than `or` expressions, we do not have to parenthesize them when placed next to an `or`. --- bin/tests/data/useless_has_attr.nix | 1 + bin/tests/snapshots/main__useless_has_attr.snap | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'bin') diff --git a/bin/tests/data/useless_has_attr.nix b/bin/tests/data/useless_has_attr.nix index f4c9fd5..10966ac 100644 --- a/bin/tests/data/useless_has_attr.nix +++ b/bin/tests/data/useless_has_attr.nix @@ -6,4 +6,5 @@ # complex body (if x ? a then x.a else if b then c else d) + (if x ? a then x.a else b.c) ] diff --git a/bin/tests/snapshots/main__useless_has_attr.snap b/bin/tests/snapshots/main__useless_has_attr.snap index df72eaf..d9b5ac8 100644 --- a/bin/tests/snapshots/main__useless_has_attr.snap +++ b/bin/tests/snapshots/main__useless_has_attr.snap @@ -31,4 +31,11 @@ expression: "&out" · ────────────────────┬──────────────────── · ╰────────────────────── Consider using x.a or (if b then c else d) instead of this if expression ───╯ +[W19] Warning: This `if` expression can be simplified with `or` + ╭─[data/useless_has_attr.nix:9:4] + │ + 9 │ (if x ? a then x.a else b.c) + · ─────────────┬──────────── + · ╰────────────── Consider using x.a or b.c instead of this if expression +───╯ -- cgit v1.2.3