Skip to content

Commit 50b5d82

Browse files
committed
Fix deprecation warnings
1 parent 003d214 commit 50b5d82

File tree

8 files changed

+18
-16
lines changed

8 files changed

+18
-16
lines changed

lib/application.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ defmodule M51.Application do
2828
@impl true
2929
def start(_type, args) do
3030
if Enum.member?(System.argv(), "--debug") do
31-
Logger.warn("Starting in debug mode")
31+
Logger.warning("Starting in debug mode")
3232
Logger.configure(level: :debug)
3333
else
3434
Logger.configure(level: :info)

lib/format/common.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ defmodule M51.Format do
112112
|> :mochiweb_html.to_html()
113113
|> IO.iodata_to_binary()
114114

115-
html = Regex.replace(~R(<html>(.*\)</html>), html, fn _, content -> content end)
115+
html = Regex.replace(~r(<html>(.*\)</html>), html, fn _, content -> content end)
116116
# more compact
117-
html = Regex.replace(~R(<br />), html, fn _ -> "<br/>" end)
117+
html = Regex.replace(~r(<br />), html, fn _ -> "<br/>" end)
118118

119119
{plain_text, html}
120120
end

lib/format/irc2matrix.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ defmodule M51.Format.Irc2Matrix do
238238
def tokenize(text) do
239239
text
240240
|> String.to_charlist()
241-
|> do_tokenize([''])
241+
|> do_tokenize([~c""])
242242
|> Enum.reverse()
243243
|> Stream.map(fn token -> token |> Enum.reverse() |> to_string() end)
244244
end
@@ -249,7 +249,7 @@ defmodule M51.Format.Irc2Matrix do
249249

250250
defp do_tokenize([c | tail], acc) when <<c>> in @chars do
251251
# new token
252-
do_tokenize(tail, ['' | [[c] | acc]])
252+
do_tokenize(tail, [~c"" | [[c] | acc]])
253253
end
254254

255255
defp do_tokenize([0x03 | tail], acc) do
@@ -287,7 +287,7 @@ defmodule M51.Format.Irc2Matrix do
287287
{tail, []}
288288
end
289289

290-
do_tokenize(tail, ['' | [Enum.reverse([0x03 | normalized_color]) | acc]])
290+
do_tokenize(tail, [~c"" | [Enum.reverse([0x03 | normalized_color]) | acc]])
291291
end
292292

293293
defp do_tokenize([0x04 | tail], acc) do
@@ -314,7 +314,7 @@ defmodule M51.Format.Irc2Matrix do
314314
{tail, []}
315315
end
316316

317-
do_tokenize(tail, ['' | [Enum.reverse([0x04 | normalized_color]) | acc]])
317+
do_tokenize(tail, [~c"" | [Enum.reverse([0x04 | normalized_color]) | acc]])
318318
end
319319

320320
defp do_tokenize([c | tail], [head | acc]) do

lib/irc/handler.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ defmodule M51.IrcConn.Handler do
446446
# this was only meant to be used with Pantalaimon
447447
proxy =
448448
case Regex.named_captures(
449-
~R((plaintextproxy|homeserver-url\)=(?<url>https?://\S*\)),
450-
M51.IrcConn.State.gecos(state) || ""
449+
~r((plaintextproxy|homeserver-url\)=(?<url>https?://\S*\)),
450+
M51.IrcConn.State.gecos(state) || ""
451451
) do
452452
nil -> nil
453453
%{"url" => url} -> url

lib/matrix_client/client.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ defmodule M51.MatrixClient.Client do
525525
# The next call will probably fail, but this spares error handling in this one.
526526
base_url = "https://" <> hostname
527527

528-
Logger.warn(
528+
Logger.warning(
529529
"Well-known request for #{wellknown_url} returned #{Kernel.inspect(res)}. " <>
530530
"Falling back to #{base_url}"
531531
)
@@ -536,7 +536,7 @@ defmodule M51.MatrixClient.Client do
536536
# Treat this in the same way as HTTP error codes above - perm error and fallback
537537
base_url = "https://" <> hostname
538538

539-
Logger.warn(
539+
Logger.warning(
540540
"Well-known request for #{wellknown_url} failed" <>
541541
" with connection error [#{err}]. Falling back to #{base_url}"
542542
)

lib/matrix_client/poller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ defmodule M51.MatrixClient.Poller do
8888

8989
delay =
9090
if delay do
91-
Logger.warn(
91+
Logger.warning(
9292
"Server connection error [#{reconnect_reason}], retrying after #{round(delay / 1000)}s"
9393
)
9494

lib/matrix_client/sender.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ defmodule M51.MatrixClient.Sender do
7070

7171
{:error, _status_code, reason} ->
7272
if nb_attempts < @max_attempts do
73-
Logger.warn("Error while sending event, retrying: #{Kernel.inspect(reason)}")
73+
Logger.warning("Error while sending event, retrying: #{Kernel.inspect(reason)}")
7474
backoff_delay = :math.pow(2, nb_attempts)
7575
Process.sleep(round(backoff_delay * 1000))
7676

@@ -83,7 +83,7 @@ defmodule M51.MatrixClient.Sender do
8383
nb_attempts + 1
8484
)
8585
else
86-
Logger.warn("Error while sending event, giving up: #{Kernel.inspect(reason)}")
86+
Logger.warning("Error while sending event, giving up: #{Kernel.inspect(reason)}")
8787
state = M51.IrcConn.Supervisor.matrix_state(sup_pid)
8888
channel = M51.MatrixClient.State.room_irc_channel(state, room_id)
8989

test/matrix_client/client_test.exs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ defmodule M51.MatrixClient.ClientTest do
188188

189189
client = start_supervised!({M51.MatrixClient.Client, {sup_pid, [httpoison: MockHTTPoison]}})
190190

191-
assert GenServer.call(client, {:connect, "user", "matrix.example.org", "p4ssw0rd", nil}) == {:ok}
191+
assert GenServer.call(client, {:connect, "user", "matrix.example.org", "p4ssw0rd", nil}) ==
192+
{:ok}
192193

193194
assert GenServer.call(client, {:dump_state}) ==
194195
%M51.MatrixClient.Client{
@@ -274,7 +275,8 @@ defmodule M51.MatrixClient.ClientTest do
274275

275276
client = start_supervised!({M51.MatrixClient.Client, {sup_pid, [httpoison: MockHTTPoison]}})
276277

277-
assert GenServer.call(client, {:connect, "user", "matrix.example.org", "p4ssw0rd", nil}) == {:ok}
278+
assert GenServer.call(client, {:connect, "user", "matrix.example.org", "p4ssw0rd", nil}) ==
279+
{:ok}
278280

279281
assert GenServer.call(client, {:dump_state}) ==
280282
%M51.MatrixClient.Client{

0 commit comments

Comments
 (0)