Skip to content

Commit 0cfd170

Browse files
committed
Fix credo
1 parent 1f2edb0 commit 0cfd170

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

.credo.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
{Credo.Check.Readability.ParenthesesInCondition, []},
105105
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
106106
{Credo.Check.Readability.PipeIntoAnonymousFunctions, []},
107-
{Credo.Check.Readability.PredicateFunctionNames, [exit_status: 0]},
107+
{Credo.Check.Readability.PredicateFunctionNames, []},
108108
{Credo.Check.Readability.PreferImplicitTry, []},
109109
{Credo.Check.Readability.RedundantBlankLines, []},
110110
{Credo.Check.Readability.Semicolons, []},

lib/ex_webrtc/peer_connection.ex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ defmodule ExWebRTC.PeerConnection do
10081008

10091009
# This is not defined in the W3C but see https://github.com/w3c/webrtc-pc/issues/2927
10101010
tr =
1011-
if SDPUtils.is_rejected(mline),
1011+
if SDPUtils.rejected?(mline),
10121012
do: RTPTransceiver.stop(tr, on_track_ended(owner, tr.receiver.track.id)),
10131013
else: tr
10141014

@@ -1028,7 +1028,7 @@ defmodule ExWebRTC.PeerConnection do
10281028
{:mid, mid} = ExSDP.get_attribute(mline, :mid)
10291029

10301030
direction =
1031-
if SDPUtils.is_rejected(mline),
1031+
if SDPUtils.rejected?(mline),
10321032
do: :inactive,
10331033
else: SDPUtils.get_media_direction(mline) |> reverse_direction()
10341034

@@ -1044,7 +1044,7 @@ defmodule ExWebRTC.PeerConnection do
10441044
tr = if sdp_type == :answer, do: %RTPTransceiver{tr | current_direction: direction}, else: tr
10451045

10461046
tr =
1047-
if SDPUtils.is_rejected(mline),
1047+
if SDPUtils.rejected?(mline),
10481048
do: RTPTransceiver.stop(tr, on_track_ended(owner, tr.receiver.track.id)),
10491049
else: tr
10501050

@@ -1160,7 +1160,7 @@ defmodule ExWebRTC.PeerConnection do
11601160
do: state
11611161

11621162
defp update_negotiation_needed(state) do
1163-
negotiation_needed = is_negotiation_needed(state.transceivers, state)
1163+
negotiation_needed = negotiation_needed?(state.transceivers, state)
11641164

11651165
cond do
11661166
negotiation_needed == true and state.negotiation_needed == true ->
@@ -1182,11 +1182,11 @@ defmodule ExWebRTC.PeerConnection do
11821182
# We don't support MSIDs and stopping transceivers so
11831183
# we only check 5.2 and 5.3 from 4.7.3#check-if-negotiation-is-needed
11841184
# https://www.w3.org/TR/webrtc/#dfn-check-if-negotiation-is-needed
1185-
defp is_negotiation_needed([], _), do: false
1185+
defp negotiation_needed?([], _), do: false
11861186

1187-
defp is_negotiation_needed([tr | _transceivers], _state) when tr.mid == nil, do: true
1187+
defp negotiation_needed?([tr | _transceivers], _state) when tr.mid == nil, do: true
11881188

1189-
defp is_negotiation_needed([tr | transceivers], state) do
1189+
defp negotiation_needed?([tr | transceivers], state) do
11901190
{local_desc_type, local_desc} = state.current_local_desc
11911191
{_, remote_desc} = state.current_remote_desc
11921192

@@ -1211,7 +1211,7 @@ defmodule ExWebRTC.PeerConnection do
12111211
true
12121212

12131213
true ->
1214-
is_negotiation_needed(transceivers, state)
1214+
negotiation_needed?(transceivers, state)
12151215
end
12161216
end
12171217

lib/ex_webrtc/peer_connection/configuration.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,20 @@ defmodule ExWebRTC.PeerConnection.Configuration do
157157
end
158158

159159
@doc false
160-
@spec is_supported_codec(t(), RTPCodecParameters.t()) :: boolean()
161-
def is_supported_codec(config, codec) do
160+
@spec supported_codec?(t(), RTPCodecParameters.t()) :: boolean()
161+
def supported_codec?(config, codec) do
162162
# This function doesn't check if rtcp-fb is supported.
163-
# Instead, `is_supported_rtcp_fb` has to be used to filter out
163+
# Instead, `supported_rtcp_fb?` has to be used to filter out
164164
# rtcp-fb that are not supported.
165165
Enum.any?(config.audio_codecs ++ config.video_codecs, fn supported_codec ->
166166
%{supported_codec | rtcp_fbs: codec.rtcp_fbs} == codec
167167
end)
168168
end
169169

170170
@doc false
171-
@spec is_supported_rtp_hdr_extension(t(), Extmap.t(), :audio | :video) ::
171+
@spec supported_rtp_hdr_extension?(t(), Extmap.t(), :audio | :video) ::
172172
boolean()
173-
def is_supported_rtp_hdr_extension(config, rtp_hdr_extension, media_type) do
173+
def supported_rtp_hdr_extension?(config, rtp_hdr_extension, media_type) do
174174
supported_uris =
175175
case media_type do
176176
:audio -> Map.keys(config.audio_rtp_hdr_exts)
@@ -181,8 +181,8 @@ defmodule ExWebRTC.PeerConnection.Configuration do
181181
end
182182

183183
@doc false
184-
@spec is_supported_rtcp_fb(t(), RTCPFeedback.t()) :: boolean()
185-
def is_supported_rtcp_fb(_config, _rtcp_fb), do: false
184+
@spec supported_rtcp_fb?(t(), RTCPFeedback.t()) :: boolean()
185+
def supported_rtcp_fb?(_config, _rtcp_fb), do: false
186186

187187
@doc false
188188
@spec update(t(), ExSDP.t()) :: t()

lib/ex_webrtc/rtp_transceiver.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,11 @@ defmodule ExWebRTC.RTPTransceiver do
239239
defp get_codecs(mline, config) do
240240
mline
241241
|> SDPUtils.get_rtp_codec_parameters()
242-
|> Stream.filter(&Configuration.is_supported_codec(config, &1))
242+
|> Stream.filter(&Configuration.supported_codec?(config, &1))
243243
|> Enum.map(fn codec ->
244244
rtcp_fbs =
245245
Enum.filter(codec.rtcp_fbs, fn rtcp_fb ->
246-
Configuration.is_supported_rtcp_fb(config, rtcp_fb)
246+
Configuration.supported_rtcp_fb?(config, rtcp_fb)
247247
end)
248248

249249
%RTPCodecParameters{codec | rtcp_fbs: rtcp_fbs}
@@ -253,6 +253,6 @@ defmodule ExWebRTC.RTPTransceiver do
253253
defp get_rtp_hdr_extensions(mline, config) do
254254
mline
255255
|> ExSDP.get_attributes(ExSDP.Attribute.Extmap)
256-
|> Enum.filter(&Configuration.is_supported_rtp_hdr_extension(config, &1, mline.type))
256+
|> Enum.filter(&Configuration.supported_rtp_hdr_extension?(config, &1, mline.type))
257257
end
258258
end

lib/ex_webrtc/sdp_utils.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ defmodule ExWebRTC.SDPUtils do
268268
|> Enum.find_index(fn {mline, idx} -> mline.port == 0 and idx not in indices end)
269269
end
270270

271-
@spec is_rejected(ExSDP.Media.t()) :: boolean()
272-
def is_rejected(%ExSDP.Media{port: 0}), do: true
273-
def is_rejected(%ExSDP.Media{}), do: false
271+
@spec rejected?(ExSDP.Media.t()) :: boolean()
272+
def rejected?(%ExSDP.Media{port: 0}), do: true
273+
def rejected?(%ExSDP.Media{}), do: false
274274

275275
defp do_get_ice_credentials(sdp_or_mline) do
276276
ice_ufrag =

test/ex_webrtc/sdp_utils_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ defmodule ExWebRTC.SDPUtilsTest do
33

44
alias ExWebRTC.SDPUtils
55

6-
test "is_rejected/1" do
6+
test "rejected?/1" do
77
mline = ExSDP.Media.new(:audio, 0, "UDP/TLS/RTP/SAVPF", [8])
8-
assert true == SDPUtils.is_rejected(mline)
8+
assert true == SDPUtils.rejected?(mline)
99

1010
mline = ExSDP.Media.new(:audio, 9, "UDP/TLS/RTP/SAVPF", [8])
11-
assert false == SDPUtils.is_rejected(mline)
11+
assert false == SDPUtils.rejected?(mline)
1212
end
1313
end

0 commit comments

Comments
 (0)