Skip to content

Commit 6b74ecd

Browse files
committed
chore: Fix compilation warnings
1 parent 39e2eaa commit 6b74ecd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+128
-156
lines changed

apps/cf/config/config.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# This file is responsible for configuring your application
2-
# and its dependencies with the aid of the Mix.Config module.
2+
# and its dependencies with the aid of the Config module.
33
#
44
# This configuration file is loaded before any dependency and
55
# is restricted to this project.
6-
use Mix.Config
6+
import Config
77

88
# General application configuration
99
config :cf,
@@ -41,7 +41,7 @@ config :algoliax,
4141
application_id: "N5GW2EAIFX"
4242

4343
# Import environment specific config
44-
import_config "#{Mix.env()}.exs"
44+
Config.import_config("#{Mix.env()}.exs")
4545

4646
config :cf,
4747
openai_model: "gpt-4o"

apps/cf/config/dev.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use Mix.Config
1+
import Config
22

33
dev_secret = "8C6FsJwjV11d+1WPUIbkEH6gB/VavJrcXWoPLujgpclfxjkLkoNFSjVU9XfeNm6s"
44

@@ -32,5 +32,5 @@ config :cf, CF.Mailer, adapter: Bamboo.LocalAdapter
3232

3333
# Import local secrets if any - use wildcard to ignore errors
3434
for config <- "*dev.secret.exs" |> Path.expand(__DIR__) |> Path.wildcard() do
35-
import_config config
35+
Config.import_config(config)
3636
end

apps/cf/lib/accounts/accounts.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defmodule CF.Accounts do
2424
@request_validity 48 * 60 * 60
2525

2626
# Configure Fetching of user picture on Gravatar
27-
@fetch_default_picture Application.get_env(:cf, :fetch_default_user_picture, true)
27+
@fetch_default_picture Application.compile_env(:cf, :fetch_default_user_picture, true)
2828

2929
# ---- User creation ----
3030

apps/cf/lib/accounts/username_generator.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
defmodule CF.Accounts.UsernameGenerator do
2+
use Agent
3+
24
@moduledoc """
35
Generates a unique username based on user id
46
"""
57

68
@name __MODULE__
79
@username_prefix "NewUser-"
810

9-
def start_link do
11+
def start_link(_opts \\ []) do
1012
Agent.start_link(
1113
fn ->
1214
Hashids.new(

apps/cf/lib/application.ex

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ defmodule CF.Application do
44
# See http://elixir-lang.org/docs/stable/elixir/Application.html
55
# for more information on OTP Applications
66
def start(_type, _args) do
7-
import Supervisor.Spec
8-
97
# Define workers and child supervisors to be supervised
108
children = [
119
# Other custom supervisors
12-
supervisor(CF.Sources.Fetcher, []),
10+
CF.Sources.Fetcher,
1311
# Misc workers
14-
worker(CF.Accounts.UsernameGenerator, []),
12+
CF.Accounts.UsernameGenerator,
1513
# Sweep tokens from db
16-
worker(Guardian.DB.Token.SweeperServer, [])
14+
Guardian.DB.Token.SweeperServer
1715
]
1816

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

apps/cf/lib/authenticator/oauth/facebook.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ defmodule CF.Authenticator.OAuth.Facebook do
105105
end
106106

107107
defp hmac(data, type, key) do
108-
:crypto.hmac(type, key, data)
108+
:crypto.mac(:hmac, type, key, data)
109109
end
110110

111111
# ---- Private ----

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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ defmodule CF.LLMs.StatementsCreator do
6565
end
6666
end
6767

68-
@doc """
69-
Chunk captions everytime we reach the max caption length
70-
"""
7168
defp chunk_captions(captions) do
7269
# TODO: Add last captions from previous batch to preserve context
7370
Enum.chunk_every(captions, @captions_chunk_size)
@@ -138,7 +135,7 @@ defmodule CF.LLMs.StatementsCreator do
138135
defp create_statements_from_inputs(statements_inputs, video) do
139136
inserted_at = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
140137

141-
{nb_statements, statements} =
138+
{_nb_statements, statements} =
142139
DB.Repo.insert_all(
143140
DB.Schema.Statement,
144141
Enum.map(statements_inputs, fn %{"text" => text, "time" => time} ->

apps/cf/lib/sources/fetcher.ex

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,25 @@ defmodule CF.Sources.Fetcher do
1010

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

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

23+
def start_link(_opts \\ []) do
1624
Supervisor.start_link(
1725
[
1826
:hackney_pool.child_spec(
1927
pool_name(),
2028
timeout: @request_timeout,
2129
max_connections: @max_connections
2230
),
23-
worker(CF.Sources.Fetcher.LinkChecker, [])
31+
CF.Sources.Fetcher.LinkChecker
2432
],
2533
strategy: :one_for_all,
2634
name: __MODULE__
@@ -75,7 +83,7 @@ defmodule CF.Sources.Fetcher do
7583
hackney: [pool: pool_name()]
7684
) do
7785
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
78-
{:ok, source_params_from_tree(Floki.parse(body))}
86+
{:ok, source_params_from_tree(Floki.parse_document(body))}
7987

8088
{:ok, %HTTPoison.Response{status_code: 404}} ->
8189
{:error, :not_found}
@@ -137,10 +145,12 @@ defmodule CF.Sources.Fetcher do
137145
# Link checker
138146

139147
defmodule LinkChecker do
148+
use Agent
149+
140150
@doc """
141151
Agent that record which links are currently fetched
142152
"""
143-
def start_link() do
153+
def start_link(_opts \\ []) do
144154
Agent.start_link(fn -> MapSet.new() end, name: Fetcher.link_checker_name())
145155
end
146156

apps/cf/lib/videos/captions_fetcher_youtube.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ defmodule CF.Videos.CaptionsFetcherYoutube do
77
@behaviour CF.Videos.CaptionsFetcher
88

99
require Logger
10-
import SweetXml
1110

1211
@user_agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/135.0"
1312

0 commit comments

Comments
 (0)