Skip to content

Commit 4a97151

Browse files
committed
Satisfy the compiler
1 parent f09983c commit 4a97151

10 files changed

Lines changed: 56 additions & 38 deletions

File tree

lib/membrane/children_spec.ex

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,9 @@ defmodule Membrane.ChildrenSpec do
452452
via_in(builder, :input)
453453
end
454454
|> Builder.finish_link(child_name)
455-
|> then(&%Builder{&1 | children: [child_spec | &1.children]})
455+
|> then(fn %Builder{} = builder ->
456+
%Builder{builder | children: [child_spec | builder.children]}
457+
end)
456458
end
457459

458460
@doc """
@@ -465,7 +467,9 @@ defmodule Membrane.ChildrenSpec do
465467
:ok = validate_pad_name(pad)
466468

467469
get_child({Membrane.Bin, :itself})
468-
|> then(&%Builder{&1 | status: :from_pad, from_pad: pad, from_pad_props: %{}})
470+
|> then(fn %Builder{} = builder ->
471+
%Builder{builder | status: :from_pad, from_pad: pad, from_pad_props: %{}}
472+
end)
469473
end
470474

471475
@doc """
@@ -488,7 +492,9 @@ defmodule Membrane.ChildrenSpec do
488492
else
489493
via_out(builder, :output)
490494
end
491-
|> then(&%Builder{&1 | status: :to_pad, to_pad: pad, to_pad_props: %{}})
495+
|> then(fn %Builder{} = builder ->
496+
%Builder{builder | status: :to_pad, to_pad: pad, to_pad_props: %{}}
497+
end)
492498
|> get_child({Membrane.Bin, :itself})
493499
end
494500

@@ -572,7 +578,9 @@ defmodule Membrane.ChildrenSpec do
572578
else
573579
via_out(builder, :output)
574580
end
575-
|> then(&%Builder{&1 | status: :to_pad, to_pad: pad, to_pad_props: Enum.into(props, %{})})
581+
|> then(fn %Builder{} = builder ->
582+
%Builder{builder | status: :to_pad, to_pad: pad, to_pad_props: Enum.into(props, %{})}
583+
end)
576584
end
577585

578586
@doc """

lib/membrane/core/element/lifecycle_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ defmodule Membrane.Core.Element.LifecycleController do
7373
end
7474

7575
@spec handle_playing(State.t()) :: State.t()
76-
def handle_playing(state) do
76+
def handle_playing(%State{} = state) do
7777
Membrane.Logger.debug("Got play request")
7878

7979
state =

lib/membrane/core/element/manual_flow_controller.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ defmodule Membrane.Core.Element.ManualFlowController do
8080
|> handle_delayed_demands()
8181
end
8282

83-
defp do_supply_demand(pad_ref, state) do
83+
defp do_supply_demand(pad_ref, %State{} = state) do
8484
# marking is state that actual demand supply has been started (note changing back to false when finished)
8585
state = %State{state | delay_demands?: true}
8686

@@ -90,7 +90,7 @@ defmodule Membrane.Core.Element.ManualFlowController do
9090
InputQueue.take(pad_data.input_queue, pad_data.manual_demand_size)
9191

9292
state = PadModel.set_data!(state, pad_ref, :input_queue, new_input_queue)
93-
state = handle_input_queue_output(pad_ref, popped_data, state)
93+
%State{} = state = handle_input_queue_output(pad_ref, popped_data, state)
9494
%State{state | delay_demands?: false}
9595
end
9696

lib/membrane/core/element/playback_queue.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ defmodule Membrane.Core.Element.PlaybackQueue do
1212

1313
@spec eval(State.t()) :: State.t()
1414
def eval(%State{playback_queue: playback_queue} = state) do
15-
state =
15+
%State{} =
16+
state =
1617
playback_queue
1718
|> List.foldr(state, fn function, state -> function.(state) end)
1819

lib/membrane/core/parent/child_life_controller/crash_group_utils.ex

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,14 @@ defmodule Membrane.Core.Parent.ChildLifeController.CrashGroupUtils do
9292

9393
update_in(
9494
state.crash_groups[group.name],
95-
&%CrashGroup{
96-
&1
97-
| detonating?: true,
98-
crash_initiator: crash_initiator,
99-
crash_reason: reason
100-
}
95+
fn %CrashGroup{} = group ->
96+
%CrashGroup{
97+
group
98+
| detonating?: true,
99+
crash_initiator: crash_initiator,
100+
crash_reason: reason
101+
}
102+
end
101103
)
102104
end
103105

lib/membrane/core/parent/child_life_controller/link_utils.ex

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,14 @@ defmodule Membrane.Core.Parent.ChildLifeController.LinkUtils do
156156
links =
157157
Enum.map(
158158
links,
159-
&%Link{
160-
&1
161-
| spec_ref: spec_ref,
162-
from: resolve_endpoint(&1.from, state),
163-
to: resolve_endpoint(&1.to, state)
164-
}
159+
fn %Link{} = link ->
160+
%Link{
161+
link
162+
| spec_ref: spec_ref,
163+
from: resolve_endpoint(link.from, state),
164+
to: resolve_endpoint(link.to, state)
165+
}
166+
end
165167
)
166168

167169
:ok = validate_links(links, state)
@@ -235,13 +237,12 @@ defmodule Membrane.Core.Parent.ChildLifeController.LinkUtils do
235237
end
236238
end
237239

238-
defp resolve_endpoint(endpoint, state) do
239-
%Endpoint{child: child, pad_spec: pad_spec} = endpoint
240-
child_data = Parent.ChildrenModel.get_child_data!(state, child)
241-
pad_name = Pad.name_by_ref(pad_spec)
240+
defp resolve_endpoint(%Endpoint{} = endpoint, state) do
241+
child_data = Parent.ChildrenModel.get_child_data!(state, endpoint.child)
242+
pad_name = Pad.name_by_ref(endpoint.pad_spec)
242243

243244
withl pad: {:ok, pad_info} <- Keyword.fetch(child_data.module.membrane_pads(), pad_name),
244-
ref: {:ok, ref} <- make_pad_ref(pad_spec, pad_info.availability) do
245+
ref: {:ok, ref} <- make_pad_ref(endpoint.pad_spec, pad_info.availability) do
245246
%Endpoint{
246247
endpoint
247248
| pid: child_data.pid,
@@ -251,11 +252,12 @@ defmodule Membrane.Core.Parent.ChildLifeController.LinkUtils do
251252
}
252253
else
253254
pad: :error ->
254-
raise LinkError, "Child #{inspect(child)} does not have pad #{inspect(pad_spec)}"
255+
raise LinkError,
256+
"Child #{inspect(endpoint.child)} does not have pad #{inspect(endpoint.pad_spec)}"
255257

256258
ref: {:error, :invalid_availability} ->
257259
raise LinkError,
258-
"Dynamic pad ref #{inspect(pad_spec)} passed for static pad of child #{inspect(child)}"
260+
"Dynamic pad ref #{inspect(endpoint.pad_spec)} passed for static pad of child #{inspect(endpoint.child)}"
259261
end
260262
end
261263

lib/membrane/core/parent/child_life_controller/startup_utils.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ defmodule Membrane.Core.Parent.ChildLifeController.StartupUtils do
172172
:ok
173173
end
174174

175-
defp start_child(child, node, syncs, log_metadata, group, state) do
175+
defp start_child(%ChildEntry{} = child, node, syncs, log_metadata, group, state) do
176176
%ChildEntry{name: name, module: module, options: options} = child
177177

178178
Membrane.Logger.debug(

lib/membrane/core/parent/specification_parser.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ defmodule Membrane.Core.Parent.SpecificationParser do
2828
%ChildrenSpec.Builder{links: links, children: children, status: :done} = builder ->
2929
if links == [] and children == [] do
3030
Membrane.Logger.warning(
31-
"The specification you have passed: #{builder} has no effect - it doesn't produce any children nor links."
31+
"The specification you have passed: #{inspect(builder)} has no effect - it doesn't produce any children nor links."
3232
)
3333
end
3434

lib/membrane/core/timer.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ defmodule Membrane.Core.Timer do
4040
end
4141

4242
@spec update_ratio(t, Clock.ratio()) :: t
43-
def update_ratio(timer, ratio) do
43+
def update_ratio(%__MODULE__{} = timer, ratio) do
4444
%__MODULE__{timer | ratio: ratio}
4545
end
4646

@@ -55,7 +55,7 @@ defmodule Membrane.Core.Timer do
5555
timer
5656
end
5757

58-
def tick(timer) do
58+
def tick(%__MODULE__{} = timer) do
5959
%__MODULE__{
6060
id: id,
6161
interval: interval,
@@ -89,7 +89,7 @@ defmodule Membrane.Core.Timer do
8989
|> tick()
9090
end
9191

92-
def set_interval(timer, interval) do
92+
def set_interval(%__MODULE__{} = timer, interval) do
9393
%__MODULE__{timer | interval: interval}
9494
end
9595
end

mix.exs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ defmodule Membrane.Mixfile do
1717
source_url: link(),
1818
docs: docs(),
1919
aliases: [docs: ["docs", &copy_assets/1]],
20-
preferred_cli_env: [
21-
coveralls: :test,
22-
"coveralls.detail": :test,
23-
"coveralls.post": :test,
24-
"coveralls.html": :test
25-
],
2620
test_coverage: [tool: ExCoveralls, test_task: "test"],
2721
deps: deps()
2822
]
@@ -32,6 +26,17 @@ defmodule Membrane.Mixfile do
3226
[extra_applications: [:logger]]
3327
end
3428

29+
def cli do
30+
[
31+
preferred_envs: [
32+
coveralls: :test,
33+
"coveralls.detail": :test,
34+
"coveralls.post": :test,
35+
"coveralls.html": :test
36+
]
37+
]
38+
end
39+
3540
defp elixirc_paths(:test), do: ["lib", "test/support"]
3641
defp elixirc_paths(:benchmark), do: ["lib", "benchmark"]
3742
defp elixirc_paths(_env), do: ["lib"]

0 commit comments

Comments
 (0)