Skip to content

Commit

Permalink
Add Elixir 1.17 and OTP 27 to CI, fixing warnings (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoefmoraes authored Sep 14, 2024
1 parent 2130438 commit 518a471
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ jobs:
run_plugin_tests: true
run_integration_tests: true
warnings_as_errors: true
- elixir: '1.16.0'
otp: '26.2.1'
- elixir: '1.17.0'
otp: '27.0.1'
check_formatted: true
run_plugin_tests: true
run_integration_tests: true
warnings_as_errors: true
- elixir: '1.17.0'
otp: '27.0.1'
update_deps: true
run_plugin_tests: true
env:
Expand Down
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
erlang 27.0.1
elixir 1.17.2-otp-27
5 changes: 2 additions & 3 deletions lib/mix/tasks/surface/surface.init/ex_patcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,8 @@ defmodule Mix.Tasks.Surface.Init.ExPatcher do
end

defp to_string_opts() do
"mix.exs"
|> Mix.Tasks.Format.formatter_opts_for_file()
|> Keyword.take([:line_length])
{_formatter, opts} = Mix.Tasks.Format.formatter_for_file("mix.exs")
Keyword.take(opts, [:line_length])
end

defp get_code_by_range(code, range) do
Expand Down
6 changes: 3 additions & 3 deletions lib/surface/catalogue/data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ defmodule Surface.Catalogue.Data do
Access.at(value)
end

def access_fun(from..to = range) when is_integer(from) and is_integer(to) do
def access_fun(from..to//1 = range) when is_integer(from) and is_integer(to) do
slice(range)
end

Expand Down Expand Up @@ -244,14 +244,14 @@ defmodule Surface.Catalogue.Data do
{:lists.reverse(gets), :lists.reverse(updates)}
end

defp get_and_update_slice(list, from..to, next, updates, gets, -1) do
defp get_and_update_slice(list, from..to//1, next, updates, gets, -1) do
list_length = length(list)
from = normalize_range_bound(from, list_length)
to = normalize_range_bound(to, list_length)
get_and_update_slice(list, from..to, next, updates, gets, 0)
end

defp get_and_update_slice([head | rest], from..to = range, next, updates, gets, index) do
defp get_and_update_slice([head | rest], from..to//1 = range, next, updates, gets, index) do
new_index = index + 1

if index >= from and index <= to do
Expand Down
6 changes: 3 additions & 3 deletions test/surface/components/link_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ defmodule Surface.Components.LinkTest do
html = render_surface(do: ~F[<Link label="foo" to={{:javascript, "alert(<1>)"}} />])
assert html =~ ~s[<a href="javascript:alert(&lt;1&gt;)">foo</a>]

html = render_surface(do: ~F[<Link label="foo" to={{:javascript, 'alert(<1>)'}} />])
html = render_surface(do: ~F[<Link label="foo" to={{:javascript, ~c"alert(<1>)"}} />])
assert html =~ ~s[<a href="javascript:alert(&lt;1&gt;)">foo</a>]

html = render_surface(do: ~F[<Link label="foo" to={{:javascript, {:safe, "alert(<1>)"}}} />])

assert html =~ ~s[<a href="javascript:alert(<1>)">foo</a>]

html = render_surface(do: ~F[<Link label="foo" to={{:javascript, {:safe, 'alert(<1>)'}}} />])
html = render_surface(do: ~F[<Link label="foo" to={{:javascript, {:safe, ~c"alert(<1>)"}}} />])

assert html =~ ~s[<a href="javascript:alert(<1>)">foo</a>]
end
Expand All @@ -212,7 +212,7 @@ defmodule Surface.Components.LinkTest do
end

assert_raise ArgumentError, ~r"unsupported scheme given to <Link />", fn ->
render_surface(do: ~F[<Link label="foo" to={{:safe, 'javascript:alert(<1>)'}} />])
render_surface(do: ~F[<Link label="foo" to={{:safe, ~c"javascript:alert(<1>)"}} />])
end
end
end
Expand Down

0 comments on commit 518a471

Please sign in to comment.