Skip to content

Commit

Permalink
Upgrade elixir otp (beyond-all-reason#432)
Browse files Browse the repository at this point in the history
* Upgrade elixir and otp

Also upgrade dependencies that raised compiler warnings

* Update versions for github CI

* Fix a compiler warning

* Upgrade gettext usage

* Replace charlist with strings

* mix format

* Fix dialyzer

* Use map() instead of Map.t() in typespeck

* Fix new dialyzer errors

* Update doc for local setup.
  • Loading branch information
geekingfrog authored Aug 30, 2024
1 parent 000f1ad commit eb6bfb6
Show file tree
Hide file tree
Showing 218 changed files with 654 additions and 630 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dialyzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ on:
# Sets the ENV `MIX_ENV` to `test` for running tests
env:
MIX_ENV: test
ELIXIR_VER: '1.14.3'
OTP_VER: '25.2.3'
ELIXIR_VER: '1.16.3'
OTP_VER: '26.2.5.2'

permissions:
contents: read
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ on:
# Sets the ENV `MIX_ENV` to `test` for running tests
env:
MIX_ENV: test
ELIXIR_VER: '1.14.3'
OTP_VER: '25.2.3'
ELIXIR_VER: '1.16.3'
OTP_VER: '26.2.5.2'

permissions:
contents: read
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ on:
# Sets the ENV `MIX_ENV` to `test` for running tests
env:
MIX_ENV: test
ELIXIR_VER: '1.14.3'
OTP_VER: '25.2.3'
ELIXIR_VER: '1.16.3'
OTP_VER: '26.2.5.2'

permissions:
contents: read
Expand Down
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 25.2.3
elixir 1.14.3-otp-25
erlang 26.2.5.2
elixir 1.16.3-otp-26
74 changes: 37 additions & 37 deletions config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,43 @@ config :teiserver, TeiserverWeb.Endpoint,
port: 8888,
otp_app: :teiserver,
ciphers: [
'ECDHE-ECDSA-AES256-GCM-SHA384',
'ECDHE-RSA-AES256-GCM-SHA384',
'ECDHE-ECDSA-AES256-SHA384',
'ECDHE-RSA-AES256-SHA384',
'ECDHE-ECDSA-DES-CBC3-SHA',
'ECDH-ECDSA-AES256-GCM-SHA384',
'ECDH-RSA-AES256-GCM-SHA384',
'ECDH-ECDSA-AES256-SHA384',
'ECDH-RSA-AES256-SHA384',
'DHE-DSS-AES256-GCM-SHA384',
'DHE-DSS-AES256-SHA256',
'AES256-GCM-SHA384',
'AES256-SHA256',
'ECDHE-ECDSA-AES128-GCM-SHA256',
'ECDHE-RSA-AES128-GCM-SHA256',
'ECDHE-ECDSA-AES128-SHA256',
'ECDHE-RSA-AES128-SHA256',
'ECDH-ECDSA-AES128-GCM-SHA256',
'ECDH-RSA-AES128-GCM-SHA256',
'ECDH-ECDSA-AES128-SHA256',
'ECDH-RSA-AES128-SHA256',
'DHE-DSS-AES128-GCM-SHA256',
'DHE-DSS-AES128-SHA256',
'AES128-GCM-SHA256',
'AES128-SHA256',
'ECDHE-ECDSA-AES256-SHA',
'ECDHE-RSA-AES256-SHA',
'DHE-DSS-AES256-SHA',
'ECDH-ECDSA-AES256-SHA',
'ECDH-RSA-AES256-SHA',
'AES256-SHA',
'ECDHE-ECDSA-AES128-SHA',
'ECDHE-RSA-AES128-SHA',
'DHE-DSS-AES128-SHA',
'ECDH-ECDSA-AES128-SHA',
'ECDH-RSA-AES128-SHA',
'AES128-SHA'
"ECDHE-ECDSA-AES256-GCM-SHA384",
"ECDHE-RSA-AES256-GCM-SHA384",
"ECDHE-ECDSA-AES256-SHA384",
"ECDHE-RSA-AES256-SHA384",
"ECDHE-ECDSA-DES-CBC3-SHA",
"ECDH-ECDSA-AES256-GCM-SHA384",
"ECDH-RSA-AES256-GCM-SHA384",
"ECDH-ECDSA-AES256-SHA384",
"ECDH-RSA-AES256-SHA384",
"DHE-DSS-AES256-GCM-SHA384",
"DHE-DSS-AES256-SHA256",
"AES256-GCM-SHA384",
"AES256-SHA256",
"ECDHE-ECDSA-AES128-GCM-SHA256",
"ECDHE-RSA-AES128-GCM-SHA256",
"ECDHE-ECDSA-AES128-SHA256",
"ECDHE-RSA-AES128-SHA256",
"ECDH-ECDSA-AES128-GCM-SHA256",
"ECDH-RSA-AES128-GCM-SHA256",
"ECDH-ECDSA-AES128-SHA256",
"ECDH-RSA-AES128-SHA256",
"DHE-DSS-AES128-GCM-SHA256",
"DHE-DSS-AES128-SHA256",
"AES128-GCM-SHA256",
"AES128-SHA256",
"ECDHE-ECDSA-AES256-SHA",
"ECDHE-RSA-AES256-SHA",
"DHE-DSS-AES256-SHA",
"ECDH-ECDSA-AES256-SHA",
"ECDH-RSA-AES256-SHA",
"AES256-SHA",
"ECDHE-ECDSA-AES128-SHA",
"ECDHE-RSA-AES128-SHA",
"DHE-DSS-AES128-SHA",
"ECDH-ECDSA-AES128-SHA",
"ECDH-RSA-AES128-SHA",
"AES128-SHA"
],
secure_renegotiate: true,
reuse_sessions: true,
Expand Down
4 changes: 2 additions & 2 deletions documents/guides/local_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ You will need to install:
- [Elixir/Erlang installed](https://elixir-lang.org/install.html).
- [Postresql](https://www.postgresql.org/download).

Make sure that Elixir is in correct version (I'm currently using 1.14). You can find required version [here](https://github.com/beyond-all-reason/teiserver/blob/master/mix.exs#L8).
You can use [asdf](https://github.com/asdf-vm/asdf) to install correct version.
Make sure that Elixir is in correct version (currently using 1.16). You can find required version [here](https://github.com/beyond-all-reason/teiserver/blob/master/mix.exs#L8).
You can use [asdf](https://github.com/asdf-vm/asdf) to install correct version, picked up from the file `.tool-version`.

### Clone repo
```bash
Expand Down
26 changes: 13 additions & 13 deletions lib/teiserver/account.ex
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ defmodule Teiserver.Account do
|> Repo.one()
end

@spec get_user_stat_data(integer()) :: Map.t()
@spec get_user_stat_data(integer()) :: map()
def get_user_stat_data(userid) do
Teiserver.cache_get_or_store(:teiserver_user_stat_cache, userid, fn ->
case get_user_stat(userid) do
Expand Down Expand Up @@ -309,7 +309,7 @@ defmodule Teiserver.Account do
{:error, %Ecto.Changeset{}}
"""
@spec create_badge_type(Map.t()) :: {:ok, BadgeType.t()} | {:error, Ecto.Changeset.t()}
@spec create_badge_type(map()) :: {:ok, BadgeType.t()} | {:error, Ecto.Changeset.t()}
def create_badge_type(attrs \\ %{}) do
%BadgeType{}
|> BadgeType.changeset(attrs)
Expand All @@ -328,7 +328,7 @@ defmodule Teiserver.Account do
{:error, %Ecto.Changeset{}}
"""
@spec update_badge_type(BadgeType.t(), Map.t()) ::
@spec update_badge_type(BadgeType.t(), map()) ::
{:ok, BadgeType.t()} | {:error, Ecto.Changeset.t()}
def update_badge_type(%BadgeType{} = badge_type, attrs) do
badge_type
Expand Down Expand Up @@ -464,7 +464,7 @@ defmodule Teiserver.Account do
{:error, %Ecto.Changeset{}}
"""
@spec create_accolade(Map.t()) :: {:ok, Accolade.t()} | {:error, Ecto.Changeset.t()}
@spec create_accolade(map()) :: {:ok, Accolade.t()} | {:error, Ecto.Changeset.t()}
def create_accolade(attrs \\ %{}) do
%Accolade{}
|> Accolade.changeset(attrs)
Expand All @@ -483,7 +483,7 @@ defmodule Teiserver.Account do
{:error, %Ecto.Changeset{}}
"""
@spec update_accolade(Accolade.t(), Map.t()) ::
@spec update_accolade(Accolade.t(), map()) ::
{:ok, Accolade.t()} | {:error, Ecto.Changeset.t()}
def update_accolade(%Accolade{} = accolade, attrs) do
accolade
Expand Down Expand Up @@ -683,7 +683,7 @@ defmodule Teiserver.Account do
{:error, %Ecto.Changeset{}}
"""
@spec update_smurf_key(SmurfKey.t(), Map.t()) ::
@spec update_smurf_key(SmurfKey.t(), map()) ::
{:ok, SmurfKey.t()} | {:error, Ecto.Changeset.t()}
def update_smurf_key(%SmurfKey{} = smurf_key, attrs) do
smurf_key
Expand Down Expand Up @@ -823,7 +823,7 @@ defmodule Teiserver.Account do
{:error, %Ecto.Changeset{}}
"""
@spec create_smurf_key_type(Map.t()) :: {:ok, SmurfKeyType.t()} | {:error, Ecto.Changeset.t()}
@spec create_smurf_key_type(map()) :: {:ok, SmurfKeyType.t()} | {:error, Ecto.Changeset.t()}
def create_smurf_key_type(attrs \\ %{}) do
%SmurfKeyType{}
|> SmurfKeyType.changeset(attrs)
Expand Down Expand Up @@ -985,7 +985,7 @@ defmodule Teiserver.Account do
{:error, %Ecto.Changeset{}}
"""
@spec create_rating(Map.t()) :: {:ok, Rating.t()} | {:error, Ecto.Changeset.t()}
@spec create_rating(map()) :: {:ok, Rating.t()} | {:error, Ecto.Changeset.t()}
def create_rating(attrs \\ %{}) do
%Rating{}
|> Rating.changeset(attrs)
Expand All @@ -1001,7 +1001,7 @@ defmodule Teiserver.Account do
|> Repo.update()
end

@spec create_or_update_rating(Map.t()) :: {:ok, Rating.t()} | {:error, Ecto.Changeset.t()}
@spec create_or_update_rating(map()) :: {:ok, Rating.t()} | {:error, Ecto.Changeset.t()}
def create_or_update_rating(attrs \\ %{}) do
case get_rating(attrs.user_id, attrs.rating_type_id) do
nil ->
Expand Down Expand Up @@ -2065,18 +2065,18 @@ defmodule Teiserver.Account do
@spec list_clients([T.userid()]) :: [T.client()]
defdelegate list_clients(id_list), to: ClientLib

@spec update_client(T.userid(), Map.t()) :: nil | :ok
@spec update_client(T.userid(), map()) :: nil | :ok
defdelegate update_client(userid, partial_client), to: ClientLib

# TODO: Remove these in favour of update_client
@spec merge_update_client(Map.t()) :: nil | :ok
@spec merge_update_client(map()) :: nil | :ok
defdelegate merge_update_client(client), to: ClientLib

@spec merge_update_client(T.userid(), Map.t()) :: nil | :ok
@spec merge_update_client(T.userid(), map()) :: nil | :ok
defdelegate merge_update_client(userid, client), to: ClientLib

@spec replace_update_client(
Map.t(),
map(),
:silent | :client_updated_status | :client_updated_battlestatus
) :: T.client()
defdelegate replace_update_client(client, reason), to: ClientLib
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/account/accolades/accolade_bot_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ defmodule Teiserver.Account.AccoladeBotServer do
end

@impl true
@spec init(Map.t()) :: {:ok, Map.t()}
@spec init(map()) :: {:ok, map()}
def init(_opts) do
Horde.Registry.register(
Teiserver.AccoladesRegistry,
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/account/accolades/accolade_chat_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ defmodule Teiserver.Account.AccoladeChatServer do
%{state | stage: :awaiting_choice}
end

@spec init(Map.t()) :: {:ok, Map.t()}
@spec init(map()) :: {:ok, map()}
def init(opts) do
userid = opts[:userid]
recipient_id = opts[:recipient_id]
Expand Down
4 changes: 2 additions & 2 deletions lib/teiserver/account/libs/accolade_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule Teiserver.Account.AccoladeLib do
@spec colours :: atom
def colours, do: :info

@spec make_favourite(Map.t()) :: Map.t()
@spec make_favourite(map()) :: map()
def make_favourite(accolade) do
%{
type_colour: StylingHelper.colours(colours()) |> elem(0),
Expand All @@ -37,7 +37,7 @@ defmodule Teiserver.Account.AccoladeLib do
from(accolades in Accolade)
end

@spec search(Ecto.Query.t(), Map.t() | nil) :: Ecto.Query.t()
@spec search(Ecto.Query.t(), map() | nil) :: Ecto.Query.t()
def search(query, nil), do: query

def search(query, params) do
Expand Down
6 changes: 3 additions & 3 deletions lib/teiserver/account/libs/auth_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Teiserver.Account.AuthLib do
@spec icon :: String.t()
def icon(), do: "fa-solid fa-address-card"

@spec get_all_permission_sets() :: Map.t()
@spec get_all_permission_sets() :: list()
def get_all_permission_sets do
Teiserver.store_get(:auth_group_store, :all)
|> Enum.map(fn key -> {key, get_permission_set(key)} end)
Expand Down Expand Up @@ -60,7 +60,7 @@ defmodule Teiserver.Account.AuthLib do
end

# If you don't need permissions then lets not bother checking
@spec allow?(Map.t() | Plug.Conn.t() | [String.t()], String.t() | [String.t()]) :: boolean
@spec allow?(map() | Plug.Conn.t() | [String.t()], String.t() | [String.t()]) :: boolean
def allow?(nil, []), do: false
def allow?(_, nil), do: true
def allow?(_, ""), do: true
Expand Down Expand Up @@ -144,7 +144,7 @@ defmodule Teiserver.Account.AuthLib do
end

@spec mount_require_any(
Map.t() | Plug.Conn.t() | Phoenix.LiveView.Socket.t(),
map() | Plug.Conn.t() | Phoenix.LiveView.Socket.t(),
String.t() | [String.t()]
) :: Phoenix.LiveView.Socket
def mount_require_any(obj, requirements) do
Expand Down
4 changes: 2 additions & 2 deletions lib/teiserver/account/libs/badge_type_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defmodule Teiserver.Account.BadgeTypeLib do
"Role"
]

@spec make_favourite(Map.t()) :: Map.t()
@spec make_favourite(map()) :: map()
def make_favourite(badge_type) do
%{
type_colour: colours(),
Expand All @@ -48,7 +48,7 @@ defmodule Teiserver.Account.BadgeTypeLib do
from(badge_types in BadgeType)
end

@spec search(Ecto.Query.t(), Map.t() | nil) :: Ecto.Query.t()
@spec search(Ecto.Query.t(), map() | nil) :: Ecto.Query.t()
def search(query, nil), do: query

def search(query, params) do
Expand Down
12 changes: 6 additions & 6 deletions lib/teiserver/account/libs/client_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,25 @@ defmodule Teiserver.Account.ClientLib do
end

# Updates
@spec merge_update_client(Map.t()) :: nil | :ok
@spec merge_update_client(map()) :: nil | :ok
def merge_update_client(%{userid: userid} = partial_client) do
cast_client(userid, {:update_values, partial_client})
end

@spec merge_update_client(T.userid(), Map.t()) :: nil | :ok
@spec merge_update_client(T.userid(), map()) :: nil | :ok
def merge_update_client(userid, partial_client) do
cast_client(userid, {:update_values, partial_client})
end

@spec update_client(T.userid(), Map.t()) :: nil | :ok
@spec update_client(T.userid(), map()) :: nil | :ok
def update_client(userid, partial_client) do
cast_client(userid, {:update_values, partial_client})
end

@spec replace_update_client(
Map.t(),
map(),
:silent | :client_updated_status | :client_updated_battlestatus
) :: Map.t()
) :: map()
def replace_update_client(%{userid: userid} = client, :silent) do
# Update the process with it
cast_client(userid, {:update_client, client})
Expand Down Expand Up @@ -273,7 +273,7 @@ defmodule Teiserver.Account.ClientLib do

# Used in tests to update a client based on user data
# not intended to be used as part of standard operation
@spec refresh_client(T.userid()) :: Map.t()
@spec refresh_client(T.userid()) :: map()
def refresh_client(userid) do
user = Account.get_user_by_id(userid)
stats = Account.get_user_stat_data(user.id)
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/account/libs/rating_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defmodule Teiserver.Account.RatingLib do
from(ratings in Rating)
end

@spec search(Ecto.Query.t(), Map.t() | nil) :: Ecto.Query.t()
@spec search(Ecto.Query.t(), map() | nil) :: Ecto.Query.t()
def search(query, nil), do: query

def search(query, params) do
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/account/libs/smurf_key_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule Teiserver.Account.SmurfKeyLib do
from(smurf_keys in SmurfKey)
end

@spec search(Ecto.Query.t(), Map.t() | nil) :: Ecto.Query.t()
@spec search(Ecto.Query.t(), map() | nil) :: Ecto.Query.t()
def search(query, nil), do: query

def search(query, params) do
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/account/libs/smurf_key_type_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule Teiserver.Account.SmurfKeyTypeLib do
from(smurf_key_types in SmurfKeyType)
end

@spec search(Ecto.Query.t(), Map.t() | nil) :: Ecto.Query.t()
@spec search(Ecto.Query.t(), map() | nil) :: Ecto.Query.t()
def search(query, nil), do: query

def search(query, params) do
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/account/libs/user_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule Teiserver.Account.UserLib do
@spec colour :: atom
def colour, do: :success

@spec make_favourite(Teiserver.Account.User.t()) :: Map.t()
@spec make_favourite(Teiserver.Account.User.t()) :: map()
def make_favourite(user) do
%{
type_colour: StylingHelper.colours(colours()) |> elem(0),
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/account/libs/user_stat_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Teiserver.Account.UserStatLib do
from(user_stats in UserStat)
end

@spec search(Ecto.Query.t(), Map.t() | nil) :: Ecto.Query.t()
@spec search(Ecto.Query.t(), map() | nil) :: Ecto.Query.t()
def search(query, nil), do: query

def search(query, params) do
Expand Down
Loading

0 comments on commit eb6bfb6

Please sign in to comment.