Skip to content

Commit 16c9eda

Browse files
committed
chore: Fix linter issues & deprecations
1 parent c7efee0 commit 16c9eda

File tree

18 files changed

+62
-67
lines changed

18 files changed

+62
-67
lines changed

apps/cf/lib/accounts/username_generator.ex

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ defmodule CF.Accounts.UsernameGenerator do
66
@name __MODULE__
77
@username_prefix "NewUser-"
88

9-
def start_link do
9+
def child_spec(opts) do
10+
%{
11+
id: __MODULE__,
12+
start: {__MODULE__, :start_link, [opts]},
13+
type: :worker,
14+
restart: :permanent,
15+
shutdown: 500
16+
}
17+
end
18+
19+
def start_link(_opts \\ []) do
1020
Agent.start_link(
1121
fn ->
1222
Hashids.new(

apps/cf/lib/application.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ defmodule CF.Application do
99
# Define workers and child supervisors to be supervised
1010
children = [
1111
# Other custom supervisors
12-
supervisor(CF.Sources.Fetcher, []),
12+
{CF.Sources.Fetcher, []},
1313
# Misc workers
14-
worker(CF.Accounts.UsernameGenerator, []),
14+
{CF.Accounts.UsernameGenerator, []},
1515
# Sweep tokens from db
16-
worker(Guardian.DB.Token.SweeperServer, [])
16+
{Guardian.DB.Token.SweeperServer, []}
1717
]
1818

1919
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html

apps/cf/lib/errors/errors.ex

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,9 @@ defmodule CF.Errors do
3636
end
3737

3838
@spec do_report(:error | :exit | :throw, any(), [any()], cf_error_params()) :: :ok
39-
def do_report(type, value, stacktrace, params) do
39+
def do_report(type, value, stacktrace, _params) do
4040
# Any call to Sentry, Rollbar, etc. should be done here
4141
Logger.error("[ERROR][#{type}] #{inspect(value)} - #{inspect(stacktrace)}")
4242
:ok
4343
end
44-
45-
defp build_occurence_data(params) do
46-
default_occurrence_data()
47-
|> add_user(params[:user])
48-
|> Map.merge(params[:data] || %{})
49-
end
50-
51-
defp default_occurrence_data() do
52-
%{
53-
"code_version" => CF.Application.version()
54-
}
55-
end
56-
57-
defp add_user(base, nil),
58-
do: base
59-
60-
defp add_user(base, %{id: id, username: username}),
61-
do: Map.merge(base, %{"person" => %{"id" => Integer.to_string(id), "username" => username}})
62-
63-
defp add_user(base, %{id: id}),
64-
do: Map.merge(base, %{"person" => %{"id" => Integer.to_string(id)}})
6544
end

apps/cf/lib/llms/statements_creator.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ defmodule CF.LLMs.StatementsCreator do
5656
end
5757
end
5858

59-
@doc """
60-
Chunk captions everytime we reach the max caption length
61-
"""
59+
# Chunk captions each time we reach the max caption length
6260
defp chunk_captions(captions) do
6361
# TODO: Add last captions from previous batch to preserve context
6462
Enum.chunk_every(captions, @captions_chunk_size)

apps/cf/lib/llms/templates/statements_extractor_user_prompt.eex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"title": "<%= video.id %>"
55
},
66
"captions": <%= captions |> Enum.map(fn caption -> %{
7-
"start": floor(caption["start"]),
8-
"text": String.trim(caption["text"])
7+
start: floor(caption["start"]),
8+
text: String.trim(caption["text"])
99
} end) |> Jason.encode! %>
1010
}
1111
```

apps/cf/lib/sources/fetcher.ex

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@ defmodule CF.Sources.Fetcher do
1010

1111
# ---- Public API ----
1212

13-
def start_link() do
13+
def child_spec(opts) do
14+
%{
15+
id: __MODULE__,
16+
start: {__MODULE__, :start_link, [opts]},
17+
type: :worker,
18+
restart: :permanent,
19+
shutdown: 500
20+
}
21+
end
22+
23+
def start_link(_opts \\ []) do
1424
import Supervisor.Spec
1525

1626
Supervisor.start_link(

apps/cf_atom_feed/lib/application.ex

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@ defmodule CF.AtomFeed.Application do
44
# See https://hexdocs.pm/elixir/Application.html
55
# for more information on OTP Applications
66
def start(_type, _args) do
7-
import Supervisor.Spec
8-
9-
children = []
107
config = Application.get_env(:cf_atom_feed, CF.AtomFeed.Router)
11-
12-
if config[:cowboy] do
13-
children = [supervisor(CF.AtomFeed.Router, []) | children]
14-
end
8+
children = if config[:cowboy], do: [{CF.AtomFeed.Router, []}], else: []
159

1610
# See https://hexdocs.pm/elixir/Supervisor.html
1711
# for other strategies and supported options

apps/cf_atom_feed/lib/router.ex

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ defmodule CF.AtomFeed.Router do
66
plug(:match)
77
plug(:dispatch)
88

9-
def start_link do
9+
def child_spec(opts) do
10+
%{
11+
id: __MODULE__,
12+
start: {__MODULE__, :start_link, [opts]},
13+
type: :worker,
14+
restart: :permanent,
15+
shutdown: 500
16+
}
17+
end
18+
19+
def start_link(_opts \\ []) do
1020
config = Application.get_env(:cf_atom_feed, CF.AtomFeed.Router)
1121
Logger.info("Running CF.AtomFeed.Router with cowboy on port #{config[:cowboy][:port]}")
1222
Plug.Cowboy.http(CF.AtomFeed.Router, [], config[:cowboy])

apps/cf_graphql/lib/application.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule CF.Graphql.Application do
1111
# Start the PubSub system
1212
{Phoenix.PubSub, name: CF.Graphql.PubSub},
1313
# Start the endpoint when the application starts
14-
supervisor(CF.GraphQLWeb.Endpoint, [])
14+
{CF.GraphQLWeb.Endpoint, []}
1515
]
1616

1717
# See https://hexdocs.pm/elixir/Supervisor.html

apps/cf_rest_api/lib/application.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ defmodule CF.RestApi.Application do
99
# Start the PubSub system
1010
{Phoenix.PubSub, name: CF.RestApi.PubSub},
1111
# Start the endpoint when the application starts
12-
supervisor(CF.RestApi.Endpoint, []),
12+
{CF.RestApi.Endpoint, []},
1313
# Presence to track number of connected users to a channel
14-
supervisor(CF.RestApi.Presence, [])
14+
{CF.RestApi.Presence, []}
1515
]
1616

1717
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html

0 commit comments

Comments
 (0)