Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defmodule M51.Application do
@impl true
def start(_type, args) do
if Enum.member?(System.argv(), "--debug") do
Logger.warn("Starting in debug mode")
Logger.warning("Starting in debug mode")
Logger.configure(level: :debug)
else
Logger.configure(level: :info)
Expand Down
4 changes: 2 additions & 2 deletions lib/format/common.ex
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ defmodule M51.Format do
|> :mochiweb_html.to_html()
|> IO.iodata_to_binary()

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

{plain_text, html}
end
Expand Down
8 changes: 4 additions & 4 deletions lib/format/irc2matrix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ defmodule M51.Format.Irc2Matrix do
def tokenize(text) do
text
|> String.to_charlist()
|> do_tokenize([''])
|> do_tokenize([~c""])
|> Enum.reverse()
|> Stream.map(fn token -> token |> Enum.reverse() |> to_string() end)
end
Expand All @@ -249,7 +249,7 @@ defmodule M51.Format.Irc2Matrix do

defp do_tokenize([c | tail], acc) when <<c>> in @chars do
# new token
do_tokenize(tail, ['' | [[c] | acc]])
do_tokenize(tail, [~c"" | [[c] | acc]])
end

defp do_tokenize([0x03 | tail], acc) do
Expand Down Expand Up @@ -287,7 +287,7 @@ defmodule M51.Format.Irc2Matrix do
{tail, []}
end

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

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

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

defp do_tokenize([c | tail], [head | acc]) do
Expand Down
4 changes: 2 additions & 2 deletions lib/irc/handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ defmodule M51.IrcConn.Handler do
# this was only meant to be used with Pantalaimon
proxy =
case Regex.named_captures(
~R((plaintextproxy|homeserver-url\)=(?<url>https?://\S*\)),
M51.IrcConn.State.gecos(state) || ""
~r((plaintextproxy|homeserver-url\)=(?<url>https?://\S*\)),
M51.IrcConn.State.gecos(state) || ""
) do
nil -> nil
%{"url" => url} -> url
Expand Down
4 changes: 2 additions & 2 deletions lib/matrix_client/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ defmodule M51.MatrixClient.Client do
# The next call will probably fail, but this spares error handling in this one.
base_url = "https://" <> hostname

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

Logger.warn(
Logger.warning(
"Well-known request for #{wellknown_url} failed" <>
" with connection error [#{err}]. Falling back to #{base_url}"
)
Expand Down
2 changes: 1 addition & 1 deletion lib/matrix_client/poller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ defmodule M51.MatrixClient.Poller do

delay =
if delay do
Logger.warn(
Logger.warning(
"Server connection error [#{reconnect_reason}], retrying after #{round(delay / 1000)}s"
)

Expand Down
4 changes: 2 additions & 2 deletions lib/matrix_client/sender.ex
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ defmodule M51.MatrixClient.Sender do

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

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

Expand Down
6 changes: 4 additions & 2 deletions test/matrix_client/client_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ defmodule M51.MatrixClient.ClientTest do

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

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

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

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

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

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