From 4e063b2abc402ac4d6902647e821978269025c7d Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 3 Nov 2021 14:48:35 +0530 Subject: add snapshot test suite --- bin/tests/snapshots/main__bool_comparison.snap | 62 ++++++++++++++++++++++ bin/tests/snapshots/main__collapsible_let_in.snap | 17 ++++++ bin/tests/snapshots/main__deprecated_is_null.snap | 13 +++++ bin/tests/snapshots/main__empty_let_in.snap | 14 +++++ bin/tests/snapshots/main__empty_pattern.snap | 20 +++++++ bin/tests/snapshots/main__eta_reduction.snap | 13 +++++ bin/tests/snapshots/main__legacy_let_syntax.snap | 14 +++++ bin/tests/snapshots/main__manual_inherit.snap | 13 +++++ bin/tests/snapshots/main__manual_inherit_from.snap | 20 +++++++ .../snapshots/main__redundant_pattern_bind.snap | 13 +++++ bin/tests/snapshots/main__unquoted_splices.snap | 35 ++++++++++++ bin/tests/snapshots/main__unquoted_uri.snap | 13 +++++ bin/tests/snapshots/main__useless_parens.snap | 48 +++++++++++++++++ 13 files changed, 295 insertions(+) create mode 100644 bin/tests/snapshots/main__bool_comparison.snap create mode 100644 bin/tests/snapshots/main__collapsible_let_in.snap create mode 100644 bin/tests/snapshots/main__deprecated_is_null.snap create mode 100644 bin/tests/snapshots/main__empty_let_in.snap create mode 100644 bin/tests/snapshots/main__empty_pattern.snap create mode 100644 bin/tests/snapshots/main__eta_reduction.snap create mode 100644 bin/tests/snapshots/main__legacy_let_syntax.snap create mode 100644 bin/tests/snapshots/main__manual_inherit.snap create mode 100644 bin/tests/snapshots/main__manual_inherit_from.snap create mode 100644 bin/tests/snapshots/main__redundant_pattern_bind.snap create mode 100644 bin/tests/snapshots/main__unquoted_splices.snap create mode 100644 bin/tests/snapshots/main__unquoted_uri.snap create mode 100644 bin/tests/snapshots/main__useless_parens.snap (limited to 'bin/tests/snapshots') diff --git a/bin/tests/snapshots/main__bool_comparison.snap b/bin/tests/snapshots/main__bool_comparison.snap new file mode 100644 index 0000000..0865332 --- /dev/null +++ b/bin/tests/snapshots/main__bool_comparison.snap @@ -0,0 +1,62 @@ +--- +source: bin/tests/main.rs +expression: "&out" + +--- +[W01] Warning: Unnecessary comparison with boolean + ╭─[data/bool_comparison.nix:3:4] + │ + 3 │ (a == true) + · ────┬──── + · ╰────── Comparing a with boolean literal true +───╯ +[W01] Warning: Unnecessary comparison with boolean + ╭─[data/bool_comparison.nix:4:4] + │ + 4 │ (b == true) + · ────┬──── + · ╰────── Comparing b with boolean literal true +───╯ +[W01] Warning: Unnecessary comparison with boolean + ╭─[data/bool_comparison.nix:5:4] + │ + 5 │ (true == c) + · ────┬──── + · ╰────── Comparing c with boolean literal true +───╯ +[W01] Warning: Unnecessary comparison with boolean + ╭─[data/bool_comparison.nix:6:4] + │ + 6 │ (true == d) + · ────┬──── + · ╰────── Comparing d with boolean literal true +───╯ +[W01] Warning: Unnecessary comparison with boolean + ╭─[data/bool_comparison.nix:9:4] + │ + 9 │ (e != true) + · ────┬──── + · ╰────── Comparing e with boolean literal true +───╯ +[W01] Warning: Unnecessary comparison with boolean + ╭─[data/bool_comparison.nix:10:4] + │ + 10 │ (f != false) + · ─────┬──── + · ╰────── Comparing f with boolean literal false +────╯ +[W01] Warning: Unnecessary comparison with boolean + ╭─[data/bool_comparison.nix:11:4] + │ + 11 │ (true != g) + · ────┬──── + · ╰────── Comparing g with boolean literal true +────╯ +[W01] Warning: Unnecessary comparison with boolean + ╭─[data/bool_comparison.nix:12:4] + │ + 12 │ (false != h) + · ─────┬──── + · ╰────── Comparing h with boolean literal false +────╯ + diff --git a/bin/tests/snapshots/main__collapsible_let_in.snap b/bin/tests/snapshots/main__collapsible_let_in.snap new file mode 100644 index 0000000..b135abc --- /dev/null +++ b/bin/tests/snapshots/main__collapsible_let_in.snap @@ -0,0 +1,17 @@ +--- +source: bin/tests/main.rs +expression: "&out" + +--- +[W06] Warning: These let-in expressions are collapsible + ╭─[data/collapsible_let_in.nix:1:1] + │ + 1 │ ╭───▶ let + 5 │ │ ╭─▶ let + 9 │ │ ├─▶ a + b + c + d + · │ │ │ + · │ ╰───────────────────── This let in expression is nested + · │ │ + · ╰───────────────────┴─── This let in expression contains a nested let in expression +───╯ + diff --git a/bin/tests/snapshots/main__deprecated_is_null.snap b/bin/tests/snapshots/main__deprecated_is_null.snap new file mode 100644 index 0000000..d49b381 --- /dev/null +++ b/bin/tests/snapshots/main__deprecated_is_null.snap @@ -0,0 +1,13 @@ +--- +source: bin/tests/main.rs +expression: "&out" + +--- +[W13] Warning: Found usage of deprecated builtin isNull + ╭─[data/deprecated_is_null.nix:4:4] + │ + 4 │ if isNull e + · ────┬─── + · ╰───── isNull is deprecated, check equality with null instead +───╯ + diff --git a/bin/tests/snapshots/main__empty_let_in.snap b/bin/tests/snapshots/main__empty_let_in.snap new file mode 100644 index 0000000..426692f --- /dev/null +++ b/bin/tests/snapshots/main__empty_let_in.snap @@ -0,0 +1,14 @@ +--- +source: bin/tests/main.rs +expression: "&out" + +--- +[W02] Warning: Useless let-in expression + ╭─[data/empty_let_in.nix:1:1] + │ + 1 │ ╭─▶ let + 3 │ ├─▶ null + · │ + · ╰──────────── This let-in expression has no entries +───╯ + diff --git a/bin/tests/snapshots/main__empty_pattern.snap b/bin/tests/snapshots/main__empty_pattern.snap new file mode 100644 index 0000000..3ea7ae0 --- /dev/null +++ b/bin/tests/snapshots/main__empty_pattern.snap @@ -0,0 +1,20 @@ +--- +source: bin/tests/main.rs +expression: "&out" + +--- +[W10] Warning: Found empty pattern in function argument + ╭─[data/empty_pattern.nix:3:4] + │ + 3 │ ({ ... }: 42) + · ───┬─── + · ╰───── This pattern is empty, use _ instead +───╯ +[W11] Warning: Found redundant pattern bind in function argument + ╭─[data/empty_pattern.nix:7:4] + │ + 7 │ ({ ... } @ inputs: inputs) + · ────────┬─────── + · ╰───────── This pattern bind is redundant, use inputs instead +───╯ + diff --git a/bin/tests/snapshots/main__eta_reduction.snap b/bin/tests/snapshots/main__eta_reduction.snap new file mode 100644 index 0000000..6271980 --- /dev/null +++ b/bin/tests/snapshots/main__eta_reduction.snap @@ -0,0 +1,13 @@ +--- +source: bin/tests/main.rs +expression: "&out" + +--- +[W07] Warning: This function expression is eta reducible + ╭─[data/eta_reduction.nix:11:9] + │ + 11 │ (map (x: double x) xs) + · ─────┬───── + · ╰─────── Found eta-reduction: double +────╯ + diff --git a/bin/tests/snapshots/main__legacy_let_syntax.snap b/bin/tests/snapshots/main__legacy_let_syntax.snap new file mode 100644 index 0000000..35aa7ee --- /dev/null +++ b/bin/tests/snapshots/main__legacy_let_syntax.snap @@ -0,0 +1,14 @@ +--- +source: bin/tests/main.rs +expression: "&out" + +--- +[W05] Warning: Using undocumented `let` syntax + ╭─[data/legacy_let_syntax.nix:1:1] + │ + 1 │ ╭─▶ let { + 5 │ ├─▶ } + · │ + · ╰─────── Prefer rec over undocumented let syntax +───╯ + diff --git a/bin/tests/snapshots/main__manual_inherit.snap b/bin/tests/snapshots/main__manual_inherit.snap new file mode 100644 index 0000000..063867c --- /dev/null +++ b/bin/tests/snapshots/main__manual_inherit.snap @@ -0,0 +1,13 @@ +--- +source: bin/tests/main.rs +expression: "&out" + +--- +[W03] Warning: Assignment instead of inherit + ╭─[data/manual_inherit.nix:7:3] + │ + 7 │ a = a; + · ───┬── + · ╰──── This assignment is better written with inherit +───╯ + diff --git a/bin/tests/snapshots/main__manual_inherit_from.snap b/bin/tests/snapshots/main__manual_inherit_from.snap new file mode 100644 index 0000000..9cf1f5d --- /dev/null +++ b/bin/tests/snapshots/main__manual_inherit_from.snap @@ -0,0 +1,20 @@ +--- +source: bin/tests/main.rs +expression: "&out" + +--- +[W04] Warning: Assignment instead of inherit from + ╭─[data/manual_inherit_from.nix:5:3] + │ + 5 │ b = a.b; + · ────┬─── + · ╰───── This assignment is better written with inherit +───╯ +[W04] Warning: Assignment instead of inherit from + ╭─[data/manual_inherit_from.nix:6:3] + │ + 6 │ c = a.c; + · ────┬─── + · ╰───── This assignment is better written with inherit +───╯ + diff --git a/bin/tests/snapshots/main__redundant_pattern_bind.snap b/bin/tests/snapshots/main__redundant_pattern_bind.snap new file mode 100644 index 0000000..2f26818 --- /dev/null +++ b/bin/tests/snapshots/main__redundant_pattern_bind.snap @@ -0,0 +1,13 @@ +--- +source: bin/tests/main.rs +expression: "&out" + +--- +[W11] Warning: Found redundant pattern bind in function argument + ╭─[data/redundant_pattern_bind.nix:1:1] + │ + 1 │ { ... } @ inputs: null + · ────────┬──────── + · ╰────────── This pattern bind is redundant, use inputs instead +───╯ + diff --git a/bin/tests/snapshots/main__unquoted_splices.snap b/bin/tests/snapshots/main__unquoted_splices.snap new file mode 100644 index 0000000..5fd1917 --- /dev/null +++ b/bin/tests/snapshots/main__unquoted_splices.snap @@ -0,0 +1,35 @@ +--- +source: bin/tests/main.rs +expression: "&out" + +--- +[W09] Warning: Found unquoted splice expression + ╭─[data/unquoted_splices.nix:7:3] + │ + 7 │ ${x} + · ──┬─ + · ╰─── Consider quoting this splice expression +───╯ +[W09] Warning: Found unquoted splice expression + ╭─[data/unquoted_splices.nix:8:3] + │ + 8 │ ${toString (x + y)} + · ─────────┬───────── + · ╰─────────── Consider quoting this splice expression +───╯ +[W09] Warning: Found unquoted splice expression + ╭─[data/unquoted_splices.nix:9:5] + │ + 9 │ a.${toString x} + · ──────┬────── + · ╰──────── Consider quoting this splice expression +───╯ +[W09] Warning: Found unquoted splice expression + ╭─[data/unquoted_splices.nix:12:3] + │ + 12 │ ╭─▶ ${ + 14 │ ├─▶ } + · │ + · ╰───────── Consider quoting this splice expression +────╯ + diff --git a/bin/tests/snapshots/main__unquoted_uri.snap b/bin/tests/snapshots/main__unquoted_uri.snap new file mode 100644 index 0000000..2f0e5a9 --- /dev/null +++ b/bin/tests/snapshots/main__unquoted_uri.snap @@ -0,0 +1,13 @@ +--- +source: bin/tests/main.rs +expression: "&out" + +--- +[W12] Warning: Found unquoted URI expression + ╭─[data/unquoted_uri.nix:1:1] + │ + 1 │ github:nerdypepper/statix + · ────────────┬──────────── + · ╰────────────── Consider quoting this URI expression +───╯ + diff --git a/bin/tests/snapshots/main__useless_parens.snap b/bin/tests/snapshots/main__useless_parens.snap new file mode 100644 index 0000000..d44176e --- /dev/null +++ b/bin/tests/snapshots/main__useless_parens.snap @@ -0,0 +1,48 @@ +--- +source: bin/tests/main.rs +expression: "&out" + +--- +[W08] Warning: These parentheses can be omitted + ╭─[data/useless_parens.nix:16:3] + │ + 16 │ (null) + · ───┬── + · ╰──── Useless parentheses around body of let expression +────╯ +[W08] Warning: These parentheses can be omitted + ╭─[data/useless_parens.nix:4:9] + │ + 4 │ b = ("hello"); + · ────┬──── + · ╰────── Useless parentheses around value in binding +───╯ +[W08] Warning: These parentheses can be omitted + ╭─[data/useless_parens.nix:5:9] + │ + 5 │ c = (d); + · ─┬─ + · ╰─── Useless parentheses around value in binding +───╯ +[W08] Warning: These parentheses can be omitted + ╭─[data/useless_parens.nix:6:9] + │ + 6 │ e = ({ f = 2; }); + · ──────┬───── + · ╰─────── Useless parentheses around value in binding +───╯ +[W08] Warning: These parentheses can be omitted + ╭─[data/useless_parens.nix:10:7] + │ + 10 │ g = (1 + 2); + · ───┬─── + · ╰───── Useless parentheses around value in binding +────╯ +[W08] Warning: These parentheses can be omitted + ╭─[data/useless_parens.nix:11:7] + │ + 11 │ h = ({ inherit i; }); + · ────────┬─────── + · ╰───────── Useless parentheses around value in binding +────╯ + -- cgit v1.2.3