Skip to content

Commit 460c790

Browse files
committed
Add adobe/styler
1 parent 9dae62e commit 460c790

10 files changed

+25
-55
lines changed

.credo.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
{Credo.Check.Readability.AliasOrder, []},
9898
{Credo.Check.Readability.FunctionNames, []},
9999
{Credo.Check.Readability.LargeNumbers, []},
100-
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
100+
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 140]},
101101
{Credo.Check.Readability.ModuleAttributeNames, []},
102102
{Credo.Check.Readability.ModuleDoc, []},
103103
{Credo.Check.Readability.ModuleNames, []},

.formatter.exs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Used by "mix format"
22
[
3-
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
4+
plugins: [Styler]
45
]

lib/poolex.ex

+4-10
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ defmodule Poolex do
195195
try do
196196
GenServer.call(pool_id, {:get_idle_worker, caller_reference}, checkout_timeout)
197197
catch
198-
:exit,
199-
{:timeout, {GenServer, :call, [_pool_id, {:get_idle_worker, ^caller_reference}, _timeout]}} ->
198+
:exit, {:timeout, {GenServer, :call, [_pool_id, {:get_idle_worker, ^caller_reference}, _timeout]}} ->
200199
{:error, :checkout_timeout}
201200
after
202201
GenServer.cast(pool_id, {:cancel_waiting, caller_reference})
@@ -264,8 +263,7 @@ defmodule Poolex do
264263
raise ArgumentError, message
265264
end
266265

267-
def add_idle_workers!(pool_id, workers_count)
268-
when is_atom(pool_id) and is_integer(workers_count) do
266+
def add_idle_workers!(pool_id, workers_count) when is_atom(pool_id) and is_integer(workers_count) do
269267
GenServer.call(pool_id, {:add_idle_workers, workers_count})
270268
end
271269

@@ -280,8 +278,7 @@ defmodule Poolex do
280278
raise ArgumentError, message
281279
end
282280

283-
def remove_idle_workers!(pool_id, workers_count)
284-
when is_atom(pool_id) and is_integer(workers_count) do
281+
def remove_idle_workers!(pool_id, workers_count) when is_atom(pool_id) and is_integer(workers_count) do
285282
GenServer.call(pool_id, {:remove_idle_workers, workers_count})
286283
end
287284

@@ -461,10 +458,7 @@ defmodule Poolex do
461458
end
462459

463460
@impl GenServer
464-
def handle_info(
465-
{:DOWN, monitoring_reference, _process, dead_process_pid, _reason},
466-
%State{} = state
467-
) do
461+
def handle_info({:DOWN, monitoring_reference, _process, dead_process_pid, _reason}, %State{} = state) do
468462
case Monitoring.remove(state.monitor_pid, monitoring_reference) do
469463
:worker ->
470464
{:noreply, handle_down_worker(state, dead_process_pid)}

lib/poolex/private/busy_workers.ex

+1-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ defmodule Poolex.Private.BusyWorkers do
2323

2424
@doc false
2525
@spec remove(State.t(), Poolex.worker()) :: State.t()
26-
def remove(
27-
%State{busy_workers_impl: impl, busy_workers_state: busy_workers_state} = state,
28-
worker
29-
) do
26+
def remove(%State{busy_workers_impl: impl, busy_workers_state: busy_workers_state} = state, worker) do
3027
%State{state | busy_workers_state: impl.remove(busy_workers_state, worker)}
3128
end
3229

lib/poolex/private/idle_workers.ex

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ defmodule Poolex.Private.IdleWorkers do
1717

1818
@doc false
1919
@spec remove(State.t(), Poolex.worker()) :: State.t()
20-
def remove(
21-
%State{idle_workers_impl: impl, idle_workers_state: idle_workers_state} = state,
22-
worker
23-
) do
20+
def remove(%State{idle_workers_impl: impl, idle_workers_state: idle_workers_state} = state, worker) do
2421
%State{state | idle_workers_state: impl.remove(idle_workers_state, worker)}
2522
end
2623

lib/poolex/private/waiting_callers.ex

+3-11
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ defmodule Poolex.Private.WaitingCallers do
1111

1212
@doc false
1313
@spec add(State.t(), Poolex.Caller.t()) :: State.t()
14-
def add(
15-
%State{waiting_callers_impl: impl, waiting_callers_state: waiting_callers_state} = state,
16-
caller
17-
) do
14+
def add(%State{waiting_callers_impl: impl, waiting_callers_state: waiting_callers_state} = state, caller) do
1815
%State{state | waiting_callers_state: impl.add(waiting_callers_state, caller)}
1916
end
2017

@@ -26,9 +23,7 @@ defmodule Poolex.Private.WaitingCallers do
2623

2724
@doc false
2825
@spec pop(State.t()) :: {Poolex.Caller.t(), State.t()} | :empty
29-
def pop(
30-
%State{waiting_callers_impl: impl, waiting_callers_state: waiting_callers_state} = state
31-
) do
26+
def pop(%State{waiting_callers_impl: impl, waiting_callers_state: waiting_callers_state} = state) do
3227
case impl.pop(waiting_callers_state) do
3328
{caller, new_waiting_callers_state} ->
3429
{caller, %State{state | waiting_callers_state: new_waiting_callers_state}}
@@ -40,10 +35,7 @@ defmodule Poolex.Private.WaitingCallers do
4035

4136
@doc false
4237
@spec remove_by_pid(State.t(), caller_pid :: pid()) :: State.t()
43-
def remove_by_pid(
44-
%State{waiting_callers_impl: impl, waiting_callers_state: waiting_callers_state} = state,
45-
caller
46-
) do
38+
def remove_by_pid(%State{waiting_callers_impl: impl, waiting_callers_state: waiting_callers_state} = state, caller) do
4739
%State{state | waiting_callers_state: impl.remove_by_pid(waiting_callers_state, caller)}
4840
end
4941

mix.exs

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ defmodule Poolex.MixProject do
3838
{:doctor, ">= 0.0.0", only: [:dev], runtime: false},
3939
{:ex_check, "~> 0.16.0", only: [:dev], runtime: false},
4040
{:ex_doc, ">= 0.0.0", only: [:dev], runtime: false},
41-
{:makeup_diff, ">= 0.0.0", only: [:dev], runtime: false}
41+
{:makeup_diff, ">= 0.0.0", only: [:dev], runtime: false},
42+
{:styler, "~> 1.1", only: [:dev, :test], runtime: false}
4243
]
4344
end
4445

mix.lock

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"},
1616
"makeup_erlang": {:hex, :makeup_erlang, "1.0.0", "6f0eff9c9c489f26b69b61440bf1b238d95badae49adac77973cbacae87e3c2e", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "ea7a9307de9d1548d2a72d299058d1fd2339e3d398560a0e46c27dab4891e4d2"},
1717
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
18+
"styler": {:hex, :styler, "1.1.2", "d5b14cd4f8f7cc45624d9485cd0edb277ec92583b118409cfcbcb7c78efa5f4b", [:mix], [], "hexpm", "b46edab1f129d0c839d426755e172cf92118e5fac877456d074156b335f1f80b"},
1819
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
1920
"telemetry_poller": {:hex, :telemetry_poller, "1.1.0", "58fa7c216257291caaf8d05678c8d01bd45f4bdbc1286838a28c4bb62ef32999", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "9eb9d9cbfd81cbd7cdd24682f8711b6e2b691289a0de6826e58452f28c103c8f"},
2021
}

test/poolex_test.exs

+9-21
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
defmodule PoolexTest do
22
use ExUnit.Case, async: false
3-
import PoolHelpers
43

5-
doctest Poolex
4+
import PoolHelpers
65

76
alias Poolex.Private.DebugInfo
87

8+
doctest Poolex
9+
910
describe "debug info" do
1011
test "valid after initialization" do
1112
initial_fun = fn -> 0 end
@@ -202,12 +203,9 @@ defmodule PoolexTest do
202203
test "works on callers" do
203204
pool_name = start_pool(worker_module: SomeWorker, workers_count: 1)
204205

205-
1..10
206-
|> Enum.each(fn _ ->
206+
Enum.each(1..10, fn _ ->
207207
spawn(fn ->
208-
Poolex.run(pool_name, fn pid ->
209-
GenServer.call(pid, {:do_some_work_with_delay, :timer.seconds(4)})
210-
end)
208+
Poolex.run(pool_name, fn pid -> GenServer.call(pid, {:do_some_work_with_delay, :timer.seconds(4)}) end)
211209
end)
212210
end)
213211

@@ -523,21 +521,13 @@ defmodule PoolexTest do
523521
assert Poolex.child_spec(pool_id: :test_pool, worker_module: SomeWorker, workers_count: 5) ==
524522
%{
525523
id: :test_pool,
526-
start:
527-
{Poolex, :start_link,
528-
[[pool_id: :test_pool, worker_module: SomeWorker, workers_count: 5]]}
524+
start: {Poolex, :start_link, [[pool_id: :test_pool, worker_module: SomeWorker, workers_count: 5]]}
529525
}
530526

531-
assert Poolex.child_spec(
532-
pool_id: {:global, :biba},
533-
worker_module: SomeWorker,
534-
workers_count: 10
535-
) ==
527+
assert Poolex.child_spec(pool_id: {:global, :biba}, worker_module: SomeWorker, workers_count: 10) ==
536528
%{
537529
id: {:global, :biba},
538-
start:
539-
{Poolex, :start_link,
540-
[[pool_id: {:global, :biba}, worker_module: SomeWorker, workers_count: 10]]}
530+
start: {Poolex, :start_link, [[pool_id: {:global, :biba}, worker_module: SomeWorker, workers_count: 10]]}
541531
}
542532
end
543533
end
@@ -681,9 +671,7 @@ defmodule PoolexTest do
681671
ExUnit.Callbacks.start_supervised({Registry, [keys: :unique, name: TestRegistry]})
682672
name = {:via, Registry, {TestRegistry, "pool"}}
683673

684-
ExUnit.Callbacks.start_supervised(
685-
{Poolex, [pool_id: name, worker_module: SomeWorker, workers_count: 5]}
686-
)
674+
ExUnit.Callbacks.start_supervised({Poolex, [pool_id: name, worker_module: SomeWorker, workers_count: 5]})
687675

688676
state = Poolex.get_state(name)
689677

test/support/metrics_case.ex

+1-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ defmodule Poolex.MetricsCase do
4848
Enum.each(Map.get(groups, name, []), fn metric ->
4949
send(
5050
self,
51-
{:metric, metric.name, Map.get(measurements, metric.measurement),
52-
extract_tags(metric, metadata)}
51+
{:metric, metric.name, Map.get(measurements, metric.measurement), extract_tags(metric, metadata)}
5352
)
5453
end)
5554
end

0 commit comments

Comments
 (0)