From 6b86d78bd7c1616e45d7e83ce184552e380c0ce6 Mon Sep 17 00:00:00 2001 From: Theodor Fiedler Date: Tue, 21 May 2024 12:50:56 +0200 Subject: [PATCH 1/2] Fix some typos --- lib/style.ex | 2 +- lib/style/module_directives.ex | 4 ++-- test/style/pipes_test.exs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/style.ex b/lib/style.ex index 386fe98..0f20ced 100644 --- a/lib/style.ex +++ b/lib/style.ex @@ -169,7 +169,7 @@ defmodule Styler.Style do @doc """ "Fixes" the line numbers of nodes who have had their orders changed via sorting or other methods. - This "fix" siply ensures that comments don't get wrecked as part of us moving AST nodes willy-nilly. + This "fix" simply ensures that comments don't get wrecked as part of us moving AST nodes willy-nilly. The fix is rather naive, and simply enforces the following property on the code: A given node must have a line number less than the following node. diff --git a/lib/style/module_directives.ex b/lib/style/module_directives.ex index 16cafc4..09d0a9b 100644 --- a/lib/style/module_directives.ex +++ b/lib/style/module_directives.ex @@ -333,8 +333,8 @@ defmodule Styler.Style.ModuleDirectives do if Enum.any?(liftable) do # This is a silly hack that helps comments stay put. - # the `cap_line` algo was designed to handle high-line stuff moving up into low line territory, so we set our - # new node to have an abritrarily high line annnnd comments behave! i think. + # The `cap_line` algorithm was designed to handle high-line stuff moving up into low line territory, + # so we set our new node to have an arbitrarily high line so comments stay where they are. m = [line: 999_999] aliases = diff --git a/test/style/pipes_test.exs b/test/style/pipes_test.exs index 49cfe25..82d2365 100644 --- a/test/style/pipes_test.exs +++ b/test/style/pipes_test.exs @@ -482,7 +482,7 @@ defmodule Styler.Style.PipesTest do end describe "simple rewrites" do - test "rewrites anon fun def ahd invoke to use then" do + test "rewrites anonymous function invocation to use then" do assert_style("a |> (& &1).()", "then(a, & &1)") assert_style("a |> (& {&1, &2}).(b)", "(&{&1, &2}).(a, b)") assert_style("a |> (& &1).() |> c", "a |> then(& &1) |> c()") @@ -700,7 +700,7 @@ defmodule Styler.Style.PipesTest do end describe "comments" do - test "unpiping doens't move comment in anon fun" do + test "unpiping doesn't move comment in anonymous function" do assert_style """ aliased = aliases From 3e8813e4356fe24281bf719995b88458987bb0cc Mon Sep 17 00:00:00 2001 From: Theodor Fiedler Date: Tue, 21 May 2024 17:56:17 +0200 Subject: [PATCH 2/2] do not change tone of internal comments --- lib/style/module_directives.ex | 4 ++-- test/style/pipes_test.exs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/style/module_directives.ex b/lib/style/module_directives.ex index 09d0a9b..ecb21fa 100644 --- a/lib/style/module_directives.ex +++ b/lib/style/module_directives.ex @@ -333,8 +333,8 @@ defmodule Styler.Style.ModuleDirectives do if Enum.any?(liftable) do # This is a silly hack that helps comments stay put. - # The `cap_line` algorithm was designed to handle high-line stuff moving up into low line territory, - # so we set our new node to have an arbitrarily high line so comments stay where they are. + # The `cap_line` algo was designed to handle high-line stuff moving up into low line territory, so we set our + # new node to have an arbitrarily high line annnnd comments behave! i think. m = [line: 999_999] aliases = diff --git a/test/style/pipes_test.exs b/test/style/pipes_test.exs index 82d2365..bd6a83c 100644 --- a/test/style/pipes_test.exs +++ b/test/style/pipes_test.exs @@ -482,7 +482,7 @@ defmodule Styler.Style.PipesTest do end describe "simple rewrites" do - test "rewrites anonymous function invocation to use then" do + test "rewrites anonymous function invocations to use then" do assert_style("a |> (& &1).()", "then(a, & &1)") assert_style("a |> (& {&1, &2}).(b)", "(&{&1, &2}).(a, b)") assert_style("a |> (& &1).() |> c", "a |> then(& &1) |> c()")