Skip to content

Commit 9fcbeb5

Browse files
committed
refactor(core): fix credo+dialyzer warnings
1 parent 223894a commit 9fcbeb5

File tree

4 files changed

+20
-25
lines changed

4 files changed

+20
-25
lines changed

core/lib/core/adapters/connectors/event_connectors/mqtt.ex

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ defmodule Core.Adapters.Connectors.EventConnectors.Mqtt do
7878
Logger.warning(
7979
"MQTT Event Connector: invocation of #{module}/#{function} failed with error #{inspect(err)}"
8080
)
81-
82-
other ->
83-
Logger.warning(
84-
"MQTT Event Connector: invocation of #{module}/#{function} failed with cause #{inspect(other)}"
85-
)
8681
end
8782

8883
{:noreply, params}

core/lib/core/adapters/telemetry/monitor.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ defmodule Core.Adapters.Telemetry.Monitor do
5858

5959
@impl true
6060
def handle_info({:nodeup, node}, dynamic_supervisor) do
61-
if is_worker(node) do
61+
if worker?(node) do
6262
_ =
6363
DynamicSupervisor.start_child(
6464
dynamic_supervisor,
@@ -91,7 +91,7 @@ defmodule Core.Adapters.Telemetry.Monitor do
9191
end
9292
end
9393

94-
defp is_worker(node) do
94+
defp worker?(node) do
9595
node |> Atom.to_string() |> String.contains?("worker")
9696
end
9797
end

core/lib/core/domain/policies/app.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ defimpl Core.Domain.Policies.SchedulingPolicy, for: Data.Configurations.APP do
143143
end
144144
end)
145145
|> Enum.filter(fn w ->
146-
is_valid?(w, function, invalidate_capacity, invalidate_invocations)
146+
valid?(w, function, invalidate_capacity, invalidate_invocations)
147147
end)
148148

149149
case filtered_workers do
@@ -188,13 +188,13 @@ defimpl Core.Domain.Policies.SchedulingPolicy, for: Data.Configurations.APP do
188188
- true if the worker can host the function, given the conditions
189189
- false otherwise
190190
"""
191-
@spec is_valid?(
191+
@spec valid?(
192192
Data.Worker.t(),
193193
Data.FunctionStruct.t(),
194194
number() | :infinity,
195195
number() | :infinity
196196
) :: boolean
197-
def is_valid?(
197+
def valid?(
198198
%Data.Worker{
199199
concurrent_functions: c,
200200
resources: %Data.Worker.Metrics{

core/test/core/unit/policies/app_policy_test.exs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ defmodule Core.Unit.Policies.AppPolicyTest do
5050
end
5151
end
5252

53-
describe "is_valid?" do
54-
test "is_valid? should return true when invalidate options are :infinity and the worker can host the function",
53+
describe "valid?" do
54+
test "valid? should return true when invalidate options are :infinity and the worker can host the function",
5555
%{impl: app_impl} do
5656
wrk = %Worker{
5757
name: "worker@localhost",
@@ -73,15 +73,15 @@ defmodule Core.Unit.Policies.AppPolicyTest do
7373
invalidate_capacity = :infinity
7474
invalidate_invocations = :infinity
7575

76-
assert app_impl.is_valid?(
76+
assert app_impl.valid?(
7777
wrk,
7878
function,
7979
invalidate_capacity,
8080
invalidate_invocations
8181
) == true
8282
end
8383

84-
test "is_valid? should return true when invalidate options are satisfied and the worker can host the function",
84+
test "valid? should return true when invalidate options are satisfied and the worker can host the function",
8585
%{impl: app_impl} do
8686
wrk = %Worker{
8787
name: "worker@localhost",
@@ -103,15 +103,15 @@ defmodule Core.Unit.Policies.AppPolicyTest do
103103
invalidate_capacity = 50
104104
invalidate_invocations = 1
105105

106-
assert app_impl.is_valid?(
106+
assert app_impl.valid?(
107107
wrk,
108108
function,
109109
invalidate_capacity,
110110
invalidate_invocations
111111
) == true
112112
end
113113

114-
test "is_valid? should return false when invalidate options are :infinity and the worker can't host the function",
114+
test "valid? should return false when invalidate options are :infinity and the worker can't host the function",
115115
%{impl: app_impl} do
116116
wrk = %Worker{
117117
name: "worker@localhost",
@@ -133,15 +133,15 @@ defmodule Core.Unit.Policies.AppPolicyTest do
133133
invalidate_capacity = :infinity
134134
invalidate_invocations = :infinity
135135

136-
assert app_impl.is_valid?(
136+
assert app_impl.valid?(
137137
wrk,
138138
function,
139139
invalidate_capacity,
140140
invalidate_invocations
141141
) == false
142142
end
143143

144-
test "is_valid? should return false when invalidate options are not satisfied or the worker can't host the function",
144+
test "valid? should return false when invalidate options are not satisfied or the worker can't host the function",
145145
%{impl: app_impl} do
146146
wrk = %Worker{
147147
name: "worker@localhost",
@@ -163,21 +163,21 @@ defmodule Core.Unit.Policies.AppPolicyTest do
163163
invalidate_capacity = 49
164164
invalidate_invocations = 1
165165

166-
assert app_impl.is_valid?(
166+
assert app_impl.valid?(
167167
wrk,
168168
function,
169169
invalidate_capacity,
170170
invalidate_invocations
171171
) == false
172172

173-
assert app_impl.is_valid?(
173+
assert app_impl.valid?(
174174
wrk |> Map.put(:concurrent_functions, 1),
175175
function,
176176
invalidate_capacity,
177177
invalidate_invocations
178178
) == false
179179

180-
assert app_impl.is_valid?(
180+
assert app_impl.valid?(
181181
wrk |> Map.put(:resources, %Metrics{memory: %{available: 127, total: 256}}),
182182
function,
183183
invalidate_capacity,
@@ -266,7 +266,7 @@ defmodule Core.Unit.Policies.AppPolicyTest do
266266
function: function
267267
} do
268268
assert app_impl.select(script, workers, function) == {:ok, wrk}
269-
assert app_impl.is_valid?(wrk, function, :infinity, :infinity)
269+
assert app_impl.valid?(wrk, function, :infinity, :infinity)
270270

271271
# invalidating the first worker causes select() to choose "worker2"
272272
workers_invalid_first = [
@@ -279,13 +279,13 @@ defmodule Core.Unit.Policies.AppPolicyTest do
279279
]
280280

281281
assert app_impl.select(script, workers_invalid_first, function) == {:ok, wrk2}
282-
assert app_impl.is_valid?(wrk2, function, :infinity, :infinity)
282+
assert app_impl.valid?(wrk2, function, :infinity, :infinity)
283283
end
284284

285285
test "select should return a valid worker in the script when the strategy is :random",
286286
%{impl: app_impl, workers: workers, script: script, function: function} do
287287
{:ok, wrk} = app_impl.select(script, workers, function)
288-
assert app_impl.is_valid?(wrk, function, :infinity, :infinity)
288+
assert app_impl.valid?(wrk, function, :infinity, :infinity)
289289
assert Enum.member?(workers, wrk) == true
290290
end
291291

@@ -305,7 +305,7 @@ defmodule Core.Unit.Policies.AppPolicyTest do
305305
{:ok, wrk} = app_impl.select(platform_script, workers, function)
306306
{:ok, wrk_default} = default_impl.select(%Data.Configurations.Empty{}, workers, function)
307307

308-
assert app_impl.is_valid?(wrk, function, :infinity, :infinity)
308+
assert app_impl.valid?(wrk, function, :infinity, :infinity)
309309
assert Enum.member?(workers, wrk) == true
310310
assert wrk_default == wrk
311311
end

0 commit comments

Comments
 (0)