Skip to content

Commit

Permalink
Replace Application.get_env use with compile_env (#206)
Browse files Browse the repository at this point in the history
`compile_env` is more explicit and won't trigger
the `ApplicationConfigInModuleAttribute` credo warning.

https://hexdocs.pm/credo/Credo.Check.Warning.ApplicationConfigInModuleAttribute.html
  • Loading branch information
vorce authored Feb 2, 2021
1 parent 97966b0 commit 484a9ca
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/lasso.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ defmodule Lasso do
"""
require Logger

@cache_id Application.get_env(:lasso, Lasso)[:cache_name]
@request_limit Application.get_env(:lasso, Lasso)[:max_requests_per_lasso]
@cache_id Application.compile_env(:lasso, [Lasso, :cache_name])
@request_limit Application.compile_env(:lasso, [Lasso, :max_requests_per_lasso])

@topic inspect(__MODULE__)

Expand Down
4 changes: 3 additions & 1 deletion lib/lasso/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ defmodule Lasso.Application do

use Application

@cache_name Application.compile_env(:lasso, [Lasso, :cache_name])

def start(_type, _args) do
children = [
{ConCache,
[
name: Application.get_env(:lasso, Lasso)[:cache_name],
name: @cache_name,
ttl_check_interval: :timer.minutes(10),
global_ttl: :timer.hours(24),
ets_options: [:compressed],
Expand Down
2 changes: 1 addition & 1 deletion lib/lasso_web/live/admin_liveview.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule LassoWeb.AdminLiveView do

require Logger

@admin_events Application.get_env(:lasso, Lasso)[:admin_events_topic]
@admin_events Application.compile_env(:lasso, [Lasso, :admin_events_topic])

def render(assigns) do
LassoWeb.AdminView.render("index.html", assigns)
Expand Down
2 changes: 1 addition & 1 deletion lib/lasso_web/live/lasso_liveview.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule LassoWeb.LassoLiveView do

require Logger

@request_limit Application.get_env(:lasso, Lasso)[:max_requests_per_lasso]
@request_limit Application.compile_env(:lasso, [Lasso, :max_requests_per_lasso])

def render(assigns) do
LassoWeb.LassoViewView.render("lasso.html", assigns)
Expand Down

0 comments on commit 484a9ca

Please sign in to comment.