diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2222131b..2e99802a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: name: Ex${{matrix.elixir}}/OTP${{matrix.otp}} strategy: matrix: - elixir: ['1.14.2', '1.15.7', '1.16.0'] + elixir: ['1.15.7', '1.16.0'] otp: ['25.1.2'] steps: - uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 938ef830..535de59c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ * module directives: various fixes for unreported obscure crashes * pipes: fix a comment-shifting scenario when unpiping +### Breaking Changes + +* drop support for elixir `1.14` + ## v0.11.9 ### Improvements diff --git a/lib/style/single_node.ex b/lib/style/single_node.ex index e8bff9cb..72bfb367 100644 --- a/lib/style/single_node.ex +++ b/lib/style/single_node.ex @@ -34,13 +34,6 @@ defmodule Styler.Style.SingleNode do def run({node, meta}, ctx), do: {:cont, {style(node), meta}, ctx} - # as of 1.15, elixir's formatter takes care of this for us. - if Version.match?(System.version(), "< 1.15.0-dev") do - # 'charlist' => ~c"charlist" - defp style({:__block__, [{:delimiter, ~s|'|} | meta], [chars]}) when is_list(chars), - do: {:sigil_c, [{:delimiter, ~s|"|} | meta], [{:<<>>, [line: meta[:line]], [List.to_string(chars)]}, []]} - end - # rewrite double-quote strings with >= 4 escaped double-quotes as sigils defp style({:__block__, [{:delimiter, ~s|"|} | meta], [string]} = node) when is_binary(string) do # running a regex against every double-quote delimited string literal in a codebase doesn't have too much impact @@ -150,14 +143,12 @@ defmodule Styler.Style.SingleNode do defp style({{:., dm, [{:__aliases__, am, [:Timex]}, :now]}, funm, [tz]}), do: {{:., dm, [{:__aliases__, am, [:DateTime]}, :now!]}, funm, [tz]} - if Version.match?(System.version(), ">= 1.15.0-dev") do - # {DateTime,NaiveDateTime,Time,Date}.compare(a, b) == :lt => {DateTime,NaiveDateTime,Time,Date}.before?(a, b) - # {DateTime,NaiveDateTime,Time,Date}.compare(a, b) == :gt => {DateTime,NaiveDateTime,Time,Date}.after?(a, b) - defp style({:==, _, [{{:., dm, [{:__aliases__, am, [mod]}, :compare]}, funm, args}, {:__block__, _, [result]}]}) - when mod in ~w[DateTime NaiveDateTime Time Date]a and result in [:lt, :gt] do - fun = if result == :lt, do: :before?, else: :after? - {{:., dm, [{:__aliases__, am, [mod]}, fun]}, funm, args} - end + # {DateTime,NaiveDateTime,Time,Date}.compare(a, b) == :lt => {DateTime,NaiveDateTime,Time,Date}.before?(a, b) + # {DateTime,NaiveDateTime,Time,Date}.compare(a, b) == :gt => {DateTime,NaiveDateTime,Time,Date}.after?(a, b) + defp style({:==, _, [{{:., dm, [{:__aliases__, am, [mod]}, :compare]}, funm, args}, {:__block__, _, [result]}]}) + when mod in ~w[DateTime NaiveDateTime Time Date]a and result in [:lt, :gt] do + fun = if result == :lt, do: :before?, else: :after? + {{:., dm, [{:__aliases__, am, [mod]}, fun]}, funm, args} end # Remove parens from 0 arity funs (Credo.Check.Readability.ParenthesesOnZeroArityDefs) diff --git a/mix.exs b/mix.exs index 8f4cd63f..2919c1a6 100644 --- a/mix.exs +++ b/mix.exs @@ -19,7 +19,7 @@ defmodule Styler.MixProject do [ app: :styler, version: @version, - elixir: "~> 1.14", + elixir: "~> 1.15", start_permanent: Mix.env() == :prod, elixirc_paths: elixirc_paths(Mix.env()), deps: deps(), diff --git a/test/style/single_node_test.exs b/test/style/single_node_test.exs index cca3d92b..542ca8fc 100644 --- a/test/style/single_node_test.exs +++ b/test/style/single_node_test.exs @@ -11,14 +11,6 @@ defmodule Styler.Style.SingleNodeTest do use Styler.StyleCase, async: true - if Version.match?(System.version(), "< 1.15.0-dev") do - test "charlist literals: rewrites single quote charlists to ~c" do - assert_style("'foo'", ~s|~c"foo"|) - assert_style(~s|'"'|, ~s|~c"\\""|) - assert_style("''", ~s|~c""|) - end - end - test "string sigil rewrites" do assert_style ~s|""| assert_style ~s|"\\""| @@ -70,20 +62,18 @@ defmodule Styler.Style.SingleNodeTest do end end - if Version.match?(System.version(), ">= 1.15.0-dev") do - test "{DateTime,NaiveDateTime,Time,Date}.compare to {DateTime,NaiveDateTime,Time,Date}.before?" do - assert_style("DateTime.compare(foo, bar) == :lt", "DateTime.before?(foo, bar)") - assert_style("NaiveDateTime.compare(foo, bar) == :lt", "NaiveDateTime.before?(foo, bar)") - assert_style("Time.compare(foo, bar) == :lt", "Time.before?(foo, bar)") - assert_style("Date.compare(foo, bar) == :lt", "Date.before?(foo, bar)") - end + test "{DateTime,NaiveDateTime,Time,Date}.compare to {DateTime,NaiveDateTime,Time,Date}.before?" do + assert_style("DateTime.compare(foo, bar) == :lt", "DateTime.before?(foo, bar)") + assert_style("NaiveDateTime.compare(foo, bar) == :lt", "NaiveDateTime.before?(foo, bar)") + assert_style("Time.compare(foo, bar) == :lt", "Time.before?(foo, bar)") + assert_style("Date.compare(foo, bar) == :lt", "Date.before?(foo, bar)") + end - test "{DateTime,NaiveDateTime,Time,Date}.compare to {DateTime,NaiveDateTime,Time,Date}.after?" do - assert_style("DateTime.compare(foo, bar) == :gt", "DateTime.after?(foo, bar)") - assert_style("NaiveDateTime.compare(foo, bar) == :gt", "NaiveDateTime.after?(foo, bar)") - assert_style("Time.compare(foo, bar) == :gt", "Time.after?(foo, bar)") - assert_style("Time.compare(foo, bar) == :gt", "Time.after?(foo, bar)") - end + test "{DateTime,NaiveDateTime,Time,Date}.compare to {DateTime,NaiveDateTime,Time,Date}.after?" do + assert_style("DateTime.compare(foo, bar) == :gt", "DateTime.after?(foo, bar)") + assert_style("NaiveDateTime.compare(foo, bar) == :gt", "NaiveDateTime.after?(foo, bar)") + assert_style("Time.compare(foo, bar) == :gt", "Time.after?(foo, bar)") + assert_style("Time.compare(foo, bar) == :gt", "Time.after?(foo, bar)") end describe "def / defp" do