Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Enum.count instead of count for team_count/size #324

Merged
merged 1 commit into from
Jun 11, 2024
Merged
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
4 changes: 2 additions & 2 deletions lib/teiserver/battle/libs/match_lib.ex
Original file line number Diff line number Diff line change
@@ -80,11 +80,11 @@ defmodule Teiserver.Battle.MatchLib do
|> Enum.group_by(fn c -> c.team_number end)

if teams != %{} do
team_count = teams |> count
team_count = teams |> Enum.count()

team_size =
teams
|> Enum.map(fn {_, t} -> t |> count end)
|> Enum.map(fn {_, t} -> t |> Enum.count() end)
|> Enum.max(fn -> 0 end)

game_type = game_type(team_size, team_count, bots)
1 change: 1 addition & 0 deletions lib/teiserver/game/libs/match_rating_lib.ex
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ defmodule Teiserver.Game.MatchRatingLib do
"Team FFA",
"Partied Team"
]

# TODO Remove "Team" from here once the split is done

@spec rating_type_list() :: [String.t()]

Unchanged files with check annotations Beta

assert new_user.email_change_code == [nil, nil]
end
test "CHANGEEMAIL to email already taken", %{socket: socket, user: user} do

Check warning on line 563 in test/teiserver/protocols/spring/spring_auth_test.exs

GitHub Actions / Build and test

variable "user" is unused (if the variable is not meant to be used, prefix it with an underscore)
other_user = Teiserver.TeiserverTestLib.new_user()
# Make the request
%{socket: hsocket, user: host} = tachyon_auth_setup()
# User needs to be a moderator (at this time) to start/stop Coordinator mode
User.update_user(%{host | moderator: true})

Check warning on line 107 in test/teiserver_web/controllers/api/spads_controller_test.exs

GitHub Actions / Build and test

Teiserver.User.update_user/1 is undefined (module Teiserver.User is not available or is yet to be defined)
ClientLib.refresh_client(host.id)
lobby_data = %{
describe "Basic auth test" do
setup [:unauth_setup, :create_tag]
test "basic user", %{tag: tag, conn: conn} do

Check failure on line 52 in test/teiserver_web/live/microblog/admin/tag_live_test.exs

GitHub Actions / Build and test

test Basic auth test basic user (TeiserverWeb.TagLiveTest)
{:error, {:redirect, resp}} = live(conn, ~p"/microblog/admin/tags")
assert resp == %{flash: %{"info" => "Welcome back!"}, to: ~p"/microblog"}
describe "Basic auth test" do
setup [:unauth_setup, :create_post]
test "basic user", %{post: post, conn: conn} do

Check failure on line 52 in test/teiserver_web/live/microblog/admin/post_live_test.exs

GitHub Actions / Build and test

test Basic auth test basic user (TeiserverWeb.PostLiveTest)
{:error, {:redirect, resp}} = live(conn, ~p"/microblog/admin/posts")
assert resp == %{flash: %{"info" => "Welcome back!"}, to: ~p"/microblog"}
refute html =~ "LiveBattleName"
end
test "show - valid battle", %{conn: conn} do

Check failure on line 84 in test/teiserver_web/live/battle_live_test.exs

GitHub Actions / Build and test

test battle live show - valid battle (TeiserverWeb.Live.BattleTest)
# Lets create a battle
%{socket: host_socket, user: host_user} = TeiserverTestLib.auth_setup()
CacheUser.add_roles(host_user, ["Bot"])
live(conn, "/battle/lobbies/show/0")
end
test "chat - valid battle", %{conn: conn} do

Check failure on line 161 in test/teiserver_web/live/battle_live_test.exs

GitHub Actions / Build and test

test battle live chat - valid battle (TeiserverWeb.Live.BattleTest)
# Lets create a battle
%{socket: host_socket, user: host_user} = TeiserverTestLib.auth_setup()
CacheUser.add_roles(host_user, ["Bot"])
@sleep_time 2100
describe "client live" do
test "index", %{conn: conn} do

Check failure on line 19 in test/teiserver_web/live/client_live_test.exs

GitHub Actions / Build and test

test client live index (TeiserverWeb.Live.ClientTest)
{:ok, view, _html} = live(conn, "/teiserver/admin/client")
# Sadly because other clients can still be logged in after their tests we can't actually test this bit...
refute html =~ "#{user2.name}"
end
test "show - valid client", %{conn: conn} do

Check failure on line 60 in test/teiserver_web/live/client_live_test.exs

GitHub Actions / Build and test

test client live show - valid client (TeiserverWeb.Live.ClientTest)
%{socket: socket, user: user} = TeiserverTestLib.auth_setup()
# client = Client.get_client_by_id(user.id)
assert_redirect(view, "/teiserver/admin/client", 250)
end
test "show - no client", %{conn: conn} do

Check failure on line 78 in test/teiserver_web/live/client_live_test.exs

GitHub Actions / Build and test

test client live show - no client (TeiserverWeb.Live.ClientTest)
assert {:error, {:redirect, %{to: "/teiserver/admin/client"}}} =
live(conn, "/teiserver/admin/client/0")
end
|> has_element?()
end
test "renders error flash when client is not connected", %{

Check failure on line 60 in test/teiserver_web/live/account/profile/overview_test.exs

GitHub Actions / Build and test

test join lobby renders error flash when client is not connected (TeiserverWeb.Live.Account.Profile.OverviewTest)
conn: conn,
profile_user: profile_user
} do
|> Teiserver.TeiserverTestLib.conn_setup()
end
test "index", %{conn: conn} do

Check failure on line 11 in test/teiserver_web/controllers/report/general_controller_test.exs

GitHub Actions / Build and test

test index (TeiserverWeb.Report.GeneralControllerTest)
conn = get(conn, Routes.ts_reports_general_path(conn, :index))
assert html_response(conn, 200)
assert html_response(conn, 200) =~ "some updated"
end
test "renders errors when data is invalid", %{conn: conn, user: user} do

Check failure on line 150 in test/teiserver_web/controllers/moderation/proposal_controller_test.exs

GitHub Actions / Build and test

test update proposal renders errors when data is invalid (TeiserverWeb.Moderation.ProposalControllerTest)
# You can only edit a proposal if you are the proposer
{proposal, _vote} = ModerationTestLib.proposal_fixture(%{proposer: user})
|> assign(:page_title, "#{user.name} - Achievements")
end
def handle_info(%{channel: "teiserver_client_messages:" <> _, event: :connected}, socket) do

Check warning on line 62 in lib/teiserver_web/live/account/profile/overview.ex

GitHub Actions / Build and test

module attribute @impl was not set for function handle_info/2 callback (specified in Phoenix.LiveView). This either means you forgot to add the "@impl true" annotation before the definition or that you are accidentally overriding this callback

Check warning on line 62 in lib/teiserver_web/live/account/profile/overview.ex

GitHub Actions / Dialyzer

module attribute @impl was not set for function handle_info/2 callback (specified in Phoenix.LiveView). This either means you forgot to add the "@impl true" annotation before the definition or that you are accidentally overriding this callback

Check warning on line 62 in lib/teiserver_web/live/account/profile/overview.ex

GitHub Actions / mix format

module attribute @impl was not set for function handle_info/2 callback (specified in Phoenix.LiveView). This either means you forgot to add the "@impl true" annotation before the definition or that you are accidentally overriding this callback
user_id = socket.assigns.user.id
socket = assign(socket, :client, Account.get_client_by_id(user_id))
|> assign(:profile_permissions, [])
end
def handle_event("join", _params, %{assigns: assigns} = socket) do

Check warning on line 288 in lib/teiserver_web/live/account/profile/overview.ex

GitHub Actions / Build and test

clauses with the same name and arity (number of arguments) should be grouped together, "def handle_event/3" was previously defined (lib/teiserver_web/live/account/profile/overview.ex:87)

Check warning on line 288 in lib/teiserver_web/live/account/profile/overview.ex

GitHub Actions / Dialyzer

clauses with the same name and arity (number of arguments) should be grouped together, "def handle_event/3" was previously defined (lib/teiserver_web/live/account/profile/overview.ex:87)

Check warning on line 288 in lib/teiserver_web/live/account/profile/overview.ex

GitHub Actions / mix format

clauses with the same name and arity (number of arguments) should be grouped together, "def handle_event/3" was previously defined (lib/teiserver_web/live/account/profile/overview.ex:87)
user_id = assigns.user.id

Check warning on line 289 in lib/teiserver_web/live/account/profile/overview.ex

GitHub Actions / Build and test

variable "user_id" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 289 in lib/teiserver_web/live/account/profile/overview.ex

GitHub Actions / Dialyzer

variable "user_id" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 289 in lib/teiserver_web/live/account/profile/overview.ex

GitHub Actions / mix format

variable "user_id" is unused (if the variable is not meant to be used, prefix it with an underscore)
current_user_id = assigns.current_user.id
lobby_id = assigns.client.lobby_id
end
end
def get_relationships_and_permissions(

Check warning on line 328 in lib/teiserver_web/live/account/profile/overview.ex

GitHub Actions / Build and test

clauses with the same name and arity (number of arguments) should be grouped together, "def get_relationships_and_permissions/1" was previously defined (lib/teiserver_web/live/account/profile/overview.ex:272)

Check warning on line 328 in lib/teiserver_web/live/account/profile/overview.ex

GitHub Actions / Dialyzer

clauses with the same name and arity (number of arguments) should be grouped together, "def get_relationships_and_permissions/1" was previously defined (lib/teiserver_web/live/account/profile/overview.ex:272)

Check warning on line 328 in lib/teiserver_web/live/account/profile/overview.ex

GitHub Actions / mix format

clauses with the same name and arity (number of arguments) should be grouped together, "def get_relationships_and_permissions/1" was previously defined (lib/teiserver_web/live/account/profile/overview.ex:272)
%{assigns: %{current_user: current_user, user: user}} = socket
)
when is_connected?(socket) do
# This is because upon disconnecting, the server does a bunch of DB call for logging
# and telemetry. The disconnection happen when the tcp socket is closed, and by
# that time, the test has ended and the SQL sandbox closed.
ExUnit.Callbacks.on_exit(fn -> Teiserver.Client.disconnect(user.id) end)

Check warning on line 124 in lib/teiserver/libs/test_lib.ex

GitHub Actions / Dialyzer

unknown_function

Function ExUnit.Callbacks.on_exit/1 does not exist.
%{socket: socket, user: user, pid: pid}
end
defmodule TeiserverWeb.ChannelCase do

Check warning on line 1 in test/support/channel_case.ex

GitHub Actions / Dialyzer

unknown_function

Function ExUnit.Callbacks.__merge__/3 does not exist.
@moduledoc """
This module defines the test case to be used by
channel tests.
use ExUnit.CaseTemplate
using do

Check warning on line 20 in test/support/channel_case.ex

GitHub Actions / Dialyzer

unknown_function

Function ExUnit.CaseTemplate.__proxy__/2 does not exist.
quote do
# Import conveniences for testing with channels
import Phoenix.ChannelTest
defmodule TeiserverWeb.ConnCase do

Check warning on line 1 in test/support/conn_case.ex

GitHub Actions / Dialyzer

unknown_function

Function ExUnit.Callbacks.__merge__/3 does not exist.
@moduledoc """
This module defines the test case to be used by
tests that require setting up a connection.
use ExUnit.CaseTemplate
using do

Check warning on line 20 in test/support/conn_case.ex

GitHub Actions / Dialyzer

unknown_function

Function ExUnit.CaseTemplate.__proxy__/2 does not exist.
quote do
# Import conveniences for testing with connections
import Plug.Conn
defmodule Teiserver.DataCase do

Check warning on line 1 in test/support/data_case.ex

GitHub Actions / Dialyzer

unknown_function

Function ExUnit.Callbacks.__merge__/3 does not exist.
@moduledoc """
This module defines the setup for tests requiring
access to the application's data layer.
use ExUnit.CaseTemplate
using do

Check warning on line 19 in test/support/data_case.ex

GitHub Actions / Dialyzer

unknown_function

Function ExUnit.CaseTemplate.__proxy__/2 does not exist.
quote do
alias Teiserver.Repo
"""
def setup_sandbox(tags) do
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Teiserver.Repo, shared: not tags[:async])
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)

Check warning on line 35 in test/support/data_case.ex

GitHub Actions / Dialyzer

unknown_function

Function ExUnit.Callbacks.on_exit/1 does not exist.
end
setup tags do
defmodule Teiserver.ServerCase do

Check warning on line 1 in test/support/server_case.ex

GitHub Actions / Dialyzer

unknown_function

Function ExUnit.Callbacks.__merge__/3 does not exist.
@moduledoc """
This module defines the setup for tests requiring
access to the application's data layer.
use ExUnit.CaseTemplate
using do

Check warning on line 19 in test/support/server_case.ex

GitHub Actions / Dialyzer

unknown_function

Function ExUnit.CaseTemplate.__proxy__/2 does not exist.
quote do
alias Teiserver.Repo