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

Fix warning caused by usage of deprecated Application.get_env #116

Merged
merged 1 commit into from
May 16, 2023
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
12 changes: 1 addition & 11 deletions lib/crontab/cron_expression/ecto_type.ex
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
# TODO: Replace with simple Code.ensure_compiled as soon as Elixir minimum
# version is raised to 1.10.

Code
|> function_exported?(:ensure_compiled, 1)
|> if do
match?({:module, Ecto.Type}, Code.ensure_compiled(Ecto.Type))
else
:erlang.apply(Code, :ensure_compiled?, [Ecto.Type])
end
|> if do
if match?({:module, Ecto.Type}, Code.ensure_compiled(Ecto.Type)) do
defmodule Crontab.CronExpression.Ecto.Type do
@moduledoc """
Provides a type for Ecto usage.
Expand Down
8 changes: 1 addition & 7 deletions lib/crontab/scheduler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ defmodule Crontab.Scheduler do
@type direction :: :increment | :decrement
@type result :: maybe(NaiveDateTime.t(), any)

# TODO: Remove if when requiring Elixir 1.10 + only
if function_exported?(Application, :compile_env, 3) do
@max_runs Application.compile_env(:crontab, :max_runs, 10_000)
else
# credo:disable-for-next-line Credo.Check.Warning.ApplicationConfigInModuleAttribute
@max_runs Application.get_env(:crontab, :max_runs, 10_000)
end
@max_runs Application.compile_env(:crontab, :max_runs, 10_000)

@doc """
This function provides the functionality to retrieve the next run date from a
Expand Down
10 changes: 1 addition & 9 deletions test/crontab/cron_expression/ecto_type_test.exs
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# TODO: Replace with simple Code.ensure_compiled as soon as Elixir min. version is raised to 1.10
Code
|> function_exported?(:ensure_compiled, 1)
|> if do
match?({:module, Ecto.Type}, Code.ensure_compiled(Ecto.Type))
else
:erlang.apply(Code, :ensure_compiled?, [Ecto.Type])
end
|> if do
if match?({:module, Ecto.Type}, Code.ensure_compiled(Ecto.Type)) do
defmodule Crontab.CronExpression.Ecto.TypeTest do
@moduledoc false

Expand Down